mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Force color or white mode exclusivity for Tasmota lights (#42772)
This commit is contained in:
parent
9e0043fb17
commit
56ee99372d
@ -128,6 +128,11 @@ class TasmotaLight(
|
|||||||
white_value = float(attributes["white_value"])
|
white_value = float(attributes["white_value"])
|
||||||
percent_white = white_value / TASMOTA_BRIGHTNESS_MAX
|
percent_white = white_value / TASMOTA_BRIGHTNESS_MAX
|
||||||
self._white_value = percent_white * 255
|
self._white_value = percent_white * 255
|
||||||
|
if self._white_value == 0:
|
||||||
|
self._color_temp = None
|
||||||
|
self._white_value = None
|
||||||
|
if self._white_value is not None and self._white_value > 0:
|
||||||
|
self._hs = None
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -432,6 +432,8 @@ async def test_controlling_state_via_mqtt_rgbww(hass, mqtt_mock, setup_tasmota):
|
|||||||
state = hass.states.get("light.test")
|
state = hass.states.get("light.test")
|
||||||
assert state.state == STATE_ON
|
assert state.state == STATE_ON
|
||||||
assert state.attributes.get("white_value") == 127.5
|
assert state.attributes.get("white_value") == 127.5
|
||||||
|
# Setting white > 0 should clear the color
|
||||||
|
assert not state.attributes.get("rgb_color")
|
||||||
|
|
||||||
async_fire_mqtt_message(
|
async_fire_mqtt_message(
|
||||||
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","CT":300}'
|
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","CT":300}'
|
||||||
@ -440,6 +442,15 @@ async def test_controlling_state_via_mqtt_rgbww(hass, mqtt_mock, setup_tasmota):
|
|||||||
assert state.state == STATE_ON
|
assert state.state == STATE_ON
|
||||||
assert state.attributes.get("color_temp") == 300
|
assert state.attributes.get("color_temp") == 300
|
||||||
|
|
||||||
|
async_fire_mqtt_message(
|
||||||
|
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","White":0}'
|
||||||
|
)
|
||||||
|
state = hass.states.get("light.test")
|
||||||
|
assert state.state == STATE_ON
|
||||||
|
# Setting white to 0 should clear the white_value and color_temp
|
||||||
|
assert not state.attributes.get("white_value")
|
||||||
|
assert not state.attributes.get("color_temp")
|
||||||
|
|
||||||
async_fire_mqtt_message(
|
async_fire_mqtt_message(
|
||||||
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","Scheme":3}'
|
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","Scheme":3}'
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user