Create dynamic entities and groups

I use AppDaemon heavily for my automations. I use HomeAssistant groups and input_* devices to provide user updatable configuration information to my apps (activate deactivate alarm clock, set when to switch from daytime to night time mode, set the state for the house (normal, party, holiday, etc). My AD apps then read the state of these devices to decide what to do and if there are any exceptions to the normal automation rules.

It would be nice to be able to have my devices create HA groups and entities (the input_boolean, input_select, input_slider types, not actual devices) when they start up if they do not exist. It makes installation of apps by others easier, since they don’t have to remember to create the groups and devices. It also makes my code a little more bulletproof in that it can create devices and groups that it needs for operations. Ideally, it would create these groups in the active HA dictionary, and have the written to the configuration.yaml file as well.

I don’t quite like HA writing to my config. I keep it versioned and deploy it to a different host. One of the things I like about HA is the clear separation between config and data.

Regarding your use case, I use packages, where the related configuration is included. Ie my alarmclock.yaml includes the inputs it needs. Are you using a package based configuration strategy?

No but I would not be opposed to that as long as AD can create the entities in it. I’m fine with it being in a new dynamic config file of some type that AD reads and integrates in so that it doesn’t impact people’s core configuration.

1 Like

I would like a variation on this theme… I would like to be able to template groups. The idea being I could have a group that shows all entities a given state, e.g. all media players that are currently playing. I would love this.

I could give you something using AppDaemon that does this, but you would manually have to create the group in home assistant for it to write to.

Yea, that could be interesting. Please do share :slight_smile:

On that note, does HASS (or yaml?) allow a file thats been included through “include:” to have its own include? If thats the case, I would let that app right to that file. Provides a tiny bit of isolation

It wouldn’t write to a file in this case. It would be dynamic. But a group has to exist for it to dynamically add and remove items from. But ever time you restart HA it would re-populate the group and would update it as items change state with maybe a catch all timed update every 5 minutes or so in case it misses an event.

Awesome. I would love to try it!

Do you have appdaemon installed? If so which version?

Yes. I’m using the latest release that is in the docker image. I believe it is 2.1.2

@turboc any issues with that version?

I don’t know of any. We will give it a try. I hope to get this knocked out this weekend. But the wife may have something to say about that. You never know.

give the code here a try. It’s definitely still an Alpha test. Read the docs at the top of the file. Have you used appdaemon before?