diff --git a/homeassistant/components/tasmota/manifest.json b/homeassistant/components/tasmota/manifest.json index 7cc6413e162f57ce72c87027754973d88ec189ab..2b8bbc8d10339f578b593a4fc466a9d861b82f98 100644 --- a/homeassistant/components/tasmota/manifest.json +++ b/homeassistant/components/tasmota/manifest.json @@ -3,7 +3,7 @@ "name": "Tasmota (beta)", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/tasmota", - "requirements": ["hatasmota==0.0.26"], + "requirements": ["hatasmota==0.0.27"], "dependencies": ["mqtt"], "mqtt": ["tasmota/discovery/#"], "codeowners": ["@emontnemery"] diff --git a/homeassistant/components/tasmota/sensor.py b/homeassistant/components/tasmota/sensor.py index badf20956650fa20a4a28713068744aebaf9fc15..480e5d8d2146e8503984dd1988c61973c5b2eb6b 100644 --- a/homeassistant/components/tasmota/sensor.py +++ b/homeassistant/components/tasmota/sensor.py @@ -37,6 +37,7 @@ from hatasmota.const import ( SENSOR_STATUS_IP, SENSOR_STATUS_LINK_COUNT, SENSOR_STATUS_MQTT_COUNT, + SENSOR_STATUS_RESTART, SENSOR_STATUS_RSSI, SENSOR_STATUS_SIGNAL, SENSOR_STATUS_UPTIME, @@ -59,7 +60,6 @@ from homeassistant.const import ( DEVICE_CLASS_PRESSURE, DEVICE_CLASS_SIGNAL_STRENGTH, DEVICE_CLASS_TEMPERATURE, - DEVICE_CLASS_TIMESTAMP, ) from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -108,14 +108,15 @@ SENSOR_DEVICE_CLASS_ICON_MAP = { SENSOR_PRESSUREATSEALEVEL: {DEVICE_CLASS: DEVICE_CLASS_PRESSURE}, SENSOR_PROXIMITY: {ICON: "mdi:ruler"}, SENSOR_REACTIVE_POWERUSAGE: {DEVICE_CLASS: DEVICE_CLASS_POWER}, + SENSOR_STATUS_RESTART: {ICON: "mdi:information-outline"}, SENSOR_STATUS_SIGNAL: {DEVICE_CLASS: DEVICE_CLASS_SIGNAL_STRENGTH}, SENSOR_STATUS_RSSI: {ICON: "mdi:access-point"}, + SENSOR_STATUS_UPTIME: {ICON: "mdi:progress-clock"}, SENSOR_TEMPERATURE: {DEVICE_CLASS: DEVICE_CLASS_TEMPERATURE}, SENSOR_TODAY: {DEVICE_CLASS: DEVICE_CLASS_POWER}, SENSOR_TOTAL: {DEVICE_CLASS: DEVICE_CLASS_POWER}, SENSOR_TOTAL_START_TIME: {ICON: "mdi:progress-clock"}, SENSOR_TVOC: {ICON: "mdi:air-filter"}, - SENSOR_STATUS_UPTIME: {DEVICE_CLASS: DEVICE_CLASS_TIMESTAMP}, SENSOR_VOLTAGE: {ICON: "mdi:alpha-v-circle-outline"}, SENSOR_WEIGHT: {ICON: "mdi:scale"}, SENSOR_YESTERDAY: {DEVICE_CLASS: DEVICE_CLASS_POWER}, diff --git a/requirements_all.txt b/requirements_all.txt index 6be4ac3ad3d6167f9b19f2a34bed276dea7b7eee..94c460075777be3b61fdc80b6a0b10c62fd20b29 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -738,7 +738,7 @@ hass-nabucasa==0.37.1 hass_splunk==0.1.1 # homeassistant.components.tasmota -hatasmota==0.0.26 +hatasmota==0.0.27 # homeassistant.components.jewish_calendar hdate==0.9.12 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index cdb1322577905d7f2e3b7d42bb33e46fdb73391f..927ef726c8a69b6c44bcc540a817c4127f5f499d 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -376,7 +376,7 @@ hangups==0.4.11 hass-nabucasa==0.37.1 # homeassistant.components.tasmota -hatasmota==0.0.26 +hatasmota==0.0.27 # homeassistant.components.jewish_calendar hdate==0.9.12 diff --git a/tests/components/tasmota/test_binary_sensor.py b/tests/components/tasmota/test_binary_sensor.py index 52ab88b0ecb5814584d7b24fa992dc46d727238e..c3982bf69fdc733094d2e9da3f38ca49ec985b92 100644 --- a/tests/components/tasmota/test_binary_sensor.py +++ b/tests/components/tasmota/test_binary_sensor.py @@ -4,8 +4,8 @@ from datetime import timedelta import json from hatasmota.utils import ( + get_topic_stat_result, get_topic_stat_status, - get_topic_stat_switch, get_topic_tele_sensor, get_topic_tele_will, ) @@ -61,11 +61,15 @@ async def test_controlling_state_via_mqtt(hass, mqtt_mock, setup_tasmota): assert not state.attributes.get(ATTR_ASSUMED_STATE) # Test normal state update - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1", '{"STATE":"ON"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"ON"}}' + ) state = hass.states.get("binary_sensor.test") assert state.state == STATE_ON - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1", '{"STATE":"OFF"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"OFF"}}' + ) state = hass.states.get("binary_sensor.test") assert state.state == STATE_OFF @@ -80,13 +84,13 @@ async def test_controlling_state_via_mqtt(hass, mqtt_mock, setup_tasmota): # Test polled state update async_fire_mqtt_message( - hass, "tasmota_49A3BC/stat/STATUS8", '{"StatusSNS":{"Switch1":"ON"}}' + hass, "tasmota_49A3BC/stat/STATUS10", '{"StatusSNS":{"Switch1":"ON"}}' ) state = hass.states.get("binary_sensor.test") assert state.state == STATE_ON async_fire_mqtt_message( - hass, "tasmota_49A3BC/stat/STATUS8", '{"StatusSNS":{"Switch1":"OFF"}}' + hass, "tasmota_49A3BC/stat/STATUS10", '{"StatusSNS":{"Switch1":"OFF"}}' ) state = hass.states.get("binary_sensor.test") assert state.state == STATE_OFF @@ -141,13 +145,17 @@ async def test_off_delay(hass, mqtt_mock, setup_tasmota): async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online") await hass.async_block_till_done() assert events == ["off"] - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1", '{"STATE":"ON"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"ON"}}' + ) await hass.async_block_till_done() state = hass.states.get("binary_sensor.test") assert state.state == STATE_ON assert events == ["off", "on"] - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1", '{"STATE":"ON"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"ON"}}' + ) await hass.async_block_till_done() state = hass.states.get("binary_sensor.test") assert state.state == STATE_ON @@ -195,7 +203,13 @@ async def test_availability_poll_state( config["swc"][0] = 1 poll_topic = "tasmota_49A3BC/cmnd/STATUS" await help_test_availability_poll_state( - hass, mqtt_client_mock, mqtt_mock, binary_sensor.DOMAIN, config, poll_topic, "8" + hass, + mqtt_client_mock, + mqtt_mock, + binary_sensor.DOMAIN, + config, + poll_topic, + "10", ) @@ -240,9 +254,9 @@ async def test_entity_id_update_subscriptions(hass, mqtt_mock, setup_tasmota): config = copy.deepcopy(DEFAULT_CONFIG) config["swc"][0] = 1 topics = [ - get_topic_stat_switch(config, 0), + get_topic_stat_result(config), get_topic_tele_sensor(config), - get_topic_stat_status(config, 8), + get_topic_stat_status(config, 10), get_topic_tele_will(config), ] await help_test_entity_id_update_subscriptions( diff --git a/tests/components/tasmota/test_common.py b/tests/components/tasmota/test_common.py index 5c18f2f401c0876202f036ec5c6341498d213421..04346f915c44acc9d8f837131f94c341ba032357 100644 --- a/tests/components/tasmota/test_common.py +++ b/tests/components/tasmota/test_common.py @@ -24,6 +24,44 @@ from tests.async_mock import ANY from tests.common import async_fire_mqtt_message DEFAULT_CONFIG = { + "ip": "192.168.15.10", + "dn": "Tasmota", + "fn": ["Test", "Beer", "Milk", "Four", None], + "hn": "tasmota_49A3BC-0956", + "if": 0, # iFan + "lk": 1, # RGB + white channels linked to a single light + "mac": "00000049A3BC", + "md": "Sonoff Basic", + "ofln": "Offline", + "onln": "Online", + "state": ["OFF", "ON", "TOGGLE", "HOLD"], + "sw": "8.4.0.2", + "swn": [None, None, None, None, None], + "t": "tasmota_49A3BC", + "ft": "%topic%/%prefix%/", + "tp": ["cmnd", "stat", "tele"], + "rl": [0, 0, 0, 0, 0, 0, 0, 0], + "swc": [-1, -1, -1, -1, -1, -1, -1, -1], + "btn": [0, 0, 0, 0], + "so": { + "4": 0, # Return MQTT response as RESULT or %COMMAND% + "11": 0, # Swap button single and double press functionality + "13": 0, # Allow immediate action on single button press + "17": 1, # Show Color string as hex or comma-separated + "20": 0, # Update of Dimmer/Color/CT without turning power on + "30": 0, # Enforce Home Assistant auto-discovery as light + "68": 0, # Multi-channel PWM instead of a single light + "73": 0, # Enable Buttons decoupling and send multi-press and hold MQTT messages + "82": 0, # Reduce the CT range from 153..500 to 200.380 + "114": 0, # Enable sending switch MQTT messages + }, + "ty": 0, # Tuya MCU + "lt_st": 0, + "ver": 1, +} + + +DEFAULT_CONFIG_9_0_0_3 = { "ip": "192.168.15.10", "dn": "Tasmota", "fn": ["Test", "Beer", "Milk", "Four", None], diff --git a/tests/components/tasmota/test_device_trigger.py b/tests/components/tasmota/test_device_trigger.py index b027b2c095da0ece368154c5991a9e06df54b53b..09c3d691b0946b7421d7c0a603e4ff0d297d7c61 100644 --- a/tests/components/tasmota/test_device_trigger.py +++ b/tests/components/tasmota/test_device_trigger.py @@ -142,6 +142,7 @@ async def test_discover_bad_triggers( mac=None, source=None, subtype=None, + switchname=None, trigger_topic=None, type=None, ) @@ -245,6 +246,7 @@ async def test_if_fires_on_mqtt_message( config = copy.deepcopy(DEFAULT_CONFIG) config["swc"][0] = 0 config["swc"][2] = 9 + config["swn"][2] = "custom_switch" mac = config["mac"] async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config)) @@ -289,13 +291,17 @@ async def test_if_fires_on_mqtt_message( ) # Fake short press. - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 1 assert calls[0].data["some"] == "short_press" # Fake long press. - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH3T", '{"TRIG":"HOLD"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"custom_switch":{"Action":"HOLD"}}' + ) await hass.async_block_till_done() assert len(calls) == 2 assert calls[1].data["some"] == "long_press" @@ -314,6 +320,7 @@ async def test_if_fires_on_mqtt_message_late_discover( config2 = copy.deepcopy(DEFAULT_CONFIG) config2["swc"][0] = 0 config2["swc"][3] = 9 + config2["swn"][3] = "custom_switch" async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1)) await hass.async_block_till_done() @@ -361,13 +368,17 @@ async def test_if_fires_on_mqtt_message_late_discover( await hass.async_block_till_done() # Fake short press. - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 1 assert calls[0].data["some"] == "short_press" # Fake long press. - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH4T", '{"TRIG":"HOLD"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"custom_switch":{"Action":"HOLD"}}' + ) await hass.async_block_till_done() assert len(calls) == 2 assert calls[1].data["some"] == "double_press" @@ -414,7 +425,9 @@ async def test_if_fires_on_mqtt_message_after_update( ) # Fake short press. - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 1 @@ -422,11 +435,15 @@ async def test_if_fires_on_mqtt_message_after_update( async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config2)) await hass.async_block_till_done() - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 1 - async_fire_mqtt_message(hass, "tasmota_49A3BC/status/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/status/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 2 @@ -434,11 +451,15 @@ async def test_if_fires_on_mqtt_message_after_update( async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config2)) await hass.async_block_till_done() - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 2 - async_fire_mqtt_message(hass, "tasmota_49A3BC/status/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/status/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 3 @@ -527,7 +548,9 @@ async def test_not_fires_on_mqtt_message_after_remove_by_mqtt( ) # Fake short press. - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 1 @@ -536,7 +559,9 @@ async def test_not_fires_on_mqtt_message_after_remove_by_mqtt( async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config)) await hass.async_block_till_done() - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 1 @@ -545,7 +570,9 @@ async def test_not_fires_on_mqtt_message_after_remove_by_mqtt( async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config)) await hass.async_block_till_done() - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 2 @@ -590,7 +617,9 @@ async def test_not_fires_on_mqtt_message_after_remove_from_registry( ) # Fake short press. - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 1 @@ -598,7 +627,9 @@ async def test_not_fires_on_mqtt_message_after_remove_from_registry( device_reg.async_remove_device(device_entry.id) await hass.async_block_till_done() - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 1 @@ -637,7 +668,9 @@ async def test_attach_remove(hass, device_reg, mqtt_mock, setup_tasmota): ) # Fake short press. - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 1 assert calls[0] == "event 'tasmota_event'" @@ -647,7 +680,9 @@ async def test_attach_remove(hass, device_reg, mqtt_mock, setup_tasmota): await hass.async_block_till_done() # Verify the triggers are no longer active - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 1 @@ -688,7 +723,9 @@ async def test_attach_remove_late(hass, device_reg, mqtt_mock, setup_tasmota): ) # Fake short press. - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 0 @@ -696,7 +733,9 @@ async def test_attach_remove_late(hass, device_reg, mqtt_mock, setup_tasmota): await hass.async_block_till_done() # Fake short press. - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 1 assert calls[0] == "event 'tasmota_event'" @@ -706,7 +745,9 @@ async def test_attach_remove_late(hass, device_reg, mqtt_mock, setup_tasmota): await hass.async_block_till_done() # Verify the triggers are no longer active - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 1 @@ -754,7 +795,9 @@ async def test_attach_remove_late2(hass, device_reg, mqtt_mock, setup_tasmota): await hass.async_block_till_done() # Verify the triggers is not active - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 0 @@ -866,7 +909,9 @@ async def test_attach_remove_config_entry(hass, device_reg, mqtt_mock, setup_tas ) # Fake short press. - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 1 assert calls[0] == "event 'tasmota_event'" @@ -877,6 +922,8 @@ async def test_attach_remove_config_entry(hass, device_reg, mqtt_mock, setup_tas await hass.async_block_till_done() # Verify the triggers are no longer active - async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/SWITCH1T", '{"TRIG":"TOGGLE"}') + async_fire_mqtt_message( + hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}' + ) await hass.async_block_till_done() assert len(calls) == 1 diff --git a/tests/components/tasmota/test_discovery.py b/tests/components/tasmota/test_discovery.py index 607676615a749cd5f9df3b0194faa793b87a3359..b6a51a38daf0f3adda973ce651c21f37d64f117e 100644 --- a/tests/components/tasmota/test_discovery.py +++ b/tests/components/tasmota/test_discovery.py @@ -6,7 +6,7 @@ from homeassistant.components.tasmota.const import DEFAULT_PREFIX from homeassistant.components.tasmota.discovery import ALREADY_DISCOVERED from .conftest import setup_tasmota_helper -from .test_common import DEFAULT_CONFIG +from .test_common import DEFAULT_CONFIG, DEFAULT_CONFIG_9_0_0_3 from tests.async_mock import patch from tests.common import async_fire_mqtt_message @@ -132,6 +132,29 @@ async def test_device_discover( assert device_entry.sw_version == config["sw"] +async def test_device_discover_deprecated( + hass, mqtt_mock, caplog, device_reg, entity_reg, setup_tasmota +): + """Test setting up a device with deprecated discovery message.""" + config = copy.deepcopy(DEFAULT_CONFIG_9_0_0_3) + mac = config["mac"] + + async_fire_mqtt_message( + hass, + f"{DEFAULT_PREFIX}/{mac}/config", + json.dumps(config), + ) + await hass.async_block_till_done() + + # Verify device and registry entries are created + device_entry = device_reg.async_get_device(set(), {("mac", mac)}) + assert device_entry is not None + assert device_entry.manufacturer == "Tasmota" + assert device_entry.model == config["md"] + assert device_entry.name == config["dn"] + assert device_entry.sw_version == config["sw"] + + async def test_device_update( hass, mqtt_mock, caplog, device_reg, entity_reg, setup_tasmota ): diff --git a/tests/components/tasmota/test_mixins.py b/tests/components/tasmota/test_mixins.py index a90d4c01fd7f6797828611b182f4edb806abb365..5f4ef443475d5b84032362e4cf895dc6147696f8 100644 --- a/tests/components/tasmota/test_mixins.py +++ b/tests/components/tasmota/test_mixins.py @@ -23,7 +23,7 @@ async def test_availability_poll_state_once( config["swc"][0] = 1 config["swc"][1] = 1 poll_payload_relay = "" - poll_payload_switch = "8" + poll_payload_switch = "10" poll_topic_relay = "tasmota_49A3BC/cmnd/STATE" poll_topic_switch = "tasmota_49A3BC/cmnd/STATUS" diff --git a/tests/components/tasmota/test_sensor.py b/tests/components/tasmota/test_sensor.py index e5d55b75a3adedd3b2dca25d01c419f3e6a5b574..b8e5583579b44ff7aa16bc0ae9d4c20debe08438 100644 --- a/tests/components/tasmota/test_sensor.py +++ b/tests/components/tasmota/test_sensor.py @@ -124,7 +124,7 @@ async def test_controlling_state_via_mqtt(hass, mqtt_mock, setup_tasmota): # Test polled state update async_fire_mqtt_message( hass, - "tasmota_49A3BC/stat/STATUS8", + "tasmota_49A3BC/stat/STATUS10", '{"StatusSNS":{"DHT11":{"Temperature":20.0}}}', ) state = hass.states.get("sensor.tasmota_dht11_temperature") @@ -169,7 +169,7 @@ async def test_nested_sensor_state_via_mqtt(hass, mqtt_mock, setup_tasmota): # Test polled state update async_fire_mqtt_message( hass, - "tasmota_49A3BC/stat/STATUS8", + "tasmota_49A3BC/stat/STATUS10", '{"StatusSNS":{"TX23":{"Speed":{"Act":"23.4"}}}}', ) state = hass.states.get("sensor.tasmota_tx23_speed_act") @@ -214,7 +214,7 @@ async def test_indexed_sensor_state_via_mqtt(hass, mqtt_mock, setup_tasmota): # Test polled state update async_fire_mqtt_message( hass, - "tasmota_49A3BC/stat/STATUS8", + "tasmota_49A3BC/stat/STATUS10", '{"StatusSNS":{"ENERGY":{"TotalTariff":[5.6,7.8]}}}', ) state = hass.states.get("sensor.tasmota_energy_totaltariff_1") @@ -497,7 +497,7 @@ async def test_availability_poll_state( sensor.DOMAIN, config, poll_topic, - "8", + "10", sensor_config, ) @@ -559,7 +559,7 @@ async def test_entity_id_update_subscriptions(hass, mqtt_mock, setup_tasmota): sensor_config = copy.deepcopy(DEFAULT_SENSOR_CONFIG) topics = [ get_topic_tele_sensor(config), - get_topic_stat_status(config, 8), + get_topic_stat_status(config, 10), get_topic_tele_will(config), ] await help_test_entity_id_update_subscriptions(