Bump hatasmota to 0.2.12 (#50372)
parent
ee58f6105e
commit
e57634b1e0
|
@ -3,7 +3,7 @@
|
|||
"name": "Tasmota",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/tasmota",
|
||||
"requirements": ["hatasmota==0.2.11"],
|
||||
"requirements": ["hatasmota==0.2.12"],
|
||||
"dependencies": ["mqtt"],
|
||||
"mqtt": ["tasmota/discovery/#"],
|
||||
"codeowners": ["@emontnemery"],
|
||||
|
|
|
@ -735,7 +735,7 @@ hass-nabucasa==0.43.0
|
|||
hass_splunk==0.1.1
|
||||
|
||||
# homeassistant.components.tasmota
|
||||
hatasmota==0.2.11
|
||||
hatasmota==0.2.12
|
||||
|
||||
# homeassistant.components.jewish_calendar
|
||||
hdate==0.10.2
|
||||
|
|
|
@ -405,7 +405,7 @@ hangups==0.4.11
|
|||
hass-nabucasa==0.43.0
|
||||
|
||||
# homeassistant.components.tasmota
|
||||
hatasmota==0.2.11
|
||||
hatasmota==0.2.12
|
||||
|
||||
# homeassistant.components.jewish_calendar
|
||||
hdate==0.10.2
|
||||
|
|
|
@ -43,6 +43,15 @@ DEFAULT_SENSOR_CONFIG = {
|
|||
}
|
||||
}
|
||||
|
||||
BAD_INDEXED_SENSOR_CONFIG_3 = {
|
||||
"sn": {
|
||||
"Time": "2020-09-25T12:47:15",
|
||||
"ENERGY": {
|
||||
"ApparentPower": [7.84, 1.23, 2.34],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
INDEXED_SENSOR_CONFIG = {
|
||||
"sn": {
|
||||
"Time": "2020-09-25T12:47:15",
|
||||
|
@ -224,6 +233,117 @@ async def test_indexed_sensor_state_via_mqtt(hass, mqtt_mock, setup_tasmota):
|
|||
assert state.state == "7.8"
|
||||
|
||||
|
||||
async def test_bad_indexed_sensor_state_via_mqtt(hass, mqtt_mock, setup_tasmota):
|
||||
"""Test state update via MQTT where sensor is not matching configuration."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG)
|
||||
sensor_config = copy.deepcopy(BAD_INDEXED_SENSOR_CONFIG_3)
|
||||
mac = config["mac"]
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
f"{DEFAULT_PREFIX}/{mac}/config",
|
||||
json.dumps(config),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
f"{DEFAULT_PREFIX}/{mac}/sensors",
|
||||
json.dumps(sensor_config),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_0")
|
||||
assert state.state == "unavailable"
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_1")
|
||||
assert state.state == "unavailable"
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_2")
|
||||
assert state.state == "unavailable"
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_0")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_1")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_2")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
# Test periodic state update
|
||||
async_fire_mqtt_message(
|
||||
hass, "tasmota_49A3BC/tele/SENSOR", '{"ENERGY":{"ApparentPower":[1.2,3.4,5.6]}}'
|
||||
)
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_0")
|
||||
assert state.state == "1.2"
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_1")
|
||||
assert state.state == "3.4"
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_2")
|
||||
assert state.state == "5.6"
|
||||
|
||||
# Test periodic state update with too few values
|
||||
async_fire_mqtt_message(
|
||||
hass, "tasmota_49A3BC/tele/SENSOR", '{"ENERGY":{"ApparentPower":[7.8,9.0]}}'
|
||||
)
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_0")
|
||||
assert state.state == "7.8"
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_1")
|
||||
assert state.state == "9.0"
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_2")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass, "tasmota_49A3BC/tele/SENSOR", '{"ENERGY":{"ApparentPower":2.3}}'
|
||||
)
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_0")
|
||||
assert state.state == "2.3"
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_1")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_2")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
|
||||
# Test polled state update
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
"tasmota_49A3BC/stat/STATUS10",
|
||||
'{"StatusSNS":{"ENERGY":{"ApparentPower":[1.2,3.4,5.6]}}}',
|
||||
)
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_0")
|
||||
assert state.state == "1.2"
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_1")
|
||||
assert state.state == "3.4"
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_2")
|
||||
assert state.state == "5.6"
|
||||
|
||||
# Test polled state update with too few values
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
"tasmota_49A3BC/stat/STATUS10",
|
||||
'{"StatusSNS":{"ENERGY":{"ApparentPower":[7.8,9.0]}}}',
|
||||
)
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_0")
|
||||
assert state.state == "7.8"
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_1")
|
||||
assert state.state == "9.0"
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_2")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
"tasmota_49A3BC/stat/STATUS10",
|
||||
'{"StatusSNS":{"ENERGY":{"ApparentPower":2.3}}}',
|
||||
)
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_0")
|
||||
assert state.state == "2.3"
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_1")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_2")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
|
||||
|
||||
@pytest.mark.parametrize("status_sensor_disabled", [False])
|
||||
async def test_status_sensor_state_via_mqtt(hass, mqtt_mock, setup_tasmota):
|
||||
"""Test state update via MQTT."""
|
||||
|
|
Loading…
Reference in New Issue