diff --git a/homeassistant/components/tasmota/manifest.json b/homeassistant/components/tasmota/manifest.json index f235256f772..220bc4e31fb 100644 --- a/homeassistant/components/tasmota/manifest.json +++ b/homeassistant/components/tasmota/manifest.json @@ -8,5 +8,5 @@ "iot_class": "local_push", "loggers": ["hatasmota"], "mqtt": ["tasmota/discovery/#"], - "requirements": ["HATasmota==0.6.5"] + "requirements": ["HATasmota==0.7.0"] } diff --git a/homeassistant/components/tasmota/mixins.py b/homeassistant/components/tasmota/mixins.py index 859b11ebd4c..e99106d09e8 100644 --- a/homeassistant/components/tasmota/mixins.py +++ b/homeassistant/components/tasmota/mixins.py @@ -32,6 +32,8 @@ _LOGGER = logging.getLogger(__name__) class TasmotaEntity(Entity): """Base class for Tasmota entities.""" + _attr_has_entity_name = True + def __init__(self, tasmota_entity: HATasmotaEntity) -> None: """Initialize.""" self._tasmota_entity = tasmota_entity diff --git a/requirements_all.txt b/requirements_all.txt index 02e462f94e4..1afbd67743c 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -29,7 +29,7 @@ DoorBirdPy==2.1.0 HAP-python==4.7.1 # homeassistant.components.tasmota -HATasmota==0.6.5 +HATasmota==0.7.0 # homeassistant.components.mastodon Mastodon.py==1.5.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 8bb737295fb..3d0f59d7bca 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -28,7 +28,7 @@ DoorBirdPy==2.1.0 HAP-python==4.7.1 # homeassistant.components.tasmota -HATasmota==0.6.5 +HATasmota==0.7.0 # homeassistant.components.doods # homeassistant.components.generic diff --git a/tests/components/tasmota/test_binary_sensor.py b/tests/components/tasmota/test_binary_sensor.py index 6a82a0f0e73..2bfb4a9d5e2 100644 --- a/tests/components/tasmota/test_binary_sensor.py +++ b/tests/components/tasmota/test_binary_sensor.py @@ -125,13 +125,13 @@ async def test_controlling_state_via_mqtt_switchname( ) await hass.async_block_till_done() - state = hass.states.get("binary_sensor.custom_name") + state = hass.states.get("binary_sensor.tasmota_custom_name") assert state.state == "unavailable" assert not state.attributes.get(ATTR_ASSUMED_STATE) async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online") await hass.async_block_till_done() - state = hass.states.get("binary_sensor.custom_name") + state = hass.states.get("binary_sensor.tasmota_custom_name") assert state.state == STATE_UNKNOWN assert not state.attributes.get(ATTR_ASSUMED_STATE) @@ -139,35 +139,35 @@ async def test_controlling_state_via_mqtt_switchname( async_fire_mqtt_message( hass, "tasmota_49A3BC/stat/RESULT", '{"Custom Name":{"Action":"ON"}}' ) - state = hass.states.get("binary_sensor.custom_name") + state = hass.states.get("binary_sensor.tasmota_custom_name") assert state.state == STATE_ON async_fire_mqtt_message( hass, "tasmota_49A3BC/stat/RESULT", '{"Custom Name":{"Action":"OFF"}}' ) - state = hass.states.get("binary_sensor.custom_name") + state = hass.states.get("binary_sensor.tasmota_custom_name") assert state.state == STATE_OFF # Test periodic state update async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/SENSOR", '{"Custom Name":"ON"}') - state = hass.states.get("binary_sensor.custom_name") + state = hass.states.get("binary_sensor.tasmota_custom_name") assert state.state == STATE_ON async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/SENSOR", '{"Custom Name":"OFF"}') - state = hass.states.get("binary_sensor.custom_name") + state = hass.states.get("binary_sensor.tasmota_custom_name") assert state.state == STATE_OFF # Test polled state update async_fire_mqtt_message( hass, "tasmota_49A3BC/stat/STATUS10", '{"StatusSNS":{"Custom Name":"ON"}}' ) - state = hass.states.get("binary_sensor.custom_name") + state = hass.states.get("binary_sensor.tasmota_custom_name") assert state.state == STATE_ON async_fire_mqtt_message( hass, "tasmota_49A3BC/stat/STATUS10", '{"StatusSNS":{"Custom Name":"OFF"}}' ) - state = hass.states.get("binary_sensor.custom_name") + state = hass.states.get("binary_sensor.tasmota_custom_name") assert state.state == STATE_OFF @@ -243,9 +243,9 @@ async def test_friendly_names( assert state.state == "unavailable" assert state.attributes.get("friendly_name") == "Tasmota binary_sensor 1" - state = hass.states.get("binary_sensor.beer") + state = hass.states.get("binary_sensor.tasmota_beer") assert state.state == "unavailable" - assert state.attributes.get("friendly_name") == "Beer" + assert state.attributes.get("friendly_name") == "Tasmota Beer" async def test_off_delay( diff --git a/tests/components/tasmota/test_common.py b/tests/components/tasmota/test_common.py index 703dd2a1893..a184f650fae 100644 --- a/tests/components/tasmota/test_common.py +++ b/tests/components/tasmota/test_common.py @@ -129,7 +129,7 @@ async def help_test_availability_when_connection_lost( domain, config, sensor_config=None, - entity_id="test", + object_id="tasmota_test", ): """Test availability after MQTT disconnection. @@ -156,7 +156,7 @@ async def help_test_availability_when_connection_lost( config_get_state_online(config), ) await hass.async_block_till_done() - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state.state != STATE_UNAVAILABLE # Disconnected from MQTT server -> state changed to unavailable @@ -165,7 +165,7 @@ async def help_test_availability_when_connection_lost( await hass.async_block_till_done() await hass.async_block_till_done() await hass.async_block_till_done() - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state.state == STATE_UNAVAILABLE # Reconnected to MQTT server -> state still unavailable @@ -174,7 +174,7 @@ async def help_test_availability_when_connection_lost( await hass.async_block_till_done() await hass.async_block_till_done() await hass.async_block_till_done() - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state.state == STATE_UNAVAILABLE # Receive LWT again @@ -184,7 +184,7 @@ async def help_test_availability_when_connection_lost( config_get_state_online(config), ) await hass.async_block_till_done() - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state.state != STATE_UNAVAILABLE @@ -194,7 +194,7 @@ async def help_test_availability( domain, config, sensor_config=None, - entity_id="test", + object_id="tasmota_test", ): """Test availability. @@ -214,7 +214,7 @@ async def help_test_availability( ) await hass.async_block_till_done() - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state.state == STATE_UNAVAILABLE async_fire_mqtt_message( @@ -223,7 +223,7 @@ async def help_test_availability( config_get_state_online(config), ) await hass.async_block_till_done() - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state.state != STATE_UNAVAILABLE async_fire_mqtt_message( @@ -232,7 +232,7 @@ async def help_test_availability( config_get_state_offline(config), ) await hass.async_block_till_done() - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state.state == STATE_UNAVAILABLE @@ -242,7 +242,7 @@ async def help_test_availability_discovery_update( domain, config, sensor_config=None, - entity_id="test", + object_id="tasmota_test", ): """Test update of discovered TasmotaAvailability. @@ -280,17 +280,17 @@ async def help_test_availability_discovery_update( ) await hass.async_block_till_done() - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state.state == STATE_UNAVAILABLE async_fire_mqtt_message(hass, availability_topic1, online1) await hass.async_block_till_done() - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state.state != STATE_UNAVAILABLE async_fire_mqtt_message(hass, availability_topic1, offline1) await hass.async_block_till_done() - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state.state == STATE_UNAVAILABLE # Change availability settings @@ -302,13 +302,13 @@ async def help_test_availability_discovery_update( async_fire_mqtt_message(hass, availability_topic1, online2) async_fire_mqtt_message(hass, availability_topic2, online1) await hass.async_block_till_done() - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state.state == STATE_UNAVAILABLE # Verify we are subscribing to the new topic async_fire_mqtt_message(hass, availability_topic2, online2) await hass.async_block_till_done() - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state.state != STATE_UNAVAILABLE @@ -390,8 +390,8 @@ async def help_test_discovery_removal( config2, sensor_config1=None, sensor_config2=None, - entity_id="test", - name="Test", + object_id="tasmota_test", + name="Tasmota Test", ): """Test removal of discovered entity.""" device_reg = dr.async_get(hass) @@ -416,11 +416,11 @@ async def help_test_discovery_removal( connections={(dr.CONNECTION_NETWORK_MAC, config1[CONF_MAC])} ) assert device_entry is not None - entity_entry = entity_reg.async_get(f"{domain}.{entity_id}") + entity_entry = entity_reg.async_get(f"{domain}.{object_id}") assert entity_entry is not None # Verify state is added - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state is not None assert state.name == name @@ -439,11 +439,11 @@ async def help_test_discovery_removal( connections={(dr.CONNECTION_NETWORK_MAC, config2[CONF_MAC])} ) assert device_entry is not None - entity_entry = entity_reg.async_get(f"{domain}.{entity_id}") + entity_entry = entity_reg.async_get(f"{domain}.{object_id}") assert entity_entry is None # Verify state is removed - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state is None @@ -455,8 +455,8 @@ async def help_test_discovery_update_unchanged( config, discovery_update, sensor_config=None, - entity_id="test", - name="Test", + object_id="tasmota_test", + name="Tasmota Test", ): """Test update of discovered component with and without changes. @@ -479,7 +479,7 @@ async def help_test_discovery_update_unchanged( ) await hass.async_block_till_done() - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state is not None assert state.name == name @@ -538,7 +538,13 @@ async def help_test_discovery_device_remove( async def help_test_entity_id_update_subscriptions( - hass, mqtt_mock, domain, config, topics=None, sensor_config=None, entity_id="test" + hass, + mqtt_mock, + domain, + config, + topics=None, + sensor_config=None, + object_id="tasmota_test", ): """Test MQTT subscriptions are managed when entity_id is updated.""" entity_reg = er.async_get(hass) @@ -562,7 +568,7 @@ async def help_test_entity_id_update_subscriptions( topics = [get_topic_tele_state(config), get_topic_tele_will(config)] assert len(topics) > 0 - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state is not None assert mqtt_mock.async_subscribe.call_count == len(topics) for topic in topics: @@ -570,11 +576,11 @@ async def help_test_entity_id_update_subscriptions( mqtt_mock.async_subscribe.reset_mock() entity_reg.async_update_entity( - f"{domain}.{entity_id}", new_entity_id=f"{domain}.milk" + f"{domain}.{object_id}", new_entity_id=f"{domain}.milk" ) await hass.async_block_till_done() - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state is None state = hass.states.get(f"{domain}.milk") @@ -584,7 +590,7 @@ async def help_test_entity_id_update_subscriptions( async def help_test_entity_id_update_discovery_update( - hass, mqtt_mock, domain, config, sensor_config=None, entity_id="test" + hass, mqtt_mock, domain, config, sensor_config=None, object_id="tasmota_test" ): """Test MQTT discovery update after entity_id is updated.""" entity_reg = er.async_get(hass) @@ -606,16 +612,16 @@ async def help_test_entity_id_update_discovery_update( async_fire_mqtt_message(hass, topic, config_get_state_online(config)) await hass.async_block_till_done() - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state.state != STATE_UNAVAILABLE async_fire_mqtt_message(hass, topic, config_get_state_offline(config)) await hass.async_block_till_done() - state = hass.states.get(f"{domain}.{entity_id}") + state = hass.states.get(f"{domain}.{object_id}") assert state.state == STATE_UNAVAILABLE entity_reg.async_update_entity( - f"{domain}.{entity_id}", new_entity_id=f"{domain}.milk" + f"{domain}.{object_id}", new_entity_id=f"{domain}.milk" ) await hass.async_block_till_done() assert hass.states.get(f"{domain}.milk") diff --git a/tests/components/tasmota/test_cover.py b/tests/components/tasmota/test_cover.py index 156ea365b48..5c1364f1f77 100644 --- a/tests/components/tasmota/test_cover.py +++ b/tests/components/tasmota/test_cover.py @@ -658,7 +658,7 @@ async def test_availability_when_connection_lost( mqtt_mock, Platform.COVER, config, - entity_id="test_cover_1", + object_id="test_cover_1", ) @@ -671,7 +671,7 @@ async def test_availability( config["rl"][0] = 3 config["rl"][1] = 3 await help_test_availability( - hass, mqtt_mock, Platform.COVER, config, entity_id="test_cover_1" + hass, mqtt_mock, Platform.COVER, config, object_id="test_cover_1" ) @@ -684,7 +684,7 @@ async def test_availability_discovery_update( config["rl"][0] = 3 config["rl"][1] = 3 await help_test_availability_discovery_update( - hass, mqtt_mock, Platform.COVER, config, entity_id="test_cover_1" + hass, mqtt_mock, Platform.COVER, config, object_id="test_cover_1" ) @@ -727,7 +727,7 @@ async def test_discovery_removal_cover( Platform.COVER, config1, config2, - entity_id="test_cover_1", + object_id="test_cover_1", name="Test cover 1", ) @@ -753,7 +753,7 @@ async def test_discovery_update_unchanged_cover( Platform.COVER, config, discovery_update, - entity_id="test_cover_1", + object_id="test_cover_1", name="Test cover 1", ) @@ -787,7 +787,7 @@ async def test_entity_id_update_subscriptions( get_topic_tele_will(config), ] await help_test_entity_id_update_subscriptions( - hass, mqtt_mock, Platform.COVER, config, topics, entity_id="test_cover_1" + hass, mqtt_mock, Platform.COVER, config, topics, object_id="test_cover_1" ) @@ -800,5 +800,5 @@ async def test_entity_id_update_discovery_update( config["rl"][0] = 3 config["rl"][1] = 3 await help_test_entity_id_update_discovery_update( - hass, mqtt_mock, Platform.COVER, config, entity_id="test_cover_1" + hass, mqtt_mock, Platform.COVER, config, object_id="test_cover_1" ) diff --git a/tests/components/tasmota/test_discovery.py b/tests/components/tasmota/test_discovery.py index 9a3f4f91ec7..4fd9f293498 100644 --- a/tests/components/tasmota/test_discovery.py +++ b/tests/components/tasmota/test_discovery.py @@ -143,12 +143,12 @@ async def test_correct_config_discovery( connections={(dr.CONNECTION_NETWORK_MAC, mac)} ) assert device_entry is not None - entity_entry = entity_reg.async_get("switch.test") + entity_entry = entity_reg.async_get("switch.tasmota_test") assert entity_entry is not None - state = hass.states.get("switch.test") + state = hass.states.get("switch.tasmota_test") assert state is not None - assert state.name == "Test" + assert state.name == "Tasmota Test" assert (mac, "switch", "relay", 0) in hass.data[ALREADY_DISCOVERED] @@ -530,11 +530,11 @@ async def test_entity_duplicate_discovery( ) await hass.async_block_till_done() - state = hass.states.get("switch.test") + state = hass.states.get("switch.tasmota_test") state_duplicate = hass.states.get("binary_sensor.beer1") assert state is not None - assert state.name == "Test" + assert state.name == "Tasmota Test" assert state_duplicate is None assert ( f"Entity already added, sending update: switch ('{mac}', 'switch', 'relay', 0)" diff --git a/tests/components/tasmota/test_fan.py b/tests/components/tasmota/test_fan.py index 0b99036518e..2a50e2d43b5 100644 --- a/tests/components/tasmota/test_fan.py +++ b/tests/components/tasmota/test_fan.py @@ -226,10 +226,9 @@ async def test_availability_when_connection_lost( ) -> None: """Test availability after MQTT disconnection.""" config = copy.deepcopy(DEFAULT_CONFIG) - config["dn"] = "Test" config["if"] = 1 await help_test_availability_when_connection_lost( - hass, mqtt_client_mock, mqtt_mock, Platform.FAN, config + hass, mqtt_client_mock, mqtt_mock, Platform.FAN, config, object_id="tasmota" ) @@ -238,9 +237,10 @@ async def test_availability( ) -> None: """Test availability.""" config = copy.deepcopy(DEFAULT_CONFIG) - config["dn"] = "Test" config["if"] = 1 - await help_test_availability(hass, mqtt_mock, Platform.FAN, config) + await help_test_availability( + hass, mqtt_mock, Platform.FAN, config, object_id="tasmota" + ) async def test_availability_discovery_update( @@ -248,9 +248,10 @@ async def test_availability_discovery_update( ) -> None: """Test availability discovery update.""" config = copy.deepcopy(DEFAULT_CONFIG) - config["dn"] = "Test" config["if"] = 1 - await help_test_availability_discovery_update(hass, mqtt_mock, Platform.FAN, config) + await help_test_availability_discovery_update( + hass, mqtt_mock, Platform.FAN, config, object_id="tasmota" + ) async def test_availability_poll_state( @@ -276,14 +277,19 @@ async def test_discovery_removal_fan( ) -> None: """Test removal of discovered fan.""" config1 = copy.deepcopy(DEFAULT_CONFIG) - config1["dn"] = "Test" config1["if"] = 1 config2 = copy.deepcopy(DEFAULT_CONFIG) - config2["dn"] = "Test" config2["if"] = 0 await help_test_discovery_removal( - hass, mqtt_mock, caplog, Platform.FAN, config1, config2 + hass, + mqtt_mock, + caplog, + Platform.FAN, + config1, + config2, + object_id="tasmota", + name="Tasmota", ) @@ -295,13 +301,19 @@ async def test_discovery_update_unchanged_fan( ) -> None: """Test update of discovered fan.""" config = copy.deepcopy(DEFAULT_CONFIG) - config["dn"] = "Test" config["if"] = 1 with patch( "homeassistant.components.tasmota.fan.TasmotaFan.discovery_update" ) as discovery_update: await help_test_discovery_update_unchanged( - hass, mqtt_mock, caplog, Platform.FAN, config, discovery_update + hass, + mqtt_mock, + caplog, + Platform.FAN, + config, + discovery_update, + object_id="tasmota", + name="Tasmota", ) @@ -310,7 +322,6 @@ async def test_discovery_device_remove( ) -> None: """Test device registry remove.""" config = copy.deepcopy(DEFAULT_CONFIG) - config["dn"] = "Test" config["if"] = 1 unique_id = f"{DEFAULT_CONFIG['mac']}_fan_fan_ifan" await help_test_discovery_device_remove( @@ -323,7 +334,6 @@ async def test_entity_id_update_subscriptions( ) -> None: """Test MQTT subscriptions are managed when entity_id is updated.""" config = copy.deepcopy(DEFAULT_CONFIG) - config["dn"] = "Test" config["if"] = 1 topics = [ get_topic_stat_result(config), @@ -331,7 +341,7 @@ async def test_entity_id_update_subscriptions( get_topic_tele_will(config), ] await help_test_entity_id_update_subscriptions( - hass, mqtt_mock, Platform.FAN, config, topics + hass, mqtt_mock, Platform.FAN, config, topics, object_id="tasmota" ) @@ -340,8 +350,7 @@ async def test_entity_id_update_discovery_update( ) -> None: """Test MQTT discovery update when entity_id is updated.""" config = copy.deepcopy(DEFAULT_CONFIG) - config["dn"] = "Test" config["if"] = 1 await help_test_entity_id_update_discovery_update( - hass, mqtt_mock, Platform.FAN, config + hass, mqtt_mock, Platform.FAN, config, object_id="tasmota" ) diff --git a/tests/components/tasmota/test_light.py b/tests/components/tasmota/test_light.py index 612bda8bb08..5c8339a6f89 100644 --- a/tests/components/tasmota/test_light.py +++ b/tests/components/tasmota/test_light.py @@ -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 diff --git a/tests/components/tasmota/test_switch.py b/tests/components/tasmota/test_switch.py index b79560214a8..b8d0ed2d060 100644 --- a/tests/components/tasmota/test_switch.py +++ b/tests/components/tasmota/test_switch.py @@ -47,34 +47,34 @@ async def test_controlling_state_via_mqtt( ) await hass.async_block_till_done() - state = hass.states.get("switch.test") + state = hass.states.get("switch.tasmota_test") assert state.state == "unavailable" assert not state.attributes.get(ATTR_ASSUMED_STATE) async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online") await hass.async_block_till_done() - state = hass.states.get("switch.test") + state = hass.states.get("switch.tasmota_test") assert state.state == STATE_OFF assert not state.attributes.get(ATTR_ASSUMED_STATE) async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}') - state = hass.states.get("switch.test") + state = hass.states.get("switch.tasmota_test") assert state.state == STATE_ON async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"OFF"}') - state = hass.states.get("switch.test") + state = hass.states.get("switch.tasmota_test") assert state.state == STATE_OFF async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/RESULT", '{"POWER":"ON"}') - state = hass.states.get("switch.test") + state = hass.states.get("switch.tasmota_test") assert state.state == STATE_ON async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/RESULT", '{"POWER":"OFF"}') - state = hass.states.get("switch.test") + state = hass.states.get("switch.tasmota_test") assert state.state == STATE_OFF @@ -95,30 +95,30 @@ async def test_sending_mqtt_commands( async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online") await hass.async_block_till_done() - state = hass.states.get("switch.test") + state = hass.states.get("switch.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 switch on and verify MQTT message is sent - await common.async_turn_on(hass, "switch.test") + await common.async_turn_on(hass, "switch.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("switch.test") + state = hass.states.get("switch.tasmota_test") assert state.state == STATE_OFF # Turn the switch off and verify MQTT message is sent - await common.async_turn_off(hass, "switch.test") + await common.async_turn_off(hass, "switch.tasmota_test") mqtt_mock.async_publish.assert_called_once_with( "tasmota_49A3BC/cmnd/Power1", "OFF", 0, False ) - state = hass.states.get("switch.test") + state = hass.states.get("switch.tasmota_test") assert state.state == STATE_OFF @@ -138,9 +138,9 @@ async def test_relay_as_light( ) await hass.async_block_till_done() - state = hass.states.get("switch.test") + state = hass.states.get("switch.tasmota_test") assert state is None - state = hass.states.get("light.test") + state = hass.states.get("light.tasmota_test") assert state is not None