From 304b9f47b423243ba5a1ec25c201c05206083c7c Mon Sep 17 00:00:00 2001 From: Glenn Waters Date: Sun, 18 Oct 2020 20:48:20 -0400 Subject: [PATCH] ElkM1 fix auto-configure. (#42064) The elkm1-lib autoconfigure set the `configured` flag based on an attribute of the element being changed. This approach misses counters and thermostats. It also does not work well well an "unconfigured" element's default value is different from what is on the panel. This was the case for zones (the `area` attribute was different). The fix in the library is to mark an element as `configured` when the element has a name associated with it. This change is technically breaking, although I imagine, few if any people will be affected as (1) they configure names on all elements (2) the functionality was not working properly, so element would not be missing. The HA docs will be updated to add a section on autoconfigure. It will describe that to have an element automatically configured then the element must be configured on the ElkM1 panel with a name. This particular patch is required for ElkM1 areas. The existing logic assumes that an area is configured if it has an associated keypad. Not all areas have keypads (I have an area only armable with HA). The library fix should catch all configured areas. --- .../components/elkm1/alarm_control_panel.py | 13 ++----------- homeassistant/components/elkm1/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/elkm1/alarm_control_panel.py b/homeassistant/components/elkm1/alarm_control_panel.py index 88b307ab4c0..8f752cd9adf 100644 --- a/homeassistant/components/elkm1/alarm_control_panel.py +++ b/homeassistant/components/elkm1/alarm_control_panel.py @@ -60,18 +60,9 @@ SERVICE_ALARM_CLEAR_BYPASS = "alarm_clear_bypass" async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the ElkM1 alarm platform.""" elk_data = hass.data[DOMAIN][config_entry.entry_id] - entities = [] - elk = elk_data["elk"] - areas_with_keypad = set() - for keypad in elk.keypads: - areas_with_keypad.add(keypad.area) - - areas = [] - for area in elk.areas: - if area.index in areas_with_keypad or elk_data["auto_configure"] is False: - areas.append(area) - create_elk_entities(elk_data, areas, "area", ElkArea, entities) + entities = [] + create_elk_entities(elk_data, elk.areas, "area", ElkArea, entities) async_add_entities(entities, True) platform = entity_platform.current_platform.get() diff --git a/homeassistant/components/elkm1/manifest.json b/homeassistant/components/elkm1/manifest.json index 18e58101cbe..0e6fdcfa40c 100644 --- a/homeassistant/components/elkm1/manifest.json +++ b/homeassistant/components/elkm1/manifest.json @@ -2,7 +2,7 @@ "domain": "elkm1", "name": "Elk-M1 Control", "documentation": "https://www.home-assistant.io/integrations/elkm1", - "requirements": ["elkm1-lib==0.8.3"], + "requirements": ["elkm1-lib==0.8.4"], "codeowners": ["@gwww", "@bdraco"], "config_flow": true } diff --git a/requirements_all.txt b/requirements_all.txt index 490e38cc68e..08dd8200a56 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -535,7 +535,7 @@ elgato==0.2.0 eliqonline==1.2.2 # homeassistant.components.elkm1 -elkm1-lib==0.8.3 +elkm1-lib==0.8.4 # homeassistant.components.mobile_app emoji==0.5.4 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index c9e4db612ba..d3382accb3c 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -278,7 +278,7 @@ eebrightbox==0.0.4 elgato==0.2.0 # homeassistant.components.elkm1 -elkm1-lib==0.8.3 +elkm1-lib==0.8.4 # homeassistant.components.mobile_app emoji==0.5.4