diff --git a/homeassistant/components/tasmota/manifest.json b/homeassistant/components/tasmota/manifest.json index bdd25f4466a..8cc3006c63a 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.22"], + "requirements": ["hatasmota==0.0.23"], "dependencies": ["mqtt"], "mqtt": ["tasmota/discovery/#"], "codeowners": ["@emontnemery"] diff --git a/requirements_all.txt b/requirements_all.txt index 3a42783943d..38acdd8c2bb 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -732,7 +732,7 @@ hass-nabucasa==0.37.1 hass_splunk==0.1.1 # homeassistant.components.tasmota -hatasmota==0.0.22 +hatasmota==0.0.23 # homeassistant.components.jewish_calendar hdate==0.9.5 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 7045cf283d2..abacd5568e9 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -367,7 +367,7 @@ hangups==0.4.11 hass-nabucasa==0.37.1 # homeassistant.components.tasmota -hatasmota==0.0.22 +hatasmota==0.0.23 # homeassistant.components.jewish_calendar hdate==0.9.5 diff --git a/tests/components/tasmota/test_light.py b/tests/components/tasmota/test_light.py index 871d55a4d73..f9d839516e8 100644 --- a/tests/components/tasmota/test_light.py +++ b/tests/components/tasmota/test_light.py @@ -3,6 +3,11 @@ import copy import json from hatasmota.const import CONF_MAC +from hatasmota.utils import ( + get_topic_stat_result, + get_topic_tele_state, + get_topic_tele_will, +) from homeassistant.components import light from homeassistant.components.light import ( @@ -310,6 +315,16 @@ async def test_controlling_state_via_mqtt_on_off(hass, mqtt_mock, setup_tasmota) state = hass.states.get("light.test") assert state.state == STATE_OFF + async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/RESULT", '{"POWER":"ON"}') + + state = hass.states.get("light.test") + assert state.state == STATE_ON + + async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/RESULT", '{"POWER":"OFF"}') + + state = hass.states.get("light.test") + assert state.state == STATE_OFF + async def test_controlling_state_via_mqtt_ct(hass, mqtt_mock, setup_tasmota): """Test state update via MQTT.""" @@ -432,6 +447,16 @@ async def test_controlling_state_via_mqtt_rgbww(hass, mqtt_mock, setup_tasmota): 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") + assert state.state == STATE_ON + + async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/RESULT", '{"POWER":"OFF"}') + + state = hass.states.get("light.test") + assert state.state == STATE_OFF + async def test_sending_mqtt_commands_on_off(hass, mqtt_mock, setup_tasmota): """Test the sending MQTT commands.""" @@ -914,8 +939,13 @@ async def test_entity_id_update_subscriptions(hass, mqtt_mock, setup_tasmota): config = copy.deepcopy(DEFAULT_CONFIG) config["rl"][0] = 2 config["lt_st"] = 1 # 1 channel light (Dimmer) + topics = [ + get_topic_stat_result(config), + get_topic_tele_state(config), + get_topic_tele_will(config), + ] await help_test_entity_id_update_subscriptions( - hass, mqtt_mock, light.DOMAIN, config + hass, mqtt_mock, light.DOMAIN, config, topics ) diff --git a/tests/components/tasmota/test_switch.py b/tests/components/tasmota/test_switch.py index 564dc2f2868..208026c2de5 100644 --- a/tests/components/tasmota/test_switch.py +++ b/tests/components/tasmota/test_switch.py @@ -2,6 +2,12 @@ import copy import json +from hatasmota.utils import ( + get_topic_stat_result, + get_topic_tele_state, + get_topic_tele_will, +) + from homeassistant.components import switch from homeassistant.components.tasmota.const import DEFAULT_PREFIX from homeassistant.const import ATTR_ASSUMED_STATE, STATE_OFF, STATE_ON @@ -56,6 +62,16 @@ async def test_controlling_state_via_mqtt(hass, mqtt_mock, setup_tasmota): state = hass.states.get("switch.test") assert state.state == STATE_OFF + async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/RESULT", '{"POWER":"ON"}') + + state = hass.states.get("switch.test") + assert state.state == STATE_ON + + async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/RESULT", '{"POWER":"OFF"}') + + state = hass.states.get("switch.test") + assert state.state == STATE_OFF + async def test_sending_mqtt_commands(hass, mqtt_mock, setup_tasmota): """Test the sending MQTT commands.""" @@ -211,8 +227,13 @@ async def test_entity_id_update_subscriptions(hass, mqtt_mock, setup_tasmota): """Test MQTT subscriptions are managed when entity_id is updated.""" config = copy.deepcopy(DEFAULT_CONFIG) config["rl"][0] = 1 + topics = [ + get_topic_stat_result(config), + get_topic_tele_state(config), + get_topic_tele_will(config), + ] await help_test_entity_id_update_subscriptions( - hass, mqtt_mock, switch.DOMAIN, config + hass, mqtt_mock, switch.DOMAIN, config, topics )