Looks like moonlight mode is now supported in the library v0.4.0 as a “Power Mode” (5). So a boolean toggle for moonlight mode has be added to the light and multiple functions in the HASS side will need to be changed (bear with me, I’m new to this):
Update: Check if power mode is 5 and set boolean.
Turn_On: Add set_mode to set power mode.
The “transition presets” (HASS effects) in the library seem to be old and for RGB bulbs only. Since I don’t have an RGB yeelight, I can’t test those.
The new ones for the ceiling light, I can test once they are added to the library.
The only problem is when moonlight is activated, light.toggle on the wireless wall switch doesn’t work as intended anymore. I have to use HA or remote to take it back to normal.
Any workarounds or ideas?
Well you have to change light.yeelight_set_mode back to normal, that’s the only way (call that service through separate automation for example), but then you get scorching white light, so it’s pretty useless for my scenario. It would be great it the mode could be turned to normal without turning the light on.
My scenario:
on motion sensor turn moonlight mode on after midnight
on motion sensor off turn moonlight mode off
if someone presses the switch/button manually turn on normal mode (not last mode used which was moonlight).
I think you cannot do this with light.toggle. I use light.turn_on with kelvin and brightness_pct and the mode switches automatically back to sun mode, with colour and brighness as specified.
I use one click to turn the light on and double click to turn it off (some xiaomi button).
You could also do some automation to switch back to sun mode and specify kelvin and brightness.
Yes, that’s what I thought. My problem is that it’s double wall switch (Aqara one) and I only have one button I can use for the ceiling lamp. So I have to use toggle
If I make automation that changes back to normal (which is sun) it also turns the lamp on. That behavior just doesn’t work in my case.
For RGB: I can test if you want. What needs to be changed in the library? The support for the background light is missing, right?
For UI element to switch between moon/normal mode (@mouth4war):
To check if the ceiling light is in moonlight, use bulb.get_properties(["nl_br"]). It will return 0 if not in moonlightor [1…100] if in moonlight
ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 316, in _async_add_entity
await entity.async_update_ha_state()
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 222, in async_update_ha_state
attr = self.state_attributes or {}
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/light/init.py”, line 501, in state_attributes
data[ATTR_MIN_MIREDS] = self.min_mireds
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/light/yeelight.py”, line 258, in min_mireds
return kelvin_to_mired(YEELIGHT_SPECS[‘rgb’][‘max_kelvin’])
KeyError: ‘rgb’