bitfocus / companion-module-homeassistant-server

MIT License
12 stars 7 forks source link

Specifying any entity type #16

Closed iticory closed 2 years ago

iticory commented 2 years ago

Would it be possible to create more generic actions and feedbacks that allow arbitrary entity_id values to be specified in a text field?

A button press action called "Toggle" could simply call the generic homeassistant.toggle service with the specified entity_id without needing your code to worry about its current state or anything.

Similarly, a feedback called "Entity State" could return the boolean value of any entity specified, regardless of what domain it's in.

This would allow me to easily use things like my group entities (and others) without needing you to add support for every possible domain.

I definitely appreciate the recently added additional entity types. This means I need to create fewer superfluous template switches in my config just for supporting my companion surfaces. ;)

Thank you very much for your work on this very helpful module!

Julusian commented 2 years ago

It appears that we can get a list of the available services, so a generic 'call service' action sounds doable https://github.com/home-assistant/home-assistant-js-websocket#services And companion does now support a dropdown input field which can have also have custom values entered too. So what you are asking for is definitely doable.

Im not entirely sure about the feedback though, cant the state also be not a boolean, meaning that comparison wont be good? Maybe this is possible already through the variables we create? I dont remember if variables are created for all entities, or just those that this module understands.

Julusian commented 2 years ago

There is now a 'Call service' action which allows for calling any service with any custom written payload. I haven't done a feedback for now, hopefully this will work well enough through variables, or if not I can look at exposing some attributes as variables

rohankapoorcom commented 2 years ago

@Julusian - was this released? It doesn't look it isn't included in the v0.8.0 tag.

Julusian commented 2 years ago

Yes this is in v0.8.0 There is an additional change which I made afterwards to suggest service names, but the action works fine without that

rohankapoorcom commented 2 years ago

I'm not seeing the new options on my raspberry pi companion build after running companion-update. I'm guessing it's because the package.json for companion is still pointing at the previous tag? https://github.com/bitfocus/companion/blob/493404d6dd19aff182cf26b0cf61fc96f76075be/package.json#L314

Julusian commented 2 years ago

Your companionpi is probably using the master branch, but you will need to switch to the beta branch to get this update. Only when companion 2.2.1 is being prepared for release will the change make it to master

rohankapoorcom commented 2 years ago

Ah perfect. That's the issue. I didn't realize the master branch wasn't used for continuous integration.

Thanks Julian.