From d0b68def667d5af05990519f2c975b58b7037cc5 Mon Sep 17 00:00:00 2001 From: Bob Anderson Date: Sun, 24 Dec 2017 09:50:56 -0800 Subject: [PATCH] fix for unpredictable mapping of entity names to sensors --- 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 d689f030d8a7b3..73cf77f2b93601 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: