From 3d79bf2bfe78b7b925ee26e4ba18e9e59c0fb514 Mon Sep 17 00:00:00 2001 From: Troels Agergaard Jacobsen Date: Thu, 23 May 2019 19:27:42 +0200 Subject: [PATCH] Fix entity id naming when not using first install (#23606) * Fix entity id naming when not using first install Currently, the verisure component will use the alias of the first installation to decide entity id of the alarm_control_panel even though a different installation is configured through a specified giid. This fixes that * Fixed pulled request review comments * Remove trailing whitespace * Fix remaining pylint errors --- .../components/verisure/alarm_control_panel.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/verisure/alarm_control_panel.py b/homeassistant/components/verisure/alarm_control_panel.py index dc73be056db..53c79098782 100644 --- a/homeassistant/components/verisure/alarm_control_panel.py +++ b/homeassistant/components/verisure/alarm_control_panel.py @@ -6,7 +6,7 @@ import homeassistant.components.alarm_control_panel as alarm from homeassistant.const import ( STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED) -from . import CONF_ALARM, CONF_CODE_DIGITS, HUB as hub +from . import CONF_ALARM, CONF_CODE_DIGITS, CONF_GIID, HUB as hub _LOGGER = logging.getLogger(__name__) @@ -45,6 +45,14 @@ class VerisureAlarm(alarm.AlarmControlPanel): @property def name(self): """Return the name of the device.""" + giid = hub.config.get(CONF_GIID) + if giid is not None: + aliass = {i['giid']: i['alias'] for i in hub.session.installations} + if giid in aliass.keys(): + return '{} alarm'.format(aliass[giid]) + + _LOGGER.error('Verisure installation giid not found: %s', giid) + return '{} alarm'.format(hub.session.installations[0]['alias']) @property