HASwitchPlate / openHASP-custom-component

Home Assistant custom component for openHASP
https://www.openhasp.com
MIT License
49 stars 9 forks source link

Feature request: Implement contexts #96

Closed nagyrobi closed 5 months ago

nagyrobi commented 2 years ago

Is your feature request related to a problem? Please describe. Home Assistant supports contexts for states, to determine what caused them.

In the example below, the switch was turned off from an OpenHASP plate, and was turned on from Lovelace dashboard:

kép

Yes, the lovelace dashboard requires an user to be logged in, to display a nice username, however, contexts can also use a parent_id to be used when entities change states from automations, scripts, etc.

The goal is not only to have this information displayed, but also to determine within HA from which plate came the change and take automation actions taking that in consideration. Often use cases inclue automations which need to know if the state of an entity was previously changed by a user or by another automation/script.

kép

Describe the solution you'd like Since the username is not relevant anways when standing in front of the plate and switching entities, it would be very useful to at least know which plate initiated the state change. Use plate's slug for that.

Describe alternatives you've considered Eventually we could create dummy usernames for each plate just for the purpose of display, and have a parameter set in the yaml of the plate to specify the user_id of it to set the context accordingly - and have them displayed nicely.

Additional context https://community.home-assistant.io/t/work-with-triggered-by-in-automations/400352/7 https://community.home-assistant.io/t/is-it-possible-to-know-when-physical-button-is-pressed/327397/8

akloeckner commented 10 months ago

Please have a look at #112, which adds contexts to the event services. I am not sure though, if this solves your issues, because the context by itself does not hold information on the plate or anything else. It's just a unique ID. Please feel free to comment and suggest improvements!