netdaemon
netdaemon copied to clipboard
Make common entity types available without the code generator
The problem
I'm developing drop-in style automations that only rely on entity ids and similar configuration entries. I still want to use strongly typed entities like LikeEntity
, but these are only defined in the generated code file, which I don't want to use at all.
The proposed solution
Move these types to a dedicated NuGet package or the HassModel
package. The generated code should just reference these types.
The alternatives
Add a command line option to nd_codegen
to only generate these generic types and skip anything specific to the running HA instance.
Additional context
As a workaround, I'm now copying these types from the generated file.
The code-gen workflow indeed works best when developing for your own HA instance and is not suited well for generic solutions.
One problem I see is how to decide what to include and what not. HA keeps adding stuff like new domains, but also services for existing domains etc. If we were to do this I would suggest a separate package that users opt in to using.
Your work around copying the generated code sounds pretty workable actually. The benefit is that you have exactly what you need for your project. If we would have this in a package and it lacks something you need you would again have to add it yourself.
This is now resolved with the new I..EntityCore interfaces