Bump hatasmota to 0.6.5 (#92585)

* Bump hatasmota to 0.6.5

* Fix tests
This commit is contained in:
Erik Montnemery 2023-05-05 14:40:30 +02:00 committed by GitHub
parent 176820d665
commit 5843c1fa3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 82 additions and 26 deletions

View File

@ -8,5 +8,5 @@
"iot_class": "local_push", "iot_class": "local_push",
"loggers": ["hatasmota"], "loggers": ["hatasmota"],
"mqtt": ["tasmota/discovery/#"], "mqtt": ["tasmota/discovery/#"],
"requirements": ["hatasmota==0.6.4"] "requirements": ["hatasmota==0.6.5"]
} }

View File

@ -881,7 +881,7 @@ hass_splunk==0.1.1
hassil==1.0.6 hassil==1.0.6
# homeassistant.components.tasmota # homeassistant.components.tasmota
hatasmota==0.6.4 hatasmota==0.6.5
# homeassistant.components.jewish_calendar # homeassistant.components.jewish_calendar
hdate==0.10.4 hdate==0.10.4

View File

@ -679,7 +679,7 @@ hass-nabucasa==0.66.2
hassil==1.0.6 hassil==1.0.6
# homeassistant.components.tasmota # homeassistant.components.tasmota
hatasmota==0.6.4 hatasmota==0.6.5
# homeassistant.components.jewish_calendar # homeassistant.components.jewish_calendar
hdate==0.10.4 hdate==0.10.4

View File

