From 802a95eac5c25c879e9dc780eee719ff8e83f37a Mon Sep 17 00:00:00 2001 From: Bob Anderson Date: Mon, 25 Dec 2017 04:26:22 -0800 Subject: [PATCH] Fix unpredictable entity names in concord232 binary_sensor (#11292) --- homeassistant/components/binary_sensor/concord232.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/homeassistant/components/binary_sensor/concord232.py b/homeassistant/components/binary_sensor/concord232.py index d689f030d8a..73cf77f2b93 100755 --- a/homeassistant/components/binary_sensor/concord232.py +++ b/homeassistant/components/binary_sensor/concord232.py @@ -62,6 +62,13 @@ def setup_platform(hass, config, add_devices, discovery_info=None): _LOGGER.error("Unable to connect to Concord232: %s", str(ex)) return False + # The order of zones returned by client.list_zones() can vary. + # When the zones are not named, this can result in the same entity + # name mapping to different sensors in an unpredictable way. Sort + # the zones by zone number to prevent this. + + client.zones.sort(key=lambda zone: zone['number']) + for zone in client.zones: _LOGGER.info("Loading Zone found: %s", zone['name']) if zone['number'] not in exclude: