From be3064a0498577c901c395f2b700461c61c590bf Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 12:48:00 -0400 Subject: [PATCH 01/32] Setup all-linking service --- homeassistant/components/insteon_plm.py | 24 +++++++++++++++++++++++- homeassistant/components/services.yaml | 11 +++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index d867f0c3d28c8..9d1830c34e0b3 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -11,7 +11,8 @@ from homeassistant.core import callback from homeassistant.const import (CONF_PORT, EVENT_HOMEASSISTANT_STOP, - CONF_PLATFORM) + CONF_PLATFORM, + CONF_ENTITY_ID) import homeassistant.helpers.config_validation as cv from homeassistant.helpers import discovery from homeassistant.helpers.entity import Entity @@ -28,6 +29,9 @@ CONF_SUBCAT = 'subcat' CONF_FIRMWARE = 'firmware' CONF_PRODUCT_KEY = 'product_key' +SRV_START_ALL_LINK = 'start_all_linking' +SRV_ALL_LINK_GROUP = 'group' +SRV_ALL_LINK_MODE = 'mode' CONF_DEVICE_OVERRIDE_SCHEMA = vol.All( cv.deprecated(CONF_PLATFORM), vol.Schema({ @@ -47,6 +51,11 @@ }) }, extra=vol.ALLOW_EXTRA) +START_ALL_LINK_SCHEMA = vol.Schema({ + vol.Required(SRV_ALL_LINK_GROUP): vol.Range(min=0, max=255), + vol.Required(SRV_ALL_LINK_MODE): vol.In(['C', 'R', 'c', 'r']), +}) + @asyncio.coroutine def async_setup(hass, config): @@ -54,6 +63,7 @@ def async_setup(hass, config): import insteonplm ipdb = IPDB() + plm = None conf = config[DOMAIN] port = conf.get(CONF_PORT) @@ -78,6 +88,17 @@ def async_plm_new_device(device): discovered={'address': device.address.hex, 'state_key': state_key}, hass_config=config)) + def start_all_linking(service): + """Start the INSTEON All-Linking process.""" + group = service.data.get(SRV_ALL_LINK_GROUP) + mode = service.data.get(SRV_ALL_LINK_MODE) + link_mode = 1 if mode.lower() == 'c' else 0 + plm.start_all_linking(link_mode, group) + + def _register_services(): + hass.services.register(DOMAIN, SRV_START_ALL_LINK, start_all_linking, + schema=START_ALL_LINK_SCHEMA) + _LOGGER.debug("Insteon_plm Services registered") _LOGGER.info("Looking for PLM on %s", port) conn = yield from insteonplm.Connection.create( @@ -105,6 +126,7 @@ def async_plm_new_device(device): hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, conn.close) plm.devices.add_device_callback(async_plm_new_device) + hass.async_add_job(_register_services) return True diff --git a/homeassistant/components/services.yaml b/homeassistant/components/services.yaml index 746c3c7f4838f..cda45e2a1e661 100644 --- a/homeassistant/components/services.yaml +++ b/homeassistant/components/services.yaml @@ -556,3 +556,14 @@ xiaomi_aqara: device_id: description: Hardware address of the device to remove. example: 158d0000000000 +insteon_plm: + start_all_linking: + description: Put the PLM into All-Linking mode. Once the the PLM is in All-Linking mode, press the link button on the device to complete All-Linking. + fields: + group: + description: All-Link group number. + example: 1 + mode: + description: Linking mode \n\tC - PLM is controler \n\tR - PLM is responder + example: C +i \ No newline at end of file From 55798c6fda9e50a010ed6d38db0b273cdf548bb7 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 12:52:46 -0400 Subject: [PATCH 02/32] Remove extra line --- homeassistant/components/services.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/homeassistant/components/services.yaml b/homeassistant/components/services.yaml index cda45e2a1e661..e9c8eb13547ed 100644 --- a/homeassistant/components/services.yaml +++ b/homeassistant/components/services.yaml @@ -566,4 +566,3 @@ insteon_plm: mode: description: Linking mode \n\tC - PLM is controler \n\tR - PLM is responder example: C -i \ No newline at end of file From 4d9d25d471e6c06ca12ca2d8d4202e88e794bd90 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 13:03:14 -0400 Subject: [PATCH 03/32] Remove linefeed and tab escape chars --- homeassistant/components/services.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/services.yaml b/homeassistant/components/services.yaml index e9c8eb13547ed..5a2346a55c7a6 100644 --- a/homeassistant/components/services.yaml +++ b/homeassistant/components/services.yaml @@ -564,5 +564,5 @@ insteon_plm: description: All-Link group number. example: 1 mode: - description: Linking mode \n\tC - PLM is controler \n\tR - PLM is responder - example: C + description: Linking mode C - PLM is controler R - PLM is responder + example: 'C' From eda460c1792f9caf3171227d92f66fde5ab02649 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 17:05:56 -0400 Subject: [PATCH 04/32] Add services delete_all_link, load_all_link_database and print_all_link_database --- homeassistant/components/insteon_plm.py | 91 ++++++++++++++++++++++--- homeassistant/components/services.yaml | 27 +++++++- 2 files changed, 107 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index 9d1830c34e0b3..25192229dba76 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -29,9 +29,14 @@ CONF_SUBCAT = 'subcat' CONF_FIRMWARE = 'firmware' CONF_PRODUCT_KEY = 'product_key' -SRV_START_ALL_LINK = 'start_all_linking' + +SRV_ADD_ALL_LINK = 'add_all_link' +SRV_DEL_ALL_LINK = 'delete_all_link' +SRV_LOAD_ALDB = 'load_all_link_database' +SRV_PRINT_ALDB = 'print_all_link_database' SRV_ALL_LINK_GROUP = 'group' SRV_ALL_LINK_MODE = 'mode' +SRV_LOAD_DB_RELOAD = 'reload' CONF_DEVICE_OVERRIDE_SCHEMA = vol.All( cv.deprecated(CONF_PLATFORM), vol.Schema({ @@ -51,10 +56,24 @@ }) }, extra=vol.ALLOW_EXTRA) -START_ALL_LINK_SCHEMA = vol.Schema({ +ADD_ALL_LINK_SCHEMA = vol.Schema({ + vol.Required(SRV_ALL_LINK_GROUP): vol.Range(min=0, max=255), + vol.Required(SRV_ALL_LINK_MODE): vol.In(['C', 'R', + 'c', 'r']), + }) + +DEL_ALL_LINK_SCHEMA = vol.Schema({ vol.Required(SRV_ALL_LINK_GROUP): vol.Range(min=0, max=255), - vol.Required(SRV_ALL_LINK_MODE): vol.In(['C', 'R', 'c', 'r']), -}) + }) + +LOAD_ALDB_SCHEMA = vol.Schema({ + vol.Required(CONF_ENTITY_ID): cv.entity_id, + vol.Optional(SRV_ALL_LINK_MODE, default='n'): vol.In(['Y', 'N', 'y', 'n']), + }) + +PRINT_ALDB_SCHEMA = vol.Schema({ + vol.Required(CONF_ENTITY_ID): cv.entity_id, + }) @asyncio.coroutine @@ -88,16 +107,46 @@ def async_plm_new_device(device): discovered={'address': device.address.hex, 'state_key': state_key}, hass_config=config)) - def start_all_linking(service): - """Start the INSTEON All-Linking process.""" + + def add_all_link(service): + """Add an INSTEON All-Link between two devices.""" group = service.data.get(SRV_ALL_LINK_GROUP) mode = service.data.get(SRV_ALL_LINK_MODE) link_mode = 1 if mode.lower() == 'c' else 0 plm.start_all_linking(link_mode, group) + def del_all_link(service): + """Delete an INSTEON All-Link between two devices.""" + group = service.data.get(SRV_ALL_LINK_GROUP) + plm.start_all_linking(255, group) + + def load_aldb(service): + """Load the device All-Link database.""" + entity_id = service.data.get(CONF_ENTITY_ID) + reload = service.data.get(SRV_LOAD_DB_RELOAD) + db_reload = True if reload.lower() == 'y' else False + entity = hass.states.get(entity_id) + if entity and isinstance(InsteonPLMEntity): + entity.load_aldb(db_reload) + + def print_aldb(service): + """Print the All-Link Database for a device.""" + # For now this sends logs to the log file. + # Furture direction is to create an INSTEON control panel. + entity_id = service.data.get(CONF_ENTITY_ID) + entity = hass.states.get(entity_id) + if entity and isinstance(InsteonPLMEntity): + entity.print_aldb() + def _register_services(): - hass.services.register(DOMAIN, SRV_START_ALL_LINK, start_all_linking, - schema=START_ALL_LINK_SCHEMA) + hass.services.register(DOMAIN, SRV_ADD_ALL_LINK, add_all_link, + schema=ADD_ALL_LINK_SCHEMA) + hass.services.register(DOMAIN, SRV_DEL_ALL_LINK, del_all_link, + schema=DEL_ALL_LINK_SCHEMA) + hass.services.register(DOMAIN, SRV_LOAD_ALDB, load_aldb, + schema=LOAD_ALDB_SCHEMA) + hass.services.register(DOMAIN, SRV_PRINT_ALDB, print_aldb, + schema=PRINT_ALDB_SCHEMA) _LOGGER.debug("Insteon_plm Services registered") _LOGGER.info("Looking for PLM on %s", port) @@ -191,6 +240,7 @@ def __init__(self, device, state_key): """Initialize the INSTEON PLM binary sensor.""" self._insteon_device_state = device.states[state_key] self._insteon_device = device + self._insteon_device.aldb.add_loaded_callback(self._aldb_loaded) @property def should_poll(self): @@ -237,3 +287,28 @@ def async_added_to_hass(self): """Register INSTEON update events.""" self._insteon_device_state.register_updates( self.async_entity_update) + + def load_aldb(self, reload=False): + """Load the device All-Link Database.""" + if reload: + self._insteon_device.aldb.clear() + self._insteon_device.read_aldb() + + def print_aldb(self): + """Print the device ALDB to the log file.""" + from insteonplm.devices import ALDBStatus + _LOGGER.info('ALDB load status for device %s is %s', + self.address, self._insteon_device.aldb.status.name) + if self._insteon_device.aldb.status in [ALDBStatus.LOADED, + ALDBStatus.Partial]: + for mem_addr in self._insteon_device.aldb: + rec = self._insteon_device.aldb + _LOGGER.info(rec) + else: + _LOGGER.warning('Device All-Link database not loaded') + _LOGGER.warning('Use service insteon_plm.load_aldb first') + + @callback + def _aldb_loaded(self): + """All-Link Database loaded for the device.""" + self.print_aldb() diff --git a/homeassistant/components/services.yaml b/homeassistant/components/services.yaml index 5a2346a55c7a6..2958028693bd1 100644 --- a/homeassistant/components/services.yaml +++ b/homeassistant/components/services.yaml @@ -557,12 +557,33 @@ xiaomi_aqara: description: Hardware address of the device to remove. example: 158d0000000000 insteon_plm: - start_all_linking: - description: Put the PLM into All-Linking mode. Once the the PLM is in All-Linking mode, press the link button on the device to complete All-Linking. + add_all_link: + description: Tells the Insteom Modem (IM) start All-Linking mode. Once the the IM is in All-Linking mode, press the link button on the device to complete All-Linking. fields: group: description: All-Link group number. example: 1 mode: - description: Linking mode C - PLM is controler R - PLM is responder + description: Linking mode C - IM is controler R - IM is responder example: 'C' + delete_all_link: + description: Tells the Insteon Modem (IM) to remove an All-Link record from the All-Link Database of the IM and a device. Once the IM is set to delete the link, press the link button on the corresponding device to complete the process. + fields: + group: + description: All-Link group number. + example: 1 + load_all_link_database: + description: Load the All-Link Database for a device. WARNING - Loading a device All-LInk database is very time consuming and inconsistant. This may take a LONG time and may need to be repeated to obtain all records. + fields: + entity_id: + description: Name of the device to print + example: 'light.1a2b3c' + reload: + description: Reload all records. If Y the current records are cleared from memory (does not effect the device) and the records are reloaded. If N the existing records are left in place and only missing records are added. Default is N. + example: N + print_all_link_database: + description: Print the All-Link Database for a device. Requires that the All-Link Database is loaded into memory. + fields: + entity_id: + description: Name of the device to print + example: 'light.1a2b3c' From e81872c5ff6be03a5fb2c15b952d1db762d3df1d Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 17:14:13 -0400 Subject: [PATCH 05/32] Check if reload is set --- homeassistant/components/insteon_plm.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index 25192229dba76..1361368c64c6a 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -124,7 +124,9 @@ def load_aldb(service): """Load the device All-Link database.""" entity_id = service.data.get(CONF_ENTITY_ID) reload = service.data.get(SRV_LOAD_DB_RELOAD) - db_reload = True if reload.lower() == 'y' else False + db_reload = False + if reload: + db_reload = True if reload.lower() == 'y' else False entity = hass.states.get(entity_id) if entity and isinstance(InsteonPLMEntity): entity.load_aldb(db_reload) From 145e849ac385c7eb9ec492e1ece5a14bbc0e7302 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 17:21:21 -0400 Subject: [PATCH 06/32] Confirm entity is InsteonPLMEntity before attempting to load or print ALDB --- homeassistant/components/insteon_plm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index 1361368c64c6a..df8b791553f61 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -128,7 +128,7 @@ def load_aldb(service): if reload: db_reload = True if reload.lower() == 'y' else False entity = hass.states.get(entity_id) - if entity and isinstance(InsteonPLMEntity): + if entity and isinstance(entity, InsteonPLMEntity): entity.load_aldb(db_reload) def print_aldb(service): @@ -137,7 +137,7 @@ def print_aldb(service): # Furture direction is to create an INSTEON control panel. entity_id = service.data.get(CONF_ENTITY_ID) entity = hass.states.get(entity_id) - if entity and isinstance(InsteonPLMEntity): + if entity and isinstance(entity, InsteonPLMEntity): entity.print_aldb() def _register_services(): From 5fe240acddb3a1b5a38023545e94bc3661ef4369 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 17:31:42 -0400 Subject: [PATCH 07/32] Debug load and print ALDB --- homeassistant/components/insteon_plm.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index df8b791553f61..53f078d5bea9f 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -130,6 +130,10 @@ def load_aldb(service): entity = hass.states.get(entity_id) if entity and isinstance(entity, InsteonPLMEntity): entity.load_aldb(db_reload) + else: + _LOGGER.error('Entity is not an insteon_plm entity') + _LOGGER.debug(entity_id) + _LOGGER.debug(entity) def print_aldb(service): """Print the All-Link Database for a device.""" @@ -139,6 +143,10 @@ def print_aldb(service): entity = hass.states.get(entity_id) if entity and isinstance(entity, InsteonPLMEntity): entity.print_aldb() + else: + _LOGGER.error('Entity is not an insteon_plm entity') + _LOGGER.debug(entity_id) + _LOGGER.debug(entity) def _register_services(): hass.services.register(DOMAIN, SRV_ADD_ALL_LINK, add_all_link, From ce35e0728fa88d0fee6c9817d5bbe89a8202b218 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 18:42:35 -0400 Subject: [PATCH 08/32] Debug print aldb --- homeassistant/components/insteon_plm.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index 53f078d5bea9f..ad1bdb8115f8a 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -16,6 +16,7 @@ import homeassistant.helpers.config_validation as cv from homeassistant.helpers import discovery from homeassistant.helpers.entity import Entity +from homeassistant.loader import get_component REQUIREMENTS = ['insteonplm==0.8.6'] @@ -122,18 +123,22 @@ def del_all_link(service): def load_aldb(service): """Load the device All-Link database.""" + from insteonplm.address import Address entity_id = service.data.get(CONF_ENTITY_ID) reload = service.data.get(SRV_LOAD_DB_RELOAD) db_reload = False if reload: db_reload = True if reload.lower() == 'y' else False entity = hass.states.get(entity_id) - if entity and isinstance(entity, InsteonPLMEntity): - entity.load_aldb(db_reload) - else: - _LOGGER.error('Entity is not an insteon_plm entity') - _LOGGER.debug(entity_id) - _LOGGER.debug(entity) + if entity: + addr = entity.attributes.get('INSTEON Address') + if addr: + insteon_address = address(addr) + device = plm.devices[insteon_address.hex] + device.load_aldb(db_reload) + else: + _LOGGER.error('Entity is not an insteon_plm entity') + _LOGGER.debug(entity) def print_aldb(service): """Print the All-Link Database for a device.""" @@ -141,6 +146,8 @@ def print_aldb(service): # Furture direction is to create an INSTEON control panel. entity_id = service.data.get(CONF_ENTITY_ID) entity = hass.states.get(entity_id) + insteon_plm_component = get_component(DOMAIN) + _LOGGER.debug(dir(insteon_plm_component)) if entity and isinstance(entity, InsteonPLMEntity): entity.print_aldb() else: From 2378f3ae16d4acf917e1325c5ddd514b8253ffc6 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 19:04:03 -0400 Subject: [PATCH 09/32] Debug print_aldb --- homeassistant/components/insteon_plm.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index ad1bdb8115f8a..f919b767b2e81 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -146,8 +146,7 @@ def print_aldb(service): # Furture direction is to create an INSTEON control panel. entity_id = service.data.get(CONF_ENTITY_ID) entity = hass.states.get(entity_id) - insteon_plm_component = get_component(DOMAIN) - _LOGGER.debug(dir(insteon_plm_component)) + _LOGGER.debug(dir(service.data)) if entity and isinstance(entity, InsteonPLMEntity): entity.print_aldb() else: From e805acdaaede79f8077d427fccac3d8a290b0ca9 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 20:22:23 -0400 Subject: [PATCH 10/32] Get entity via platform --- homeassistant/components/insteon_plm.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index f919b767b2e81..b5baea7282436 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -23,6 +23,11 @@ _LOGGER = logging.getLogger(__name__) DOMAIN = 'insteon_plm' +PLATFORMS = ['binary_sensor', + 'fan', + 'light', + 'sensor', + 'switch'] CONF_OVERRIDE = 'device_override' CONF_ADDRESS = 'address' @@ -145,9 +150,13 @@ def print_aldb(service): # For now this sends logs to the log file. # Furture direction is to create an INSTEON control panel. entity_id = service.data.get(CONF_ENTITY_ID) - entity = hass.states.get(entity_id) - _LOGGER.debug(dir(service.data)) - if entity and isinstance(entity, InsteonPLMEntity): + entity = None + for str_platform in PLATFORMS: + platform = get_component(str_platform) + entity = platform.get_entity(entity_id) + if entity: + break + if isinstance(entity, InsteonPLMEntity): entity.print_aldb() else: _LOGGER.error('Entity is not an insteon_plm entity') From 603fcdb16f08fd577d8f1e8b30f23ff6ebea712f Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 21:40:49 -0400 Subject: [PATCH 11/32] Track Insteon entities in component --- homeassistant/components/insteon_plm.py | 37 +++++++++---------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index b5baea7282436..b11ce78b6ef07 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -23,11 +23,6 @@ _LOGGER = logging.getLogger(__name__) DOMAIN = 'insteon_plm' -PLATFORMS = ['binary_sensor', - 'fan', - 'light', - 'sensor', - 'switch'] CONF_OVERRIDE = 'device_override' CONF_ADDRESS = 'address' @@ -89,6 +84,7 @@ def async_setup(hass, config): ipdb = IPDB() plm = None + entities = {} conf = config[DOMAIN] port = conf.get(CONF_PORT) @@ -134,34 +130,24 @@ def load_aldb(service): db_reload = False if reload: db_reload = True if reload.lower() == 'y' else False - entity = hass.states.get(entity_id) + insteon_plm = get_component(DOMAIN) + entity = insteon_plm.entities[entity_id] if entity: - addr = entity.attributes.get('INSTEON Address') - if addr: - insteon_address = address(addr) - device = plm.devices[insteon_address.hex] - device.load_aldb(db_reload) - else: - _LOGGER.error('Entity is not an insteon_plm entity') - _LOGGER.debug(entity) + entity.print_aldb() + else: + _LOGGER.error('Entity %s is not an INSTEON device', entity_id) def print_aldb(service): """Print the All-Link Database for a device.""" # For now this sends logs to the log file. # Furture direction is to create an INSTEON control panel. entity_id = service.data.get(CONF_ENTITY_ID) - entity = None - for str_platform in PLATFORMS: - platform = get_component(str_platform) - entity = platform.get_entity(entity_id) - if entity: - break - if isinstance(entity, InsteonPLMEntity): + insteon_plm = get_component(DOMAIN) + entity = insteon_plm.entities[entity_id] + if entity: entity.print_aldb() else: - _LOGGER.error('Entity is not an insteon_plm entity') - _LOGGER.debug(entity_id) - _LOGGER.debug(entity) + _LOGGER.error('Entity %s is not an INSTEON device', entity_id) def _register_services(): hass.services.register(DOMAIN, SRV_ADD_ALL_LINK, add_all_link, @@ -312,6 +298,9 @@ def async_added_to_hass(self): """Register INSTEON update events.""" self._insteon_device_state.register_updates( self.async_entity_update) + insteon_plm = get_component(DOMAIN) + insteon_plm.entities[self.entity_id] = self + def load_aldb(self, reload=False): """Load the device All-Link Database.""" From adc1073e67b4c039fec4ce58d2fd252c838563b4 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 21:59:00 -0400 Subject: [PATCH 12/32] Store entity list in hass.data --- .../components/binary_sensor/insteon_plm.py | 2 +- homeassistant/components/fan/insteon_plm.py | 2 +- homeassistant/components/insteon_plm.py | 17 ++++++++--------- homeassistant/components/light/insteon_plm.py | 2 +- homeassistant/components/sensor/insteon_plm.py | 2 +- homeassistant/components/switch/insteon_plm.py | 2 +- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/binary_sensor/insteon_plm.py b/homeassistant/components/binary_sensor/insteon_plm.py index 06079d6aa3bcf..9cb87b317499a 100644 --- a/homeassistant/components/binary_sensor/insteon_plm.py +++ b/homeassistant/components/binary_sensor/insteon_plm.py @@ -23,7 +23,7 @@ @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up the INSTEON PLM device class for the hass platform.""" - plm = hass.data['insteon_plm'] + plm = hass.data['insteon_plm'].get('plm') address = discovery_info['address'] device = plm.devices[address] diff --git a/homeassistant/components/fan/insteon_plm.py b/homeassistant/components/fan/insteon_plm.py index f30abdbaa3078..0911295d090cf 100644 --- a/homeassistant/components/fan/insteon_plm.py +++ b/homeassistant/components/fan/insteon_plm.py @@ -31,7 +31,7 @@ @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up the INSTEON PLM device class for the hass platform.""" - plm = hass.data['insteon_plm'] + plm = hass.data['insteon_plm'].get('plm') address = discovery_info['address'] device = plm.devices[address] diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index b11ce78b6ef07..82e908f873f67 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -84,7 +84,6 @@ def async_setup(hass, config): ipdb = IPDB() plm = None - entities = {} conf = config[DOMAIN] port = conf.get(CONF_PORT) @@ -124,16 +123,15 @@ def del_all_link(service): def load_aldb(service): """Load the device All-Link database.""" - from insteonplm.address import Address entity_id = service.data.get(CONF_ENTITY_ID) reload = service.data.get(SRV_LOAD_DB_RELOAD) db_reload = False if reload: db_reload = True if reload.lower() == 'y' else False - insteon_plm = get_component(DOMAIN) - entity = insteon_plm.entities[entity_id] + entities = hass.data[DOMAIN].get('entities') + entity = entities.get(entity_id) if entity: - entity.print_aldb() + entity.load_aldb(db_reload) else: _LOGGER.error('Entity %s is not an INSTEON device', entity_id) @@ -142,8 +140,8 @@ def print_aldb(service): # For now this sends logs to the log file. # Furture direction is to create an INSTEON control panel. entity_id = service.data.get(CONF_ENTITY_ID) - insteon_plm = get_component(DOMAIN) - entity = insteon_plm.entities[entity_id] + entities = hass.data[DOMAIN].get('entities') + entity = entities.get(entity_id) if entity: entity.print_aldb() else: @@ -181,7 +179,9 @@ def _register_services(): plm.devices.add_override(address, CONF_PRODUCT_KEY, device_override[prop]) - hass.data['insteon_plm'] = plm + hass.data[DOMAIN] = {} + hass.data[DOMAIN]['plm'] = plm + hass.data[DOMAIN]['entities'] = {} hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, conn.close) @@ -301,7 +301,6 @@ def async_added_to_hass(self): insteon_plm = get_component(DOMAIN) insteon_plm.entities[self.entity_id] = self - def load_aldb(self, reload=False): """Load the device All-Link Database.""" if reload: diff --git a/homeassistant/components/light/insteon_plm.py b/homeassistant/components/light/insteon_plm.py index 40453da38e54a..8a3b463c2bd08 100644 --- a/homeassistant/components/light/insteon_plm.py +++ b/homeassistant/components/light/insteon_plm.py @@ -21,7 +21,7 @@ @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up the Insteon PLM device.""" - plm = hass.data['insteon_plm'] + plm = hass.data['insteon_plm'].get('plm') address = discovery_info['address'] device = plm.devices[address] diff --git a/homeassistant/components/sensor/insteon_plm.py b/homeassistant/components/sensor/insteon_plm.py index a72b8efbc0525..61f5877ed7815 100644 --- a/homeassistant/components/sensor/insteon_plm.py +++ b/homeassistant/components/sensor/insteon_plm.py @@ -18,7 +18,7 @@ @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up the INSTEON PLM device class for the hass platform.""" - plm = hass.data['insteon_plm'] + plm = hass.data['insteon_plm'].get('plm') address = discovery_info['address'] device = plm.devices[address] diff --git a/homeassistant/components/switch/insteon_plm.py b/homeassistant/components/switch/insteon_plm.py index 5f9482ce95530..be562e9d909d6 100644 --- a/homeassistant/components/switch/insteon_plm.py +++ b/homeassistant/components/switch/insteon_plm.py @@ -18,7 +18,7 @@ @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up the INSTEON PLM device class for the hass platform.""" - plm = hass.data['insteon_plm'] + plm = hass.data['insteon_plm'].get('plm') address = discovery_info['address'] device = plm.devices[address] From db22601dee09e2c4f4c65c78bf55b7a7a180acc7 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 22:04:46 -0400 Subject: [PATCH 13/32] Add entity to hass.data --- homeassistant/components/insteon_plm.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index 82e908f873f67..249c9950224d9 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -298,8 +298,7 @@ def async_added_to_hass(self): """Register INSTEON update events.""" self._insteon_device_state.register_updates( self.async_entity_update) - insteon_plm = get_component(DOMAIN) - insteon_plm.entities[self.entity_id] = self + hass.data[DOMAIN]['entities'][self.entity_id] = self def load_aldb(self, reload=False): """Load the device All-Link Database.""" From 52c870cb40ed629b65e815f6874ee648923d3b64 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 22:11:23 -0400 Subject: [PATCH 14/32] Add ref to hass in InsteonPLMEntity --- homeassistant/components/binary_sensor/insteon_plm.py | 2 +- homeassistant/components/fan/insteon_plm.py | 2 +- homeassistant/components/insteon_plm.py | 5 +++-- homeassistant/components/light/insteon_plm.py | 2 +- homeassistant/components/sensor/insteon_plm.py | 2 +- homeassistant/components/switch/insteon_plm.py | 4 ++-- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/binary_sensor/insteon_plm.py b/homeassistant/components/binary_sensor/insteon_plm.py index 9cb87b317499a..8bda888bf0209 100644 --- a/homeassistant/components/binary_sensor/insteon_plm.py +++ b/homeassistant/components/binary_sensor/insteon_plm.py @@ -33,7 +33,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): _LOGGER.debug('Adding device %s entity %s to Binary Sensor platform', device.address.hex, device.states[state_key].name) - new_entity = InsteonPLMBinarySensor(device, state_key) + new_entity = InsteonPLMBinarySensor(hass, device, state_key) async_add_devices([new_entity]) diff --git a/homeassistant/components/fan/insteon_plm.py b/homeassistant/components/fan/insteon_plm.py index 0911295d090cf..c0ffa0347f9da 100644 --- a/homeassistant/components/fan/insteon_plm.py +++ b/homeassistant/components/fan/insteon_plm.py @@ -40,7 +40,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): _LOGGER.debug('Adding device %s entity %s to Fan platform', device.address.hex, device.states[state_key].name) - new_entity = InsteonPLMFan(device, state_key) + new_entity = InsteonPLMFan(hass, device, state_key) async_add_devices([new_entity]) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index 249c9950224d9..2c8a4f01a7e6e 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -247,8 +247,9 @@ def __getitem__(self, key): class InsteonPLMEntity(Entity): """INSTEON abstract base entity.""" - def __init__(self, device, state_key): + def __init__(self, hass, device, state_key): """Initialize the INSTEON PLM binary sensor.""" + self._hass = hass self._insteon_device_state = device.states[state_key] self._insteon_device = device self._insteon_device.aldb.add_loaded_callback(self._aldb_loaded) @@ -298,7 +299,7 @@ def async_added_to_hass(self): """Register INSTEON update events.""" self._insteon_device_state.register_updates( self.async_entity_update) - hass.data[DOMAIN]['entities'][self.entity_id] = self + self._hass.data[DOMAIN]['entities'][self.entity_id] = self def load_aldb(self, reload=False): """Load the device All-Link Database.""" diff --git a/homeassistant/components/light/insteon_plm.py b/homeassistant/components/light/insteon_plm.py index 8a3b463c2bd08..0de55ed38d427 100644 --- a/homeassistant/components/light/insteon_plm.py +++ b/homeassistant/components/light/insteon_plm.py @@ -30,7 +30,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): _LOGGER.debug('Adding device %s entity %s to Light platform', device.address.hex, device.states[state_key].name) - new_entity = InsteonPLMDimmerDevice(device, state_key) + new_entity = InsteonPLMDimmerDevice(hass, device, state_key) async_add_devices([new_entity]) diff --git a/homeassistant/components/sensor/insteon_plm.py b/homeassistant/components/sensor/insteon_plm.py index 61f5877ed7815..f62a678974cee 100644 --- a/homeassistant/components/sensor/insteon_plm.py +++ b/homeassistant/components/sensor/insteon_plm.py @@ -27,7 +27,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): _LOGGER.debug('Adding device %s entity %s to Sensor platform', device.address.hex, device.states[state_key].name) - new_entity = InsteonPLMSensorDevice(device, state_key) + new_entity = InsteonPLMSensorDevice(hass, device, state_key) async_add_devices([new_entity]) diff --git a/homeassistant/components/switch/insteon_plm.py b/homeassistant/components/switch/insteon_plm.py index be562e9d909d6..ebf0396bb677c 100644 --- a/homeassistant/components/switch/insteon_plm.py +++ b/homeassistant/components/switch/insteon_plm.py @@ -31,9 +31,9 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): new_entity = None if state_name in ['lightOnOff', 'outletTopOnOff', 'outletBottomOnOff']: - new_entity = InsteonPLMSwitchDevice(device, state_key) + new_entity = InsteonPLMSwitchDevice(hass, device, state_key) elif state_name == 'openClosedRelay': - new_entity = InsteonPLMOpenClosedDevice(device, state_key) + new_entity = InsteonPLMOpenClosedDevice(hass, device, state_key) if new_entity is not None: async_add_devices([new_entity]) From a51cef84a61d825ef93ab249d3e24252c3a328ae Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 22:13:03 -0400 Subject: [PATCH 15/32] Pass hass correctly to InsteonPLMBinarySensor --- homeassistant/components/binary_sensor/insteon_plm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/binary_sensor/insteon_plm.py b/homeassistant/components/binary_sensor/insteon_plm.py index 8bda888bf0209..28a9e56bb6a49 100644 --- a/homeassistant/components/binary_sensor/insteon_plm.py +++ b/homeassistant/components/binary_sensor/insteon_plm.py @@ -41,9 +41,9 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): class InsteonPLMBinarySensor(InsteonPLMEntity, BinarySensorDevice): """A Class for an Insteon device entity.""" - def __init__(self, device, state_key): + def __init__(self, hass, device, state_key): """Initialize the INSTEON PLM binary sensor.""" - super().__init__(device, state_key) + super().__init__(hass, device, state_key) self._sensor_type = SENSOR_TYPES.get(self._insteon_device_state.name) @property From d5274353dcb7fb6f4e2113665eb5bae4d238ece4 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 22:19:40 -0400 Subject: [PATCH 16/32] Fix reference to ALDBStatus.PARTIAL --- homeassistant/components/insteon_plm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index 2c8a4f01a7e6e..3077a7f1069c5 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -313,7 +313,7 @@ def print_aldb(self): _LOGGER.info('ALDB load status for device %s is %s', self.address, self._insteon_device.aldb.status.name) if self._insteon_device.aldb.status in [ALDBStatus.LOADED, - ALDBStatus.Partial]: + ALDBStatus.PARTIAL]: for mem_addr in self._insteon_device.aldb: rec = self._insteon_device.aldb _LOGGER.info(rec) From decc72fc569b17931f9f2dd6320d99f8ad9256fd Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 22:31:50 -0400 Subject: [PATCH 17/32] Print ALDB record as string --- homeassistant/components/insteon_plm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index 3077a7f1069c5..38d528a4cc958 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -316,7 +316,7 @@ def print_aldb(self): ALDBStatus.PARTIAL]: for mem_addr in self._insteon_device.aldb: rec = self._insteon_device.aldb - _LOGGER.info(rec) + _LOGGER.info(str(rec)) else: _LOGGER.warning('Device All-Link database not loaded') _LOGGER.warning('Use service insteon_plm.load_aldb first') From 69f93ae494596872bd161c206c7304ef68836b53 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sun, 15 Apr 2018 22:39:04 -0400 Subject: [PATCH 18/32] Get ALDB record from memory address --- homeassistant/components/insteon_plm.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index 38d528a4cc958..776a546338dd5 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -315,8 +315,10 @@ def print_aldb(self): if self._insteon_device.aldb.status in [ALDBStatus.LOADED, ALDBStatus.PARTIAL]: for mem_addr in self._insteon_device.aldb: - rec = self._insteon_device.aldb - _LOGGER.info(str(rec)) + rec = self._insteon_device.aldb[mem_addr] + # For now we write this to the log + # Roadmap is to create a configuration panel + _LOGGER.info(rec) else: _LOGGER.warning('Device All-Link database not loaded') _LOGGER.warning('Use service insteon_plm.load_aldb first') From a0b5082b807d39c63fe02dce5bdebfc2e7fd53e4 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Mon, 16 Apr 2018 10:14:34 -0400 Subject: [PATCH 19/32] Reformat ALDB log output --- homeassistant/components/insteon_plm.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index 776a546338dd5..c912d477fe3ab 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -312,13 +312,23 @@ def print_aldb(self): from insteonplm.devices import ALDBStatus _LOGGER.info('ALDB load status for device %s is %s', self.address, self._insteon_device.aldb.status.name) + _LOGGER.info('RecID In Use Mode HWM Group Address Data 1 Data 2 Data 3') + _LOGGER.info('----- ------ ---- --- ----- -------- ------ ------ ------') if self._insteon_device.aldb.status in [ALDBStatus.LOADED, ALDBStatus.PARTIAL]: for mem_addr in self._insteon_device.aldb: rec = self._insteon_device.aldb[mem_addr] # For now we write this to the log # Roadmap is to create a configuration panel - _LOGGER.info(rec) + in_use = 'Y' if rec.control_flags.is_in_use else 'N' + mode = 'C' if rec.control_flags.is_controller else 'R' + hwm = 'Y' if rec.control_flags.is_high_water_mark else 'N' + _LOGGER.info(' {:04x} {:s} {:s} {:s} {:3d} {:s}' + ' {:3d} {:3d} {:3d}'.format( + rec.mem_addr, in_use, mode, hwm, + rec.group, rec.address.human, + rec.data1, rec.data2, rec.data3)) + else: _LOGGER.warning('Device All-Link database not loaded') _LOGGER.warning('Use service insteon_plm.load_aldb first') From 5a9f041f74b4e9546488592629d5a59fdefd99f7 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Fri, 20 Apr 2018 15:30:47 -0400 Subject: [PATCH 20/32] Add print_im_aldb service --- homeassistant/components/insteon_plm.py | 60 +++++++++++++++---------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index c912d477fe3ab..afe3f42aabbbd 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -16,7 +16,6 @@ import homeassistant.helpers.config_validation as cv from homeassistant.helpers import discovery from homeassistant.helpers.entity import Entity -from homeassistant.loader import get_component REQUIREMENTS = ['insteonplm==0.8.6'] @@ -35,6 +34,7 @@ SRV_DEL_ALL_LINK = 'delete_all_link' SRV_LOAD_ALDB = 'load_all_link_database' SRV_PRINT_ALDB = 'print_all_link_database' +SRV_PRINT_IM_ALDB = 'print_im_all_link_database' SRV_ALL_LINK_GROUP = 'group' SRV_ALL_LINK_MODE = 'mode' SRV_LOAD_DB_RELOAD = 'reload' @@ -147,6 +147,12 @@ def print_aldb(service): else: _LOGGER.error('Entity %s is not an INSTEON device', entity_id) + def print_im_aldb(service): + """Print the All-Link Database for a device.""" + # For now this sends logs to the log file. + # Furture direction is to create an INSTEON control panel. + print_aldb_to_log(plm.aldb) + def _register_services(): hass.services.register(DOMAIN, SRV_ADD_ALL_LINK, add_all_link, schema=ADD_ALL_LINK_SCHEMA) @@ -156,6 +162,8 @@ def _register_services(): schema=LOAD_ALDB_SCHEMA) hass.services.register(DOMAIN, SRV_PRINT_ALDB, print_aldb, schema=PRINT_ALDB_SCHEMA) + hass.services.register(DOMAIN, SRV_PRINT_IM_ALDB, print_im_aldb, + schema=None) _LOGGER.debug("Insteon_plm Services registered") _LOGGER.info("Looking for PLM on %s", port) @@ -309,31 +317,35 @@ def load_aldb(self, reload=False): def print_aldb(self): """Print the device ALDB to the log file.""" - from insteonplm.devices import ALDBStatus - _LOGGER.info('ALDB load status for device %s is %s', - self.address, self._insteon_device.aldb.status.name) - _LOGGER.info('RecID In Use Mode HWM Group Address Data 1 Data 2 Data 3') - _LOGGER.info('----- ------ ---- --- ----- -------- ------ ------ ------') - if self._insteon_device.aldb.status in [ALDBStatus.LOADED, - ALDBStatus.PARTIAL]: - for mem_addr in self._insteon_device.aldb: - rec = self._insteon_device.aldb[mem_addr] - # For now we write this to the log - # Roadmap is to create a configuration panel - in_use = 'Y' if rec.control_flags.is_in_use else 'N' - mode = 'C' if rec.control_flags.is_controller else 'R' - hwm = 'Y' if rec.control_flags.is_high_water_mark else 'N' - _LOGGER.info(' {:04x} {:s} {:s} {:s} {:3d} {:s}' - ' {:3d} {:3d} {:3d}'.format( - rec.mem_addr, in_use, mode, hwm, - rec.group, rec.address.human, - rec.data1, rec.data2, rec.data3)) - - else: - _LOGGER.warning('Device All-Link database not loaded') - _LOGGER.warning('Use service insteon_plm.load_aldb first') + print_aldb_to_log(self._insteon_device.aldb) @callback def _aldb_loaded(self): """All-Link Database loaded for the device.""" self.print_aldb() + + +def print_aldb_to_log(self, aldb): + """Print the All-Link Database to the log file.""" + from insteonplm.devices import ALDBStatus + _LOGGER.info('ALDB load status for device %s is %s', + self.address, self._insteon_device.aldb.status.name) + _LOGGER.info('RecID In Use Mode HWM Group Address Data 1 Data 2 Data 3') + _LOGGER.info('----- ------ ---- --- ----- -------- ------ ------ ------') + if aldb.status in [ALDBStatus.LOADED, ALDBStatus.PARTIAL]: + for mem_addr in aldb: + rec = aldb[mem_addr] + # For now we write this to the log + # Roadmap is to create a configuration panel + in_use = 'Y' if rec.control_flags.is_in_use else 'N' + mode = 'C' if rec.control_flags.is_controller else 'R' + hwm = 'Y' if rec.control_flags.is_high_water_mark else 'N' + _LOGGER.info(' {:04x} {:s} {:s} {:s} {:3d} {:s}' + ' {:3d} {:3d} {:3d}'.format( + rec.mem_addr, in_use, mode, hwm, + rec.group, rec.address.human, + rec.data1, rec.data2, rec.data3)) + + else: + _LOGGER.warning('Device All-Link database not loaded') + _LOGGER.warning('Use service insteon_plm.load_aldb first') From 1c93eac8b12a2b3b8cc3a8d96f211213d4dd0a98 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Fri, 20 Apr 2018 15:55:08 -0400 Subject: [PATCH 21/32] Remove reference to self in print_aldb_to_log --- homeassistant/components/insteon_plm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index afe3f42aabbbd..1198620d8dbc9 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -325,7 +325,7 @@ def _aldb_loaded(self): self.print_aldb() -def print_aldb_to_log(self, aldb): +def print_aldb_to_log(aldb): """Print the All-Link Database to the log file.""" from insteonplm.devices import ALDBStatus _LOGGER.info('ALDB load status for device %s is %s', From 8d3332ea0cdddf8136ddfec0204553e48e9284d5 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Fri, 20 Apr 2018 16:53:28 -0400 Subject: [PATCH 22/32] Remove reference to self in print_aldb_to_log --- homeassistant/components/insteon_plm.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index 1198620d8dbc9..c6d6d32a6c2a1 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -328,8 +328,7 @@ def _aldb_loaded(self): def print_aldb_to_log(aldb): """Print the All-Link Database to the log file.""" from insteonplm.devices import ALDBStatus - _LOGGER.info('ALDB load status for device %s is %s', - self.address, self._insteon_device.aldb.status.name) + _LOGGER.info('ALDB load status is %s', aldb.status.name) _LOGGER.info('RecID In Use Mode HWM Group Address Data 1 Data 2 Data 3') _LOGGER.info('----- ------ ---- --- ----- -------- ------ ------ ------') if aldb.status in [ALDBStatus.LOADED, ALDBStatus.PARTIAL]: From 3f9804e40a425130e2c40f968b6a1f7d21ef3167 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Fri, 20 Apr 2018 17:48:46 -0400 Subject: [PATCH 23/32] Fix spelling issue with load_all_link_database service --- homeassistant/components/insteon_plm.py | 3 ++- homeassistant/components/services.yaml | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index c6d6d32a6c2a1..173f0487f6332 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -69,7 +69,8 @@ LOAD_ALDB_SCHEMA = vol.Schema({ vol.Required(CONF_ENTITY_ID): cv.entity_id, - vol.Optional(SRV_ALL_LINK_MODE, default='n'): vol.In(['Y', 'N', 'y', 'n']), + vol.Optional(SRV_LOAD_DB_RELOAD, default='n'): vol.In(['Y', 'N', + 'y', 'n']), }) PRINT_ALDB_SCHEMA = vol.Schema({ diff --git a/homeassistant/components/services.yaml b/homeassistant/components/services.yaml index 2958028693bd1..c569feb77d850 100644 --- a/homeassistant/components/services.yaml +++ b/homeassistant/components/services.yaml @@ -587,3 +587,5 @@ insteon_plm: entity_id: description: Name of the device to print example: 'light.1a2b3c' + print_im_all_link_database: + description: Print the All-Link Database for the INSTEON Modem (IM). \ No newline at end of file From ea3cb1323eed68f97778df6184e760f0a44a14c5 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Mon, 23 Apr 2018 22:56:56 -0400 Subject: [PATCH 24/32] Bump insteonplm to 0.9.1 --- homeassistant/components/insteon_plm.py | 2 +- requirements_all.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm.py index 173f0487f6332..85c488fff7c2a 100644 --- a/homeassistant/components/insteon_plm.py +++ b/homeassistant/components/insteon_plm.py @@ -17,7 +17,7 @@ from homeassistant.helpers import discovery from homeassistant.helpers.entity import Entity -REQUIREMENTS = ['insteonplm==0.8.6'] +REQUIREMENTS = ['insteonplm==0.9.1'] _LOGGER = logging.getLogger(__name__) diff --git a/requirements_all.txt b/requirements_all.txt index 9f398a37bdfc1..27a28bc405102 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -446,7 +446,7 @@ influxdb==5.0.0 insteonlocal==0.53 # homeassistant.components.insteon_plm -insteonplm==0.8.6 +insteonplm==0.9.1 # homeassistant.components.verisure jsonpath==0.75 From fe3f2dab93c35018778685d425b2d82abf6aaeb6 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Wed, 2 May 2018 22:39:56 -0400 Subject: [PATCH 25/32] Changes from code review --- .../components/{insteon_plm.py => insteon_plm/__init__.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename homeassistant/components/{insteon_plm.py => insteon_plm/__init__.py} (100%) diff --git a/homeassistant/components/insteon_plm.py b/homeassistant/components/insteon_plm/__init__.py similarity index 100% rename from homeassistant/components/insteon_plm.py rename to homeassistant/components/insteon_plm/__init__.py From a45ef0257b6a267a0f92281f9a43cc73819c63ab Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Wed, 2 May 2018 22:47:56 -0400 Subject: [PATCH 26/32] Code review changes --- .../components/binary_sensor/insteon_plm.py | 4 +- homeassistant/components/fan/insteon_plm.py | 2 +- .../components/insteon_plm/__init__.py | 51 ++++++++++--------- .../components/insteon_plm/services.yaml | 32 ++++++++++++ homeassistant/components/light/insteon_plm.py | 2 +- .../components/sensor/insteon_plm.py | 2 +- homeassistant/components/services.yaml | 33 ------------ .../components/switch/insteon_plm.py | 4 +- 8 files changed, 65 insertions(+), 65 deletions(-) create mode 100644 homeassistant/components/insteon_plm/services.yaml diff --git a/homeassistant/components/binary_sensor/insteon_plm.py b/homeassistant/components/binary_sensor/insteon_plm.py index 28a9e56bb6a49..8bda888bf0209 100644 --- a/homeassistant/components/binary_sensor/insteon_plm.py +++ b/homeassistant/components/binary_sensor/insteon_plm.py @@ -41,9 +41,9 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): class InsteonPLMBinarySensor(InsteonPLMEntity, BinarySensorDevice): """A Class for an Insteon device entity.""" - def __init__(self, hass, device, state_key): + def __init__(self, device, state_key): """Initialize the INSTEON PLM binary sensor.""" - super().__init__(hass, device, state_key) + super().__init__(device, state_key) self._sensor_type = SENSOR_TYPES.get(self._insteon_device_state.name) @property diff --git a/homeassistant/components/fan/insteon_plm.py b/homeassistant/components/fan/insteon_plm.py index c0ffa0347f9da..0911295d090cf 100644 --- a/homeassistant/components/fan/insteon_plm.py +++ b/homeassistant/components/fan/insteon_plm.py @@ -40,7 +40,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): _LOGGER.debug('Adding device %s entity %s to Fan platform', device.address.hex, device.states[state_key].name) - new_entity = InsteonPLMFan(hass, device, state_key) + new_entity = InsteonPLMFan(device, state_key) async_add_devices([new_entity]) diff --git a/homeassistant/components/insteon_plm/__init__.py b/homeassistant/components/insteon_plm/__init__.py index 85c488fff7c2a..0ec0fa1219bea 100644 --- a/homeassistant/components/insteon_plm/__init__.py +++ b/homeassistant/components/insteon_plm/__init__.py @@ -38,6 +38,8 @@ SRV_ALL_LINK_GROUP = 'group' SRV_ALL_LINK_MODE = 'mode' SRV_LOAD_DB_RELOAD = 'reload' +SRV_CONTROLLER = 'controller' +SRV_RESPONDER = 'responder' CONF_DEVICE_OVERRIDE_SCHEMA = vol.All( cv.deprecated(CONF_PLATFORM), vol.Schema({ @@ -59,8 +61,7 @@ ADD_ALL_LINK_SCHEMA = vol.Schema({ vol.Required(SRV_ALL_LINK_GROUP): vol.Range(min=0, max=255), - vol.Required(SRV_ALL_LINK_MODE): vol.In(['C', 'R', - 'c', 'r']), + vol.Required(SRV_ALL_LINK_MODE): vol.In([SRV_CONTROLLER, SRV_RESPONDER]), }) DEL_ALL_LINK_SCHEMA = vol.Schema({ @@ -69,8 +70,7 @@ LOAD_ALDB_SCHEMA = vol.Schema({ vol.Required(CONF_ENTITY_ID): cv.entity_id, - vol.Optional(SRV_LOAD_DB_RELOAD, default='n'): vol.In(['Y', 'N', - 'y', 'n']), + vol.Optional(SRV_LOAD_DB_RELOAD, default='false'): vol.boolean), }) PRINT_ALDB_SCHEMA = vol.Schema({ @@ -114,7 +114,7 @@ def add_all_link(service): """Add an INSTEON All-Link between two devices.""" group = service.data.get(SRV_ALL_LINK_GROUP) mode = service.data.get(SRV_ALL_LINK_MODE) - link_mode = 1 if mode.lower() == 'c' else 0 + link_mode = 1 if mode.lower() == SRV_CONTROLLER else 0 plm.start_all_linking(link_mode, group) def del_all_link(service): @@ -256,9 +256,8 @@ def __getitem__(self, key): class InsteonPLMEntity(Entity): """INSTEON abstract base entity.""" - def __init__(self, hass, device, state_key): + def __init__(self, device, state_key): """Initialize the INSTEON PLM binary sensor.""" - self._hass = hass self._insteon_device_state = device.states[state_key] self._insteon_device = device self._insteon_device.aldb.add_loaded_callback(self._aldb_loaded) @@ -308,7 +307,7 @@ def async_added_to_hass(self): """Register INSTEON update events.""" self._insteon_device_state.register_updates( self.async_entity_update) - self._hass.data[DOMAIN]['entities'][self.entity_id] = self + self.hass.data[DOMAIN]['entities'][self.entity_id] = self def load_aldb(self, reload=False): """Load the device All-Link Database.""" @@ -330,22 +329,24 @@ def print_aldb_to_log(aldb): """Print the All-Link Database to the log file.""" from insteonplm.devices import ALDBStatus _LOGGER.info('ALDB load status is %s', aldb.status.name) - _LOGGER.info('RecID In Use Mode HWM Group Address Data 1 Data 2 Data 3') - _LOGGER.info('----- ------ ---- --- ----- -------- ------ ------ ------') - if aldb.status in [ALDBStatus.LOADED, ALDBStatus.PARTIAL]: - for mem_addr in aldb: - rec = aldb[mem_addr] - # For now we write this to the log - # Roadmap is to create a configuration panel - in_use = 'Y' if rec.control_flags.is_in_use else 'N' - mode = 'C' if rec.control_flags.is_controller else 'R' - hwm = 'Y' if rec.control_flags.is_high_water_mark else 'N' - _LOGGER.info(' {:04x} {:s} {:s} {:s} {:3d} {:s}' - ' {:3d} {:3d} {:3d}'.format( - rec.mem_addr, in_use, mode, hwm, - rec.group, rec.address.human, - rec.data1, rec.data2, rec.data3)) - - else: + if aldb.status not in [ALDBStatus.LOADED, ALDBStatus.PARTIAL]: _LOGGER.warning('Device All-Link database not loaded') _LOGGER.warning('Use service insteon_plm.load_aldb first') + return + + _LOGGER.info('RecID In Use Mode HWM Group Address Data 1 Data 2 Data 3') + _LOGGER.info('----- ------ ---- --- ----- -------- ------ ------ ------') + for mem_addr in aldb: + rec = aldb[mem_addr] + # For now we write this to the log + # Roadmap is to create a configuration panel + in_use = 'Y' if rec.control_flags.is_in_use else 'N' + mode = 'C' if rec.control_flags.is_controller else 'R' + hwm = 'Y' if rec.control_flags.is_high_water_mark else 'N' + _LOGGER.info(' {:04x} {:s} {:s} {:s} {:3d} {:s}' + ' {:3d} {:3d} {:3d}'.format( + rec.mem_addr, in_use, mode, hwm, + rec.group, rec.address.human, + rec.data1, rec.data2, rec.data3)) + + \ No newline at end of file diff --git a/homeassistant/components/insteon_plm/services.yaml b/homeassistant/components/insteon_plm/services.yaml new file mode 100644 index 0000000000000..a3e9a7730062b --- /dev/null +++ b/homeassistant/components/insteon_plm/services.yaml @@ -0,0 +1,32 @@ +add_all_link: + description: Tells the Insteom Modem (IM) start All-Linking mode. Once the the IM is in All-Linking mode, press the link button on the device to complete All-Linking. + fields: + group: + description: All-Link group number. + example: 1 + mode: + description: Linking mode controller - IM is controller responder - IM is responder + example: 'controller' +delete_all_link: + description: Tells the Insteon Modem (IM) to remove an All-Link record from the All-Link Database of the IM and a device. Once the IM is set to delete the link, press the link button on the corresponding device to complete the process. + fields: + group: + description: All-Link group number. + example: 1 +load_all_link_database: + description: Load the All-Link Database for a device. WARNING - Loading a device All-LInk database is very time consuming and inconsistant. This may take a LONG time and may need to be repeated to obtain all records. + fields: + entity_id: + description: Name of the device to print + example: 'light.1a2b3c' + reload: + description: Reload all records. If Y the current records are cleared from memory (does not effect the device) and the records are reloaded. If N the existing records are left in place and only missing records are added. Default is N. + example: N +print_all_link_database: + description: Print the All-Link Database for a device. Requires that the All-Link Database is loaded into memory. + fields: + entity_id: + description: Name of the device to print + example: 'light.1a2b3c' +print_im_all_link_database: + description: Print the All-Link Database for the INSTEON Modem (IM). diff --git a/homeassistant/components/light/insteon_plm.py b/homeassistant/components/light/insteon_plm.py index 0de55ed38d427..8a3b463c2bd08 100644 --- a/homeassistant/components/light/insteon_plm.py +++ b/homeassistant/components/light/insteon_plm.py @@ -30,7 +30,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): _LOGGER.debug('Adding device %s entity %s to Light platform', device.address.hex, device.states[state_key].name) - new_entity = InsteonPLMDimmerDevice(hass, device, state_key) + new_entity = InsteonPLMDimmerDevice(device, state_key) async_add_devices([new_entity]) diff --git a/homeassistant/components/sensor/insteon_plm.py b/homeassistant/components/sensor/insteon_plm.py index f62a678974cee..61f5877ed7815 100644 --- a/homeassistant/components/sensor/insteon_plm.py +++ b/homeassistant/components/sensor/insteon_plm.py @@ -27,7 +27,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): _LOGGER.debug('Adding device %s entity %s to Sensor platform', device.address.hex, device.states[state_key].name) - new_entity = InsteonPLMSensorDevice(hass, device, state_key) + new_entity = InsteonPLMSensorDevice(device, state_key) async_add_devices([new_entity]) diff --git a/homeassistant/components/services.yaml b/homeassistant/components/services.yaml index c569feb77d850..746c3c7f4838f 100644 --- a/homeassistant/components/services.yaml +++ b/homeassistant/components/services.yaml @@ -556,36 +556,3 @@ xiaomi_aqara: device_id: description: Hardware address of the device to remove. example: 158d0000000000 -insteon_plm: - add_all_link: - description: Tells the Insteom Modem (IM) start All-Linking mode. Once the the IM is in All-Linking mode, press the link button on the device to complete All-Linking. - fields: - group: - description: All-Link group number. - example: 1 - mode: - description: Linking mode C - IM is controler R - IM is responder - example: 'C' - delete_all_link: - description: Tells the Insteon Modem (IM) to remove an All-Link record from the All-Link Database of the IM and a device. Once the IM is set to delete the link, press the link button on the corresponding device to complete the process. - fields: - group: - description: All-Link group number. - example: 1 - load_all_link_database: - description: Load the All-Link Database for a device. WARNING - Loading a device All-LInk database is very time consuming and inconsistant. This may take a LONG time and may need to be repeated to obtain all records. - fields: - entity_id: - description: Name of the device to print - example: 'light.1a2b3c' - reload: - description: Reload all records. If Y the current records are cleared from memory (does not effect the device) and the records are reloaded. If N the existing records are left in place and only missing records are added. Default is N. - example: N - print_all_link_database: - description: Print the All-Link Database for a device. Requires that the All-Link Database is loaded into memory. - fields: - entity_id: - description: Name of the device to print - example: 'light.1a2b3c' - print_im_all_link_database: - description: Print the All-Link Database for the INSTEON Modem (IM). \ No newline at end of file diff --git a/homeassistant/components/switch/insteon_plm.py b/homeassistant/components/switch/insteon_plm.py index ebf0396bb677c..be562e9d909d6 100644 --- a/homeassistant/components/switch/insteon_plm.py +++ b/homeassistant/components/switch/insteon_plm.py @@ -31,9 +31,9 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): new_entity = None if state_name in ['lightOnOff', 'outletTopOnOff', 'outletBottomOnOff']: - new_entity = InsteonPLMSwitchDevice(hass, device, state_key) + new_entity = InsteonPLMSwitchDevice(device, state_key) elif state_name == 'openClosedRelay': - new_entity = InsteonPLMOpenClosedDevice(hass, device, state_key) + new_entity = InsteonPLMOpenClosedDevice(device, state_key) if new_entity is not None: async_add_devices([new_entity]) From 218a8be66a7a8b39ff4c74209b4dfe1cc4c38490 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Wed, 2 May 2018 23:19:56 -0400 Subject: [PATCH 27/32] Fix syntax error --- homeassistant/components/insteon_plm/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/insteon_plm/__init__.py b/homeassistant/components/insteon_plm/__init__.py index 0ec0fa1219bea..ad4774aca7403 100644 --- a/homeassistant/components/insteon_plm/__init__.py +++ b/homeassistant/components/insteon_plm/__init__.py @@ -70,7 +70,7 @@ LOAD_ALDB_SCHEMA = vol.Schema({ vol.Required(CONF_ENTITY_ID): cv.entity_id, - vol.Optional(SRV_LOAD_DB_RELOAD, default='false'): vol.boolean), + vol.Optional(SRV_LOAD_DB_RELOAD, default='false'): vol.boolean, }) PRINT_ALDB_SCHEMA = vol.Schema({ From cd959f96350450ef6fa388eb446652daadbdc0d3 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Wed, 2 May 2018 23:37:17 -0400 Subject: [PATCH 28/32] Correct reference to cv.boolean and update requirements --- homeassistant/components/insteon_plm/__init__.py | 2 +- homeassistant/components/insteon_plm/services.yaml | 4 ++-- requirements_all.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/insteon_plm/__init__.py b/homeassistant/components/insteon_plm/__init__.py index ad4774aca7403..fbdd1a6d1ba35 100644 --- a/homeassistant/components/insteon_plm/__init__.py +++ b/homeassistant/components/insteon_plm/__init__.py @@ -70,7 +70,7 @@ LOAD_ALDB_SCHEMA = vol.Schema({ vol.Required(CONF_ENTITY_ID): cv.entity_id, - vol.Optional(SRV_LOAD_DB_RELOAD, default='false'): vol.boolean, + vol.Optional(SRV_LOAD_DB_RELOAD, default='false'): cv.boolean, }) PRINT_ALDB_SCHEMA = vol.Schema({ diff --git a/homeassistant/components/insteon_plm/services.yaml b/homeassistant/components/insteon_plm/services.yaml index a3e9a7730062b..a0e250fef1ff9 100644 --- a/homeassistant/components/insteon_plm/services.yaml +++ b/homeassistant/components/insteon_plm/services.yaml @@ -20,8 +20,8 @@ load_all_link_database: description: Name of the device to print example: 'light.1a2b3c' reload: - description: Reload all records. If Y the current records are cleared from memory (does not effect the device) and the records are reloaded. If N the existing records are left in place and only missing records are added. Default is N. - example: N + description: Reload all records. If true the current records are cleared from memory (does not effect the device) and the records are reloaded. If false the existing records are left in place and only missing records are added. Default is false. + example: 'true' print_all_link_database: description: Print the All-Link Database for a device. Requires that the All-Link Database is loaded into memory. fields: diff --git a/requirements_all.txt b/requirements_all.txt index 16ad388867c27..76eb0b614e791 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1382,4 +1382,4 @@ ziggo-mediabox-xl==1.0.0 zigpy-xbee==0.0.2 # homeassistant.components.zha -zigpy==0.0.3 +zigpy==0.0.3 \ No newline at end of file From 969900090346348c6f27a3d4d9dee4524e1c3959 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Wed, 2 May 2018 23:54:47 -0400 Subject: [PATCH 29/32] Update requirements --- requirements_all.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_all.txt b/requirements_all.txt index 76eb0b614e791..16ad388867c27 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1382,4 +1382,4 @@ ziggo-mediabox-xl==1.0.0 zigpy-xbee==0.0.2 # homeassistant.components.zha -zigpy==0.0.3 \ No newline at end of file +zigpy==0.0.3 From 52665f649f1a452117203ba4de96d598fb209bb2 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Thu, 3 May 2018 00:14:18 -0400 Subject: [PATCH 30/32] Fix flake8 errors --- homeassistant/components/insteon_plm/__init__.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/insteon_plm/__init__.py b/homeassistant/components/insteon_plm/__init__.py index fbdd1a6d1ba35..b824fbbff052a 100644 --- a/homeassistant/components/insteon_plm/__init__.py +++ b/homeassistant/components/insteon_plm/__init__.py @@ -345,8 +345,6 @@ def print_aldb_to_log(aldb): hwm = 'Y' if rec.control_flags.is_high_water_mark else 'N' _LOGGER.info(' {:04x} {:s} {:s} {:s} {:3d} {:s}' ' {:3d} {:3d} {:3d}'.format( - rec.mem_addr, in_use, mode, hwm, - rec.group, rec.address.human, - rec.data1, rec.data2, rec.data3)) - - \ No newline at end of file + rec.mem_addr, in_use, mode, hwm, + rec.group, rec.address.human, + rec.data1, rec.data2, rec.data3)) From fa63eeed0ade6171126743407251774785fcc4ed Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Thu, 3 May 2018 00:31:51 -0400 Subject: [PATCH 31/32] Reload as boolean test --- homeassistant/components/insteon_plm/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/homeassistant/components/insteon_plm/__init__.py b/homeassistant/components/insteon_plm/__init__.py index b824fbbff052a..246e84ec71f3a 100644 --- a/homeassistant/components/insteon_plm/__init__.py +++ b/homeassistant/components/insteon_plm/__init__.py @@ -126,13 +126,10 @@ def load_aldb(service): """Load the device All-Link database.""" entity_id = service.data.get(CONF_ENTITY_ID) reload = service.data.get(SRV_LOAD_DB_RELOAD) - db_reload = False - if reload: - db_reload = True if reload.lower() == 'y' else False entities = hass.data[DOMAIN].get('entities') entity = entities.get(entity_id) if entity: - entity.load_aldb(db_reload) + entity.load_aldb(reload) else: _LOGGER.error('Entity %s is not an INSTEON device', entity_id) From e4c1ff772c6ee03b5274ea0abd0e86baa1c7e50e Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Thu, 3 May 2018 00:38:48 -0400 Subject: [PATCH 32/32] Remove hass from entity init --- homeassistant/components/binary_sensor/insteon_plm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/binary_sensor/insteon_plm.py b/homeassistant/components/binary_sensor/insteon_plm.py index 8bda888bf0209..9cb87b317499a 100644 --- a/homeassistant/components/binary_sensor/insteon_plm.py +++ b/homeassistant/components/binary_sensor/insteon_plm.py @@ -33,7 +33,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): _LOGGER.debug('Adding device %s entity %s to Binary Sensor platform', device.address.hex, device.states[state_key].name) - new_entity = InsteonPLMBinarySensor(hass, device, state_key) + new_entity = InsteonPLMBinarySensor(device, state_key) async_add_devices([new_entity])