It’s my first post here, so a friendly hello from a fellow HA enthusiast who started his journey a year ago.
One of my current “projects” is the challenge of automating lights properly, so that manual control, motion, and timers can be used at the same time without resorting to overly complex automations.
I am not sure if this is a great idea, but I was thinking if the light entity in HA couldn’t be improved in a fashion that each light actually offers a set of three virtual properties for each of its main properties (e.g. the is_on and color properties):
- Manual
- Timer
- Motion
(Technically/semantically, it doesn’t matter that they are named, it could just be three or more generic-purpose properties, but for most of the cases, these could be named to ease consistent use).
For deciding, if the light should be on, the logic of the light decorator could then e.g. just perform a logic OR on these three properties and pass the computed state on to the LightEntity. This would mean, that cases that - to my knowledge - are hard to automate, are no longer a problem: for example, a light that has been switched on manually can receive an additional turn_on for the motion is_on property - it will not change state and remain on, BUT, after the motion is cleared, clearing the on_state on the motion property won’t switch off the light. Same as there will be no interference between a motion sensor and timer events. The light will be off, if neither a timer nor a motion switches the light on. But the ending of motion or a timer won’t cancel the other out.
It is just a basic idea that can be refined in detail (e.g. for the brightness property, take the maximum value of all inputs; what to do with different color values). E.g. a forced manual off state could be added, using a fourth manual input or more states of the manual on property.
Anyway, I am a programmer but haven’t contributed to HA yet, but would love to do so. It is maybe a too complicated matter for a first contribution, but I am wondering how this could basically be achieved?
From an architecture/pattern perspective, the virtual light would be some kind of proxy or decorator for regular light entities. Is such a thing even achievable by writing an integration?
Or would that mean to write an additional, completely separate implementation of a homeassistant.components.light.LightEntity?
Ideally, a user should be able to “decorate” a given light entity of their choice with the virtual decorator.
Any hints on how this could be added to the HA architecture, or general feedback on this idea would be appreciated!