Migrate konnected to use async_forward_entry_setups (#86565)

* Migrate konnected to use async_forward_entry_setups

Replaces deprecated async_setup_platforms with async_forward_entry_setups

* update tests
This commit is contained in:
J. Nick Koston 2023-01-24 23:19:23 -10:00 committed by GitHub
parent 5285d057d2
commit 1a2652e1bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 55 additions and 13 deletions

View File

@ -259,7 +259,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
# async_connect will handle retries until it establishes a connection
await client.async_connect()
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
# config entry specific data to enable unload
hass.data[DOMAIN][entry.entry_id] = {

View File

@ -151,16 +151,25 @@ async def test_create_and_setup(hass, mock_panel):
}
# confirm the device settings are saved in hass.data
# This test should not access hass.data since its integration internals
assert device.stored_configuration == {
"binary_sensors": {
"1": {
"entity_id": "binary_sensor.konnected_445566_zone_1",
"inverse": False,
"name": "Konnected 445566 Zone 1",
"state": None,
"type": "door",
},
"2": {"inverse": True, "name": "winder", "state": None, "type": "window"},
"2": {
"entity_id": "binary_sensor.winder",
"inverse": True,
"name": "winder",
"state": None,
"type": "window",
},
"3": {
"entity_id": "binary_sensor.konnected_445566_zone_3",
"inverse": False,
"name": "Konnected 445566 Zone 3",
"state": None,
@ -168,14 +177,16 @@ async def test_create_and_setup(hass, mock_panel):
},
},
"blink": True,
"panel": device,
"discovery": True,
"host": "1.2.3.4",
"panel": device,
"port": 1234,
"sensors": [
{
"humidity": "sensor.konnected_445566_sensor_4_humidity",
"name": "Konnected 445566 Sensor 4",
"poll_interval": 3,
"temperature": "sensor.konnected_445566_sensor_4_temperature",
"type": "dht",
"zone": "4",
},
@ -184,6 +195,7 @@ async def test_create_and_setup(hass, mock_panel):
"switches": [
{
"activation": "low",
"entity_id": "switch.switcher",
"momentary": 50,
"name": "switcher",
"pause": 100,
@ -193,6 +205,7 @@ async def test_create_and_setup(hass, mock_panel):
},
{
"activation": "high",
"entity_id": "switch.konnected_445566_actuator_6",
"momentary": None,
"name": "Konnected 445566 Actuator 6",
"pause": None,
@ -307,37 +320,49 @@ async def test_create_and_setup_pro(hass, mock_panel):
}
# confirm the device settings are saved in hass.data
# hass.data should not be accessed in tests as its considered integration internals
assert device.stored_configuration == {
"binary_sensors": {
"11": {
"inverse": False,
"name": "Konnected 445566 Zone 11",
"state": None,
"type": "window",
},
"10": {
"entity_id": "binary_sensor.konnected_445566_zone_10",
"inverse": False,
"name": "Konnected 445566 Zone 10",
"state": None,
"type": "door",
},
"11": {
"entity_id": "binary_sensor.konnected_445566_zone_11",
"inverse": False,
"name": "Konnected 445566 Zone 11",
"state": None,
"type": "window",
},
"2": {
"entity_id": "binary_sensor.konnected_445566_zone_2",
"inverse": False,
"name": "Konnected 445566 Zone 2",
"state": None,
"type": "door",
},
"6": {"inverse": True, "name": "winder", "state": None, "type": "window"},
"6": {
"entity_id": "binary_sensor.winder",
"inverse": True,
"name": "winder",
"state": None,
"type": "window",
},
},
"blink": True,
"panel": device,
"discovery": True,
"host": "1.2.3.4",
"panel": device,
"port": 1234,
"sensors": [
{
"humidity": "sensor.konnected_445566_sensor_3_humidity",
"name": "Konnected 445566 Sensor 3",
"poll_interval": 5,
"temperature": "sensor.konnected_445566_sensor_3_temperature",
"type": "dht",
"zone": "3",
},
@ -346,6 +371,7 @@ async def test_create_and_setup_pro(hass, mock_panel):
"switches": [
{
"activation": "high",
"entity_id": "switch.konnected_445566_actuator_4",
"momentary": None,
"name": "Konnected 445566 Actuator 4",
"pause": None,
@ -355,6 +381,7 @@ async def test_create_and_setup_pro(hass, mock_panel):
},
{
"activation": "low",
"entity_id": "switch.switcher",
"momentary": 50,
"name": "switcher",
"pause": 100,
@ -364,6 +391,7 @@ async def test_create_and_setup_pro(hass, mock_panel):
},
{
"activation": "high",
"entity_id": "switch.konnected_445566_actuator_out1",
"momentary": None,
"name": "Konnected 445566 Actuator out1",
"pause": None,
@ -373,6 +401,7 @@ async def test_create_and_setup_pro(hass, mock_panel):
},
{
"activation": "high",
"entity_id": "switch.konnected_445566_actuator_alarm1",
"momentary": None,
"name": "Konnected 445566 Actuator alarm1",
"pause": None,
@ -495,16 +524,25 @@ async def test_default_options(hass, mock_panel):
}
# confirm the device settings are saved in hass.data
# This test should not access hass.data since its integration internals
assert device.stored_configuration == {
"binary_sensors": {
"1": {
"entity_id": "binary_sensor.konnected_445566_zone_1",
"inverse": False,
"name": "Konnected 445566 Zone 1",
"state": None,
"type": "door",
},
"2": {"inverse": True, "name": "winder", "state": None, "type": "window"},
"2": {
"entity_id": "binary_sensor.winder",
"inverse": True,
"name": "winder",
"state": None,
"type": "window",
},
"3": {
"entity_id": "binary_sensor.konnected_445566_zone_3",
"inverse": False,
"name": "Konnected 445566 Zone 3",
"state": None,
@ -512,14 +550,16 @@ async def test_default_options(hass, mock_panel):
},
},
"blink": True,
"panel": device,
"discovery": True,
"host": "1.2.3.4",
"panel": device,
"port": 1234,
"sensors": [
{
"humidity": "sensor.konnected_445566_sensor_4_humidity",
"name": "Konnected 445566 Sensor 4",
"poll_interval": 3,
"temperature": "sensor.konnected_445566_sensor_4_temperature",
"type": "dht",
"zone": "4",
},
@ -528,6 +568,7 @@ async def test_default_options(hass, mock_panel):
"switches": [
{
"activation": "low",
"entity_id": "switch.switcher",
"momentary": 50,
"name": "switcher",
"pause": 100,
@ -537,6 +578,7 @@ async def test_default_options(hass, mock_panel):
},
{
"activation": "high",
"entity_id": "switch.konnected_445566_actuator_6",
"momentary": None,
"name": "Konnected 445566 Actuator 6",
"pause": None,