@ -102,7 +102,7 @@ INDEXED_SENSOR_CONFIG_2 = {
} }
NESTED_SENSOR_CONFIG = { NESTED_SENSOR_CONFIG_1 = {
"sn": { "sn": {
"Time": "2020-03-03T00:00:00+00:00", "Time": "2020-03-03T00:00:00+00:00",
"TX23": { "TX23": {
@ -119,6 +119,17 @@ NESTED_SENSOR_CONFIG = {
} }
} }
NESTED_SENSOR_CONFIG_2 = {
"sn": {
"Time": "2023-01-27T11:04:56",
"DS18B20": {
"Id": "01191ED79190",
"Temperature": 2.4,
},
"TempUnit": "C",
}
}
async def test_controlling_state_via_mqtt( async def test_controlling_state_via_mqtt(
hass: HomeAssistant, mqtt_mock: MqttMockHAClient, setup_tasmota hass: HomeAssistant, mqtt_mock: MqttMockHAClient, setup_tasmota
@ -174,12 +185,59 @@ async def test_controlling_state_via_mqtt(
assert state.state == "20.0" assert state.state == "20.0"
@pytest.mark.parametrize(
("sensor_config", "entity_ids", "messages", "states"),
[
(
NESTED_SENSOR_CONFIG_1,
["sensor.tasmota_tx23_speed_act", "sensor.tasmota_tx23_dir_card"],
(
'{"TX23":{"Speed":{"Act":"12.3"},"Dir": {"Card": "WSW"}}}',
'{"StatusSNS":{"TX23":{"Speed":{"Act":"23.4"},"Dir": {"Card": "ESE"}}}}',
),
(
{
"sensor.tasmota_tx23_speed_act": "12.3",
"sensor.tasmota_tx23_dir_card": "WSW",
},
{
"sensor.tasmota_tx23_speed_act": "23.4",
"sensor.tasmota_tx23_dir_card": "ESE",
},
),
),
(
NESTED_SENSOR_CONFIG_2,
["sensor.tasmota_ds18b20_temperature", "sensor.tasmota_ds18b20_id"],
(
'{"DS18B20":{"Id": "01191ED79190","Temperature": 12.3}}',
'{"StatusSNS":{"DS18B20":{"Id": "meep","Temperature": 23.4}}}',
),
(
{
"sensor.tasmota_ds18b20_temperature": "12.3",
"sensor.tasmota_ds18b20_id": "01191ED79190",
},
{
"sensor.tasmota_ds18b20_temperature": "23.4",
"sensor.tasmota_ds18b20_id": "meep",
},
),
),
],
)
async def test_nested_sensor_state_via_mqtt( async def test_nested_sensor_state_via_mqtt(
hass: HomeAssistant, mqtt_mock: MqttMockHAClient, setup_tasmota hass: HomeAssistant,
mqtt_mock: MqttMockHAClient,
setup_tasmota,
sensor_config,
entity_ids,
messages,
states,
) -> None: ) -> None:
"""Test state update via MQTT.""" """Test state update via MQTT."""
config = copy.deepcopy(DEFAULT_CONFIG) config = copy.deepcopy(DEFAULT_CONFIG)
sensor_config = copy.deepcopy(NESTED_SENSOR_CONFIG) sensor_config = copy.deepcopy(sensor_config)
mac = config["mac"] mac = config["mac"]
async_fire_mqtt_message( async_fire_mqtt_message(
@ -195,31 +253,29 @@ async def test_nested_sensor_state_via_mqtt(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
state = hass.states.get("sensor.tasmota_tx23_speed_act") for entity_id in entity_ids:
state = hass.states.get(entity_id)
assert state.state == "unavailable" assert state.state == "unavailable"
assert not state.attributes.get(ATTR_ASSUMED_STATE) assert not state.attributes.get(ATTR_ASSUMED_STATE)
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online") async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
await hass.async_block_till_done() await hass.async_block_till_done()
state = hass.states.get("sensor.tasmota_tx23_speed_act") for entity_id in entity_ids:
state = hass.states.get(entity_id)
assert state.state == STATE_UNKNOWN assert state.state == STATE_UNKNOWN
assert not state.attributes.get(ATTR_ASSUMED_STATE) assert not state.attributes.get(ATTR_ASSUMED_STATE)
# Test periodic state update # Test periodic state update
async_fire_mqtt_message( async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/SENSOR", messages[0])
hass, "tasmota_49A3BC/tele/SENSOR", '{"TX23":{"Speed":{"Act":"12.3"}}}' for entity_id in entity_ids:
) state = hass.states.get(entity_id)
state = hass.states.get("sensor.tasmota_tx23_speed_act") assert state.state == states[0][entity_id]
assert state.state == "12.3"
# Test polled state update # Test polled state update
async_fire_mqtt_message( async_fire_mqtt_message(hass, "tasmota_49A3BC/stat/STATUS10", messages[1])
hass, for entity_id in entity_ids:
"tasmota_49A3BC/stat/STATUS10", state = hass.states.get(entity_id)
'{"StatusSNS":{"TX23":{"Speed":{"Act":"23.4"}}}}', assert state.state == states[1][entity_id]
)
state = hass.states.get("sensor.tasmota_tx23_speed_act")
assert state.state == "23.4"
async def test_indexed_sensor_state_via_mqtt( async def test_indexed_sensor_state_via_mqtt(
@ -728,7 +784,7 @@ async def test_nested_sensor_attributes(
) -> None: ) -> None:
"""Test correct attributes for sensors.""" """Test correct attributes for sensors."""
config = copy.deepcopy(DEFAULT_CONFIG) config = copy.deepcopy(DEFAULT_CONFIG)
sensor_config = copy.deepcopy(NESTED_SENSOR_CONFIG) sensor_config = copy.deepcopy(NESTED_SENSOR_CONFIG_1)
mac = config["mac"] mac = config["mac"]
async_fire_mqtt_message( async_fire_mqtt_message(
@ -754,7 +810,7 @@ async def test_nested_sensor_attributes(
assert state.attributes.get("device_class") is None assert state.attributes.get("device_class") is None
assert state.attributes.get("friendly_name") == "Tasmota TX23 Dir Avg" assert state.attributes.get("friendly_name") == "Tasmota TX23 Dir Avg"
assert state.attributes.get("icon") is None assert state.attributes.get("icon") is None
assert state.attributes.get("unit_of_measurement") == " " assert state.attributes.get("unit_of_measurement") is None
async def test_indexed_sensor_attributes( async def test_indexed_sensor_attributes(