Bump hatasmota to 0.7.0 (#98636)

* Bump hatasmota to 0.7.0

* Update tests according to new entity naming
This commit is contained in:
Erik Montnemery
2023-08-18 19:24:33 +02:00
committed by GitHub
parent 93683cef27
commit 90b9764578
11 changed files with 238 additions and 213 deletions

View File

@@ -53,7 +53,7 @@ async def test_attributes_on_off(
await hass.async_block_till_done()
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.attributes.get("effect_list") is None
assert state.attributes.get("min_mireds") is None
assert state.attributes.get("max_mireds") is None
@@ -82,7 +82,7 @@ async def test_attributes_dimmer_tuya(
await hass.async_block_till_done()
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.attributes.get("effect_list") is None
assert state.attributes.get("min_mireds") is None
assert state.attributes.get("max_mireds") is None
@@ -110,7 +110,7 @@ async def test_attributes_dimmer(
await hass.async_block_till_done()
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.attributes.get("effect_list") is None
assert state.attributes.get("min_mireds") is None
assert state.attributes.get("max_mireds") is None
@@ -138,7 +138,7 @@ async def test_attributes_ct(
await hass.async_block_till_done()
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.attributes.get("effect_list") is None
assert state.attributes.get("min_mireds") == 153
assert state.attributes.get("max_mireds") == 500
@@ -167,7 +167,7 @@ async def test_attributes_ct_reduced(
await hass.async_block_till_done()
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.attributes.get("effect_list") is None
assert state.attributes.get("min_mireds") == 200
assert state.attributes.get("max_mireds") == 380
@@ -195,7 +195,7 @@ async def test_attributes_rgb(
await hass.async_block_till_done()
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.attributes.get("effect_list") == [
"Solid",
"Wake up",
@@ -232,7 +232,7 @@ async def test_attributes_rgbw(
await hass.async_block_till_done()
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.attributes.get("effect_list") == [
"Solid",
"Wake up",
@@ -269,7 +269,7 @@ async def test_attributes_rgbww(
await hass.async_block_till_done()
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.attributes.get("effect_list") == [
"Solid",
"Wake up",
@@ -307,7 +307,7 @@ async def test_attributes_rgbww_reduced(
await hass.async_block_till_done()
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.attributes.get("effect_list") == [
"Solid",
"Wake up",
@@ -341,37 +341,37 @@ async def test_controlling_state_via_mqtt_on_off(
)
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == "unavailable"
assert not state.attributes.get(ATTR_ASSUMED_STATE)
assert "color_mode" not in state.attributes
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
assert not state.attributes.get(ATTR_ASSUMED_STATE)
assert "color_mode" not in state.attributes
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("color_mode") == "onoff"
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"OFF"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
assert "color_mode" not in state.attributes
async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/RESULT", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("color_mode") == "onoff"
async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/RESULT", '{"POWER":"OFF"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
assert "color_mode" not in state.attributes
@@ -392,32 +392,32 @@ async def test_controlling_state_via_mqtt_ct(
)
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == "unavailable"
assert not state.attributes.get(ATTR_ASSUMED_STATE)
assert "color_mode" not in state.attributes
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
assert not state.attributes.get(ATTR_ASSUMED_STATE)
assert "color_mode" not in state.attributes
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("color_mode") == "color_temp"
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"OFF"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
assert "color_mode" not in state.attributes
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","Dimmer":50}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("brightness") == 128
assert state.attributes.get("color_mode") == "color_temp"
@@ -425,7 +425,7 @@ async def test_controlling_state_via_mqtt_ct(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","CT":300}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("color_temp") == 300
assert state.attributes.get("color_mode") == "color_temp"
@@ -434,7 +434,7 @@ async def test_controlling_state_via_mqtt_ct(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","Color":"255,128"}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("color_temp") == 300
assert state.attributes.get("brightness") == 128
@@ -457,32 +457,32 @@ async def test_controlling_state_via_mqtt_rgbw(
)
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == "unavailable"
assert not state.attributes.get(ATTR_ASSUMED_STATE)
assert "color_mode" not in state.attributes
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
assert not state.attributes.get(ATTR_ASSUMED_STATE)
assert "color_mode" not in state.attributes
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("color_mode") == "hs"
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"OFF"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
assert "color_mode" not in state.attributes
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","Dimmer":50,"White":0}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("brightness") == 128
assert state.attributes.get("color_mode") == "hs"
@@ -490,7 +490,7 @@ async def test_controlling_state_via_mqtt_rgbw(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","Dimmer":75,"White":75}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("brightness") == 191
assert state.attributes.get("color_mode") == "white"
@@ -500,7 +500,7 @@ async def test_controlling_state_via_mqtt_rgbw(
"tasmota_49A3BC/tele/STATE",
'{"POWER":"ON","Dimmer":50,"HSBColor":"30,100,50","White":0}',
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("brightness") == 128
assert state.attributes.get("hs_color") == (30, 100)
@@ -509,7 +509,7 @@ async def test_controlling_state_via_mqtt_rgbw(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","White":50}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("brightness") == 128
assert state.attributes.get("rgb_color") is None
@@ -518,7 +518,7 @@ async def test_controlling_state_via_mqtt_rgbw(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","Dimmer":0}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("brightness") == 0
assert state.attributes.get("rgb_color") is None
@@ -527,18 +527,18 @@ async def test_controlling_state_via_mqtt_rgbw(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","Scheme":3}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("effect") == "Cycle down"
async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/RESULT", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/RESULT", '{"POWER":"OFF"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
@@ -558,32 +558,32 @@ async def test_controlling_state_via_mqtt_rgbww(
)
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == "unavailable"
assert not state.attributes.get(ATTR_ASSUMED_STATE)
assert "color_mode" not in state.attributes
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
assert not state.attributes.get(ATTR_ASSUMED_STATE)
assert "color_mode" not in state.attributes
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("color_mode") == "color_temp"
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"OFF"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
assert "color_mode" not in state.attributes
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","Dimmer":50}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("brightness") == 128
assert state.attributes.get("color_mode") == "color_temp"
@@ -593,7 +593,7 @@ async def test_controlling_state_via_mqtt_rgbww(
"tasmota_49A3BC/tele/STATE",
'{"POWER":"ON","Dimmer":50,"HSBColor":"30,100,50","White":0}',
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("hs_color") == (30, 100)
assert state.attributes.get("color_mode") == "hs"
@@ -601,7 +601,7 @@ async def test_controlling_state_via_mqtt_rgbww(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","White":50}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
# Setting white > 0 should clear the color
assert "rgb_color" not in state.attributes
@@ -610,7 +610,7 @@ async def test_controlling_state_via_mqtt_rgbww(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","CT":300}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("color_temp") == 300
assert state.attributes.get("color_mode") == "color_temp"
@@ -618,7 +618,7 @@ async def test_controlling_state_via_mqtt_rgbww(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","White":0}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
# Setting white to 0 should clear the color_temp
assert "color_temp" not in state.attributes
@@ -628,18 +628,18 @@ async def test_controlling_state_via_mqtt_rgbww(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","Scheme":3}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("effect") == "Cycle down"
async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/RESULT", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/RESULT", '{"POWER":"OFF"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
@@ -660,32 +660,32 @@ async def test_controlling_state_via_mqtt_rgbww_tuya(
)
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == "unavailable"
assert not state.attributes.get(ATTR_ASSUMED_STATE)
assert "color_mode" not in state.attributes
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
assert not state.attributes.get(ATTR_ASSUMED_STATE)
assert "color_mode" not in state.attributes
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("color_mode") == "color_temp"
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"OFF"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
assert "color_mode" not in state.attributes
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","Dimmer":50}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("brightness") == 128
assert state.attributes.get("color_mode") == "color_temp"
@@ -695,7 +695,7 @@ async def test_controlling_state_via_mqtt_rgbww_tuya(
"tasmota_49A3BC/tele/STATE",
'{"POWER":"ON","HSBColor":"30,100,0","White":0}',
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("hs_color") == (30, 100)
assert state.attributes.get("color_mode") == "hs"
@@ -705,7 +705,7 @@ async def test_controlling_state_via_mqtt_rgbww_tuya(
"tasmota_49A3BC/tele/STATE",
'{"POWER":"ON","Dimmer":0}',
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("hs_color") == (30, 100)
assert state.attributes.get("color_mode") == "hs"
@@ -713,7 +713,7 @@ async def test_controlling_state_via_mqtt_rgbww_tuya(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","Dimmer":50,"White":50}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
# Setting white > 0 should clear the color
assert "rgb_color" not in state.attributes
@@ -722,7 +722,7 @@ async def test_controlling_state_via_mqtt_rgbww_tuya(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","CT":300}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("color_temp") == 300
assert state.attributes.get("color_mode") == "color_temp"
@@ -730,7 +730,7 @@ async def test_controlling_state_via_mqtt_rgbww_tuya(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","White":0}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
# Setting white to 0 should clear the color_temp
assert not state.attributes.get("color_temp")
@@ -739,18 +739,18 @@ async def test_controlling_state_via_mqtt_rgbww_tuya(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","Scheme":3}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("effect") == "Cycle down"
async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/RESULT", '{"POWER":"ON"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/RESULT", '{"POWER":"OFF"}')
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
@@ -772,25 +772,25 @@ async def test_sending_mqtt_commands_on_off(
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
await hass.async_block_till_done()
await hass.async_block_till_done()
mqtt_mock.async_publish.reset_mock()
# Turn the light on and verify MQTT message is sent
await common.async_turn_on(hass, "light.test")
await common.async_turn_on(hass, "light.tasmota_test")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Power1", "ON", 0, False
)
mqtt_mock.async_publish.reset_mock()
# Tasmota is not optimistic, the state should still be off
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
# Turn the light off and verify MQTT message is sent
await common.async_turn_off(hass, "light.test")
await common.async_turn_off(hass, "light.tasmota_test")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Power1", "OFF", 0, False
)
@@ -816,32 +816,32 @@ async def test_sending_mqtt_commands_rgbww_tuya(
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
await hass.async_block_till_done()
await hass.async_block_till_done()
mqtt_mock.async_publish.reset_mock()
# Turn the light on and verify MQTT message is sent
await common.async_turn_on(hass, "light.test")
await common.async_turn_on(hass, "light.tasmota_test")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog", "NoDelay;Power1 ON", 0, False
)
mqtt_mock.async_publish.reset_mock()
# Tasmota is not optimistic, the state should still be off
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
# Turn the light off and verify MQTT message is sent
await common.async_turn_off(hass, "light.test")
await common.async_turn_off(hass, "light.tasmota_test")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog", "NoDelay;Power1 OFF", 0, False
)
mqtt_mock.async_publish.reset_mock()
# Turn the light on and verify MQTT messages are sent
await common.async_turn_on(hass, "light.test", brightness=192)
await common.async_turn_on(hass, "light.tasmota_test", brightness=192)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog", "NoDelay;Dimmer3 75", 0, False
)
@@ -866,39 +866,39 @@ async def test_sending_mqtt_commands_rgbw_legacy(
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
await hass.async_block_till_done()
await hass.async_block_till_done()
mqtt_mock.async_publish.reset_mock()
# Turn the light on and verify MQTT message is sent
await common.async_turn_on(hass, "light.test")
await common.async_turn_on(hass, "light.tasmota_test")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog", "NoDelay;Power1 ON", 0, False
)
mqtt_mock.async_publish.reset_mock()
# Tasmota is not optimistic, the state should still be off
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
# Turn the light off and verify MQTT message is sent
await common.async_turn_off(hass, "light.test")
await common.async_turn_off(hass, "light.tasmota_test")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog", "NoDelay;Power1 OFF", 0, False
)
mqtt_mock.async_publish.reset_mock()
# Turn the light on and verify MQTT messages are sent
await common.async_turn_on(hass, "light.test", brightness=192)
await common.async_turn_on(hass, "light.tasmota_test", brightness=192)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog", "NoDelay;Dimmer 75", 0, False
)
mqtt_mock.async_publish.reset_mock()
# Set color when setting color
await common.async_turn_on(hass, "light.test", hs_color=[0, 100])
await common.async_turn_on(hass, "light.tasmota_test", hs_color=[0, 100])
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Power1 ON;NoDelay;HsbColor1 0;NoDelay;HsbColor2 100",
@@ -908,7 +908,7 @@ async def test_sending_mqtt_commands_rgbw_legacy(
mqtt_mock.async_publish.reset_mock()
# Set white when setting white
await common.async_turn_on(hass, "light.test", white=128)
await common.async_turn_on(hass, "light.tasmota_test", white=128)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Power1 ON;NoDelay;White 50",
@@ -918,7 +918,7 @@ async def test_sending_mqtt_commands_rgbw_legacy(
mqtt_mock.async_publish.reset_mock()
# rgbw_color should be converted
await common.async_turn_on(hass, "light.test", rgbw_color=[128, 64, 32, 0])
await common.async_turn_on(hass, "light.tasmota_test", rgbw_color=[128, 64, 32, 0])
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Power1 ON;NoDelay;HsbColor1 20;NoDelay;HsbColor2 75",
@@ -928,7 +928,7 @@ async def test_sending_mqtt_commands_rgbw_legacy(
mqtt_mock.async_publish.reset_mock()
# rgbw_color should be converted
await common.async_turn_on(hass, "light.test", rgbw_color=[16, 64, 32, 128])
await common.async_turn_on(hass, "light.tasmota_test", rgbw_color=[16, 64, 32, 128])
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Power1 ON;NoDelay;HsbColor1 141;NoDelay;HsbColor2 25",
@@ -937,7 +937,7 @@ async def test_sending_mqtt_commands_rgbw_legacy(
)
mqtt_mock.async_publish.reset_mock()
await common.async_turn_on(hass, "light.test", effect="Random")
await common.async_turn_on(hass, "light.tasmota_test", effect="Random")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Power1 ON;NoDelay;Scheme 4",
@@ -965,39 +965,39 @@ async def test_sending_mqtt_commands_rgbw(
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
await hass.async_block_till_done()
await hass.async_block_till_done()
mqtt_mock.async_publish.reset_mock()
# Turn the light on and verify MQTT message is sent
await common.async_turn_on(hass, "light.test")
await common.async_turn_on(hass, "light.tasmota_test")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog", "NoDelay;Power1 ON", 0, False
)
mqtt_mock.async_publish.reset_mock()
# Tasmota is not optimistic, the state should still be off
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
# Turn the light off and verify MQTT message is sent
await common.async_turn_off(hass, "light.test")
await common.async_turn_off(hass, "light.tasmota_test")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog", "NoDelay;Power1 OFF", 0, False
)
mqtt_mock.async_publish.reset_mock()
# Turn the light on and verify MQTT messages are sent
await common.async_turn_on(hass, "light.test", brightness=192)
await common.async_turn_on(hass, "light.tasmota_test", brightness=192)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog", "NoDelay;Dimmer 75", 0, False
)
mqtt_mock.async_publish.reset_mock()
# Set color when setting color
await common.async_turn_on(hass, "light.test", hs_color=[180, 50])
await common.async_turn_on(hass, "light.tasmota_test", hs_color=[180, 50])
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Power1 ON;NoDelay;HsbColor1 180;NoDelay;HsbColor2 50",
@@ -1007,7 +1007,7 @@ async def test_sending_mqtt_commands_rgbw(
mqtt_mock.async_publish.reset_mock()
# Set white when setting white
await common.async_turn_on(hass, "light.test", white=128)
await common.async_turn_on(hass, "light.tasmota_test", white=128)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Power1 ON;NoDelay;White 50",
@@ -1017,7 +1017,7 @@ async def test_sending_mqtt_commands_rgbw(
mqtt_mock.async_publish.reset_mock()
# rgbw_color should be converted
await common.async_turn_on(hass, "light.test", rgbw_color=[128, 64, 32, 0])
await common.async_turn_on(hass, "light.tasmota_test", rgbw_color=[128, 64, 32, 0])
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Power1 ON;NoDelay;HsbColor1 20;NoDelay;HsbColor2 75",
@@ -1027,7 +1027,7 @@ async def test_sending_mqtt_commands_rgbw(
mqtt_mock.async_publish.reset_mock()
# rgbw_color should be converted
await common.async_turn_on(hass, "light.test", rgbw_color=[16, 64, 32, 128])
await common.async_turn_on(hass, "light.tasmota_test", rgbw_color=[16, 64, 32, 128])
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Power1 ON;NoDelay;HsbColor1 141;NoDelay;HsbColor2 25",
@@ -1036,7 +1036,7 @@ async def test_sending_mqtt_commands_rgbw(
)
mqtt_mock.async_publish.reset_mock()
await common.async_turn_on(hass, "light.test", effect="Random")
await common.async_turn_on(hass, "light.tasmota_test", effect="Random")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Power1 ON;NoDelay;Scheme 4",
@@ -1064,38 +1064,38 @@ async def test_sending_mqtt_commands_rgbww(
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
await hass.async_block_till_done()
await hass.async_block_till_done()
mqtt_mock.async_publish.reset_mock()
# Turn the light on and verify MQTT message is sent
await common.async_turn_on(hass, "light.test")
await common.async_turn_on(hass, "light.tasmota_test")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog", "NoDelay;Power1 ON", 0, False
)
mqtt_mock.async_publish.reset_mock()
# Tasmota is not optimistic, the state should still be off
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
# Turn the light off and verify MQTT message is sent
await common.async_turn_off(hass, "light.test")
await common.async_turn_off(hass, "light.tasmota_test")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog", "NoDelay;Power1 OFF", 0, False
)
mqtt_mock.async_publish.reset_mock()
# Turn the light on and verify MQTT messages are sent
await common.async_turn_on(hass, "light.test", brightness=192)
await common.async_turn_on(hass, "light.tasmota_test", brightness=192)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog", "NoDelay;Dimmer 75", 0, False
)
mqtt_mock.async_publish.reset_mock()
await common.async_turn_on(hass, "light.test", hs_color=[240, 75])
await common.async_turn_on(hass, "light.tasmota_test", hs_color=[240, 75])
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Power1 ON;NoDelay;HsbColor1 240;NoDelay;HsbColor2 75",
@@ -1104,7 +1104,7 @@ async def test_sending_mqtt_commands_rgbww(
)
mqtt_mock.async_publish.reset_mock()
await common.async_turn_on(hass, "light.test", color_temp=200)
await common.async_turn_on(hass, "light.tasmota_test", color_temp=200)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Power1 ON;NoDelay;CT 200",
@@ -1113,7 +1113,7 @@ async def test_sending_mqtt_commands_rgbww(
)
mqtt_mock.async_publish.reset_mock()
await common.async_turn_on(hass, "light.test", effect="Random")
await common.async_turn_on(hass, "light.tasmota_test", effect="Random")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Power1 ON;NoDelay;Scheme 4",
@@ -1142,32 +1142,32 @@ async def test_sending_mqtt_commands_power_unlinked(
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
await hass.async_block_till_done()
await hass.async_block_till_done()
mqtt_mock.async_publish.reset_mock()
# Turn the light on and verify MQTT message is sent
await common.async_turn_on(hass, "light.test")
await common.async_turn_on(hass, "light.tasmota_test")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog", "NoDelay;Power1 ON", 0, False
)
mqtt_mock.async_publish.reset_mock()
# Tasmota is not optimistic, the state should still be off
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
# Turn the light off and verify MQTT message is sent
await common.async_turn_off(hass, "light.test")
await common.async_turn_off(hass, "light.tasmota_test")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog", "NoDelay;Power1 OFF", 0, False
)
mqtt_mock.async_publish.reset_mock()
# Turn the light on and verify MQTT messages are sent; POWER should be sent
await common.async_turn_on(hass, "light.test", brightness=192)
await common.async_turn_on(hass, "light.tasmota_test", brightness=192)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Dimmer 75;NoDelay;Power1 ON",
@@ -1195,14 +1195,14 @@ async def test_transition(
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
await hass.async_block_till_done()
await hass.async_block_till_done()
mqtt_mock.async_publish.reset_mock()
# Dim the light from 0->100: Speed should be 4*2=8
await common.async_turn_on(hass, "light.test", brightness=255, transition=4)
await common.async_turn_on(hass, "light.tasmota_test", brightness=255, transition=4)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Fade2 1;NoDelay;Speed2 8;NoDelay;Dimmer 100",
@@ -1212,7 +1212,9 @@ async def test_transition(
mqtt_mock.async_publish.reset_mock()
# Dim the light from 0->100: Speed should be capped at 40
await common.async_turn_on(hass, "light.test", brightness=255, transition=100)
await common.async_turn_on(
hass, "light.tasmota_test", brightness=255, transition=100
)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Fade2 1;NoDelay;Speed2 40;NoDelay;Dimmer 100",
@@ -1222,7 +1224,7 @@ async def test_transition(
mqtt_mock.async_publish.reset_mock()
# Dim the light from 0->0: Speed should be 1
await common.async_turn_on(hass, "light.test", brightness=0, transition=100)
await common.async_turn_on(hass, "light.tasmota_test", brightness=0, transition=100)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Fade2 1;NoDelay;Speed2 1;NoDelay;Power1 OFF",
@@ -1232,7 +1234,7 @@ async def test_transition(
mqtt_mock.async_publish.reset_mock()
# Dim the light from 0->50: Speed should be 4*2*2=16
await common.async_turn_on(hass, "light.test", brightness=128, transition=4)
await common.async_turn_on(hass, "light.tasmota_test", brightness=128, transition=4)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Fade2 1;NoDelay;Speed2 16;NoDelay;Dimmer 50",
@@ -1245,12 +1247,12 @@ async def test_transition(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","Dimmer":50}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("brightness") == 128
# Dim the light from 50->0: Speed should be 6*2*2=24
await common.async_turn_off(hass, "light.test", transition=6)
await common.async_turn_off(hass, "light.tasmota_test", transition=6)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Fade2 1;NoDelay;Speed2 24;NoDelay;Power1 OFF",
@@ -1263,12 +1265,12 @@ async def test_transition(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","Dimmer":100}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("brightness") == 255
# Dim the light from 100->0: Speed should be 0
await common.async_turn_off(hass, "light.test", transition=0)
await common.async_turn_off(hass, "light.tasmota_test", transition=0)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Fade2 0;NoDelay;Power1 OFF",
@@ -1286,13 +1288,15 @@ async def test_transition(
' "Color":"0,255,0","HSBColor":"120,100,50","White":0}'
),
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("brightness") == 128
assert state.attributes.get("rgb_color") == (0, 255, 0)
# Set color of the light from 0,255,0 to 255,0,0 @ 50%: Speed should be 6*2*2=24
await common.async_turn_on(hass, "light.test", rgb_color=[255, 0, 0], transition=6)
await common.async_turn_on(
hass, "light.tasmota_test", rgb_color=[255, 0, 0], transition=6
)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
(
@@ -1310,13 +1314,15 @@ async def test_transition(
"tasmota_49A3BC/tele/STATE",
'{"POWER":"ON","Dimmer":100, "Color":"0,255,0","HSBColor":"120,100,50"}',
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("brightness") == 255
assert state.attributes.get("rgb_color") == (0, 255, 0)
# Set color of the light from 0,255,0 to 255,0,0 @ 100%: Speed should be 6*2=12
await common.async_turn_on(hass, "light.test", rgb_color=[255, 0, 0], transition=6)
await common.async_turn_on(
hass, "light.tasmota_test", rgb_color=[255, 0, 0], transition=6
)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
(
@@ -1334,13 +1340,13 @@ async def test_transition(
"tasmota_49A3BC/tele/STATE",
'{"POWER":"ON","Dimmer":50, "CT":153, "White":50}',
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("brightness") == 128
assert state.attributes.get("color_temp") == 153
# Set color_temp of the light from 153 to 500 @ 50%: Speed should be 6*2*2=24
await common.async_turn_on(hass, "light.test", color_temp=500, transition=6)
await common.async_turn_on(hass, "light.tasmota_test", color_temp=500, transition=6)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Fade2 1;NoDelay;Speed2 24;NoDelay;Power1 ON;NoDelay;CT 500",
@@ -1353,13 +1359,13 @@ async def test_transition(
async_fire_mqtt_message(
hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON","Dimmer":50, "CT":500}'
)
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_ON
assert state.attributes.get("brightness") == 128
assert state.attributes.get("color_temp") == 500
# Set color_temp of the light from 500 to 326 @ 50%: Speed should be 6*2*2*2=48->40
await common.async_turn_on(hass, "light.test", color_temp=326, transition=6)
await common.async_turn_on(hass, "light.tasmota_test", color_temp=326, transition=6)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Fade2 1;NoDelay;Speed2 40;NoDelay;Power1 ON;NoDelay;CT 326",
@@ -1388,14 +1394,14 @@ async def test_transition_fixed(
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.state == STATE_OFF
await hass.async_block_till_done()
await hass.async_block_till_done()
mqtt_mock.async_publish.reset_mock()
# Dim the light from 0->100: Speed should be 4*2=8
await common.async_turn_on(hass, "light.test", brightness=255, transition=4)
await common.async_turn_on(hass, "light.tasmota_test", brightness=255, transition=4)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Fade2 1;NoDelay;Speed2 8;NoDelay;Dimmer 100",
@@ -1405,7 +1411,9 @@ async def test_transition_fixed(
mqtt_mock.async_publish.reset_mock()
# Dim the light from 0->100: Speed should be capped at 40
await common.async_turn_on(hass, "light.test", brightness=255, transition=100)
await common.async_turn_on(
hass, "light.tasmota_test", brightness=255, transition=100
)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Fade2 1;NoDelay;Speed2 40;NoDelay;Dimmer 100",
@@ -1415,7 +1423,7 @@ async def test_transition_fixed(
mqtt_mock.async_publish.reset_mock()
# Dim the light from 0->0: Speed should be 4*2=8
await common.async_turn_on(hass, "light.test", brightness=0, transition=4)
await common.async_turn_on(hass, "light.tasmota_test", brightness=0, transition=4)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Fade2 1;NoDelay;Speed2 8;NoDelay;Power1 OFF",
@@ -1425,7 +1433,7 @@ async def test_transition_fixed(
mqtt_mock.async_publish.reset_mock()
# Dim the light from 0->50: Speed should be 4*2=8
await common.async_turn_on(hass, "light.test", brightness=128, transition=4)
await common.async_turn_on(hass, "light.tasmota_test", brightness=128, transition=4)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Fade2 1;NoDelay;Speed2 8;NoDelay;Dimmer 50",
@@ -1435,7 +1443,7 @@ async def test_transition_fixed(
mqtt_mock.async_publish.reset_mock()
# Dim the light from 0->50: Speed should be 0
await common.async_turn_on(hass, "light.test", brightness=128, transition=0)
await common.async_turn_on(hass, "light.tasmota_test", brightness=128, transition=0)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Fade2 0;NoDelay;Dimmer 50",
@@ -1463,7 +1471,7 @@ async def test_relay_as_light(
state = hass.states.get("switch.test")
assert state is None
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state is not None
@@ -1631,14 +1639,14 @@ async def test_discovery_update_reconfigure_light(
# Simple dimmer
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{config[CONF_MAC]}/config", data1)
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert state.attributes.get("supported_features") == LightEntityFeature.TRANSITION
assert state.attributes.get("supported_color_modes") == ["brightness"]
# Reconfigure as RGB light
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{config[CONF_MAC]}/config", data2)
await hass.async_block_till_done()
state = hass.states.get("light.test")
state = hass.states.get("light.tasmota_test")
assert (
state.attributes.get("supported_features")
== LightEntityFeature.EFFECT | LightEntityFeature.TRANSITION