Rework and fix mqtt siren writing state and attributes (#100871)
Rework mqtt siren writing state and attributes
This commit is contained in:
parent
d76c5ed351
commit
ea1108503d
2 changed files with 12 additions and 9 deletions
|
@ -257,7 +257,7 @@ async def test_controlling_state_and_attributes_with_json_message_without_templa
|
|||
async_fire_mqtt_message(
|
||||
hass,
|
||||
"state-topic",
|
||||
'{"state":"beer off", "duration": 5, "volume_level": 0.6}',
|
||||
'{"state":"beer off", "tone": "bell", "duration": 5, "volume_level": 0.6}',
|
||||
)
|
||||
|
||||
state = hass.states.get("siren.test")
|
||||
|
@ -270,14 +270,15 @@ async def test_controlling_state_and_attributes_with_json_message_without_templa
|
|||
async_fire_mqtt_message(
|
||||
hass,
|
||||
"state-topic",
|
||||
'{"state":"beer on", "duration": 6, "volume_level": 2 }',
|
||||
'{"state":"beer on", "duration": 6, "volume_level": 2,"tone": "ping"}',
|
||||
)
|
||||
state = hass.states.get("siren.test")
|
||||
assert (
|
||||
"Unable to update siren state attributes from payload '{'duration': 6, 'volume_level': 2}': value must be at most 1 for dictionary value @ data['volume_level']"
|
||||
"Unable to update siren state attributes from payload '{'duration': 6, 'volume_level': 2, 'tone': 'ping'}': value must be at most 1 for dictionary value @ data['volume_level']"
|
||||
in caplog.text
|
||||
)
|
||||
assert state.state == STATE_OFF
|
||||
# Only the on/of state was updated, not the attributes
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get(siren.ATTR_TONE) == "bell"
|
||||
assert state.attributes.get(siren.ATTR_DURATION) == 5
|
||||
assert state.attributes.get(siren.ATTR_VOLUME_LEVEL) == 0.6
|
||||
|
@ -287,7 +288,7 @@ async def test_controlling_state_and_attributes_with_json_message_without_templa
|
|||
"state-topic",
|
||||
"{}",
|
||||
)
|
||||
assert state.state == STATE_OFF
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get(siren.ATTR_TONE) == "bell"
|
||||
assert state.attributes.get(siren.ATTR_DURATION) == 5
|
||||
assert state.attributes.get(siren.ATTR_VOLUME_LEVEL) == 0.6
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue