1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Remove unused parameter for MQTT discovery (#36526)

* Remove unused parameter for MQTT discovery

* Fix tests
This commit is contained in:
Erik Montnemery
2020-06-07 19:35:35 +02:00
committed by GitHub
parent 823f27db5a
commit 35cd6b9abf
10 changed files with 74 additions and 87 deletions

View File

@@ -43,7 +43,7 @@ async def test_get_triggers(hass, device_reg, entity_reg, mqtt_mock):
"""Test we get the expected triggers from a discovered mqtt device."""
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
data1 = (
'{ "automation_type":"trigger",'
@@ -75,7 +75,7 @@ async def test_get_unknown_triggers(hass, device_reg, entity_reg, mqtt_mock):
"""Test we don't get unknown triggers."""
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
# Discover a sensor (without device triggers)
data1 = (
@@ -119,7 +119,7 @@ async def test_get_non_existing_triggers(hass, device_reg, entity_reg, mqtt_mock
"""Test getting non existing triggers."""
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
# Discover a sensor (without device triggers)
data1 = (
@@ -140,7 +140,7 @@ async def test_discover_bad_triggers(hass, device_reg, entity_reg, mqtt_mock):
"""Test bad discovery message."""
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
# Test sending bad data
data0 = (
@@ -186,7 +186,7 @@ async def test_update_remove_triggers(hass, device_reg, entity_reg, mqtt_mock):
"""Test triggers can be updated and removed."""
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
data1 = (
'{ "automation_type":"trigger",'
@@ -243,7 +243,7 @@ async def test_if_fires_on_mqtt_message(hass, device_reg, calls, mqtt_mock):
"""Test triggers firing."""
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
data1 = (
'{ "automation_type":"trigger",'
@@ -322,7 +322,7 @@ async def test_if_fires_on_mqtt_message_late_discover(
"""Test triggers firing of MQTT device triggers discovered after setup."""
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
data0 = (
'{ "device":{"identifiers":["0AFFD2"]},'
@@ -409,7 +409,7 @@ async def test_if_fires_on_mqtt_message_after_update(
"""Test triggers firing after update."""
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
data1 = (
'{ "automation_type":"trigger",'
@@ -487,7 +487,7 @@ async def test_no_resubscribe_same_topic(hass, device_reg, mqtt_mock):
mock_mqtt = await async_mock_mqtt_component(hass)
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
data1 = (
'{ "automation_type":"trigger",'
@@ -535,7 +535,7 @@ async def test_not_fires_on_mqtt_message_after_remove_by_mqtt(
"""Test triggers not firing after removal."""
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
data1 = (
'{ "automation_type":"trigger",'
@@ -599,7 +599,7 @@ async def test_not_fires_on_mqtt_message_after_remove_from_registry(
"""Test triggers not firing after removal."""
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
data1 = (
'{ "automation_type":"trigger",'
@@ -653,7 +653,7 @@ async def test_attach_remove(hass, device_reg, mqtt_mock):
"""Test attach and removal of trigger."""
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
data1 = (
'{ "automation_type":"trigger",'
@@ -706,7 +706,7 @@ async def test_attach_remove_late(hass, device_reg, mqtt_mock):
"""Test attach and removal of trigger ."""
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
data0 = (
'{ "device":{"identifiers":["0AFFD2"]},'
@@ -767,7 +767,7 @@ async def test_attach_remove_late2(hass, device_reg, mqtt_mock):
"""Test attach and removal of trigger ."""
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
data0 = (
'{ "device":{"identifiers":["0AFFD2"]},'
@@ -822,7 +822,7 @@ async def test_entity_device_info_with_connection(hass, mqtt_mock):
"""Test MQTT device registry integration."""
entry = MockConfigEntry(domain=DOMAIN)
entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, entry)
await async_start(hass, "homeassistant", entry)
registry = await hass.helpers.device_registry.async_get_registry()
data = json.dumps(
@@ -856,7 +856,7 @@ async def test_entity_device_info_with_identifier(hass, mqtt_mock):
"""Test MQTT device registry integration."""
entry = MockConfigEntry(domain=DOMAIN)
entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, entry)
await async_start(hass, "homeassistant", entry)
registry = await hass.helpers.device_registry.async_get_registry()
data = json.dumps(
@@ -890,7 +890,7 @@ async def test_entity_device_info_update(hass, mqtt_mock):
"""Test device registry update."""
entry = MockConfigEntry(domain=DOMAIN)
entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, entry)
await async_start(hass, "homeassistant", entry)
registry = await hass.helpers.device_registry.async_get_registry()
config = {
@@ -930,7 +930,7 @@ async def test_cleanup_trigger(hass, device_reg, entity_reg, mqtt_mock):
"""Test trigger discovery topic is cleaned when device is removed from registry."""
config_entry = MockConfigEntry(domain=DOMAIN)
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
config = {
"automation_type": "trigger",
@@ -969,7 +969,7 @@ async def test_cleanup_device(hass, device_reg, entity_reg, mqtt_mock):
"""Test removal from device registry when trigger is removed."""
config_entry = MockConfigEntry(domain=DOMAIN)
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
config = {
"automation_type": "trigger",
@@ -1002,7 +1002,7 @@ async def test_cleanup_device_several_triggers(hass, device_reg, entity_reg, mqt
"""Test removal from device registry when the last trigger is removed."""
config_entry = MockConfigEntry(domain=DOMAIN)
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
config1 = {
"automation_type": "trigger",
@@ -1062,7 +1062,7 @@ async def test_cleanup_device_with_entity1(hass, device_reg, entity_reg, mqtt_mo
"""
config_entry = MockConfigEntry(domain=DOMAIN)
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
config1 = {
"automation_type": "trigger",
@@ -1118,7 +1118,7 @@ async def test_cleanup_device_with_entity2(hass, device_reg, entity_reg, mqtt_mo
"""
config_entry = MockConfigEntry(domain=DOMAIN)
config_entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, config_entry)
await async_start(hass, "homeassistant", config_entry)
config1 = {
"automation_type": "trigger",
@@ -1174,7 +1174,7 @@ async def test_trigger_debug_info(hass, mqtt_mock):
"""
entry = MockConfigEntry(domain=DOMAIN)
entry.add_to_hass(hass)
await async_start(hass, "homeassistant", {}, entry)
await async_start(hass, "homeassistant", entry)
registry = await hass.helpers.device_registry.async_get_registry()
config = {