mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Process abbreviated availability options in mqtt discovery payload (#79712)
Expand availability in mqtt discovery payload
This commit is contained in:
parent
c6df823b35
commit
6546bba233
@ -139,6 +139,14 @@ async def async_start( # noqa: C901
|
|||||||
key = DEVICE_ABBREVIATIONS.get(key, key)
|
key = DEVICE_ABBREVIATIONS.get(key, key)
|
||||||
device[key] = device.pop(abbreviated_key)
|
device[key] = device.pop(abbreviated_key)
|
||||||
|
|
||||||
|
if CONF_AVAILABILITY in payload:
|
||||||
|
for availability_conf in cv.ensure_list(payload[CONF_AVAILABILITY]):
|
||||||
|
if isinstance(availability_conf, dict):
|
||||||
|
for key in list(availability_conf):
|
||||||
|
abbreviated_key = key
|
||||||
|
key = ABBREVIATIONS.get(key, key)
|
||||||
|
availability_conf[key] = availability_conf.pop(abbreviated_key)
|
||||||
|
|
||||||
if TOPIC_BASE in payload:
|
if TOPIC_BASE in payload:
|
||||||
base = payload.pop(TOPIC_BASE)
|
base = payload.pop(TOPIC_BASE)
|
||||||
for key, value in payload.items():
|
for key, value in payload.items():
|
||||||
|
@ -945,9 +945,9 @@ async def test_discovery_expansion(hass, mqtt_mock_entry_no_yaml_config, caplog)
|
|||||||
' "payload_not_available": "not_available"'
|
' "payload_not_available": "not_available"'
|
||||||
" },"
|
" },"
|
||||||
" {"
|
" {"
|
||||||
' "topic":"avail_item2/~",'
|
' "t":"avail_item2/~",'
|
||||||
' "payload_available": "available",'
|
' "pl_avail": "available",'
|
||||||
' "payload_not_available": "not_available"'
|
' "pl_not_avail": "not_available"'
|
||||||
" }"
|
" }"
|
||||||
" ],"
|
" ],"
|
||||||
' "dev":{'
|
' "dev":{'
|
||||||
@ -999,9 +999,9 @@ async def test_discovery_expansion_2(hass, mqtt_mock_entry_no_yaml_config, caplo
|
|||||||
' "stat_t": "test_topic/~",'
|
' "stat_t": "test_topic/~",'
|
||||||
' "cmd_t": "~/test_topic",'
|
' "cmd_t": "~/test_topic",'
|
||||||
' "availability": {'
|
' "availability": {'
|
||||||
' "topic":"~/avail_item1",'
|
' "t":"~/avail_item1",'
|
||||||
' "payload_available": "available",'
|
' "pl_avail": "available",'
|
||||||
' "payload_not_available": "not_available"'
|
' "pl_not_avail": "not_available"'
|
||||||
" },"
|
" },"
|
||||||
' "dev":{'
|
' "dev":{'
|
||||||
' "ids":["5706DF"],'
|
' "ids":["5706DF"],'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user