[RFC] Set color/brightness for turned off lights#7477
Conversation
| ATTR_WHITE_VALUE: vol.All(vol.Coerce(int), vol.Range(min=0, max=255)), | ||
| ATTR_FLASH: vol.In([FLASH_SHORT, FLASH_LONG]), | ||
| ATTR_EFFECT: cv.string, | ||
| vol.Optional(ATTR_POWER_ON, default=True): cv.boolean, |
There was a problem hiding this comment.
this just doesn't make much sense… turn on with power off? 😛 I wonder if we should extend the turn_off schema instead?
There was a problem hiding this comment.
btw, this idea came up before and I have shot it down because of proposed implementations (things like a set_state command etc).
As far as I know LIFX is the only light that allows changing settings while it's off. So I suggest you add it as a LIFX only service. If we ever have more lights than we can maybe generalize it.
There was a problem hiding this comment.
Yeah, I think I touched on both points in the "Alternatives" section. The idea comes up repeatedly because it's really useful and we miss it when converting from IFTTT 😄
I'm cool with starting out with a LIFX only service (though that will not fix the Flux+motion sensor race). So that will indeed be something like lifx_set_state – or maybe lifx_set_color. I will look into that.
If I am creating a new service call, will it be acceptable to use the units that are well-known from the LIFX smartphone app? This is Kelvin for temperature and percentage for brightness.
There was a problem hiding this comment.
It's a lifx only service so I don't really care. But I feel like it would make sense to keep them in sync with the rest of Hass. So rather not use the app units.
There was a problem hiding this comment.
Oh, and I must admit that I did not read the whole PR intro…
Description:
Background
The LIFX light API has a very handy feature: setting the color/brightness without actually turning the light on. Philips Hue apparently does not support this functionality natively though it is frequently requested, like here: https://developers.meethue.com/content/changing-color-while-onfalse
This PR is a proposal to add that feature to Home Assistant.
Setting the color of a light that is turned off might sound odd at first and I have seen it rejected as absurd elsewhere. However, this functionality is very useful for decoupling color and power changes. If the above link is not convincing, I can give several other examples.
The easiest way to see that it is not absurd is probably to compare to media players where the volume can be set even with nothing playing.
Implementation
A new
power_onattribute is added to thelight.turn_oncall. Setting this toFalsewill send just the color change, not the power on command. Thus, the light stays at its current power state.As this is not supported by all lights, a
SUPPORT_OFF_STATEflag is also added. This is used by the Flux switch to fix long-standing issues like #4005 (but only for supporting lights).Using
power_on: FalsewithoutSUPPORT_OFF_STATEcan be handled in a couple of ways. I think the best alternative is probably to leave it undefined, for the platform to handle.Alternatives
I think
light.turn_onis already too busy and this change makes it even worse. Also, toturn_ona light without powering it on sounds a bit weird.It would IMHO be better to split the current functionality into
light.turn_on,light.set_color,light.effect_startetc. The proposal would then be to add optional power control toset_color. I would be happy to work on such a split but it would be quite disruptive so I did not go down that path yet.Because I actually don’t think this proposal is the best solution in an absolute sense I have marked the PR with [RFC]. If you feel like shooting down the implementation, please indicate whether you at least agree that the fundamental feature itself is useful.
Further work
Personally, I think that this feature is so useful that partial
SUPPORT_OFF_STATEcould be considered forhueand other platforms as well. This would involve a platform cache that adds the last set color to theturn_oncall that eventually turns a light on.It would only be a partial solution because the cache would not be applied if an external switch toggles a light without going through HA. It could, however, fix #4005 for Hue as well.
Related issue (if applicable): fixes #
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>
Example entry for
configuration.yaml(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
toxrun successfully. Your PR cannot be merged unless tests passREQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.If the code does not interact with devices:
toxrun successfully. Your PR cannot be merged unless tests pass