From 7a2cd2993068be2c0d19e96b9355d6b2a9b8eb94 Mon Sep 17 00:00:00 2001 From: Ryan Horiguchi Date: Fri, 10 Aug 2018 13:53:44 +0200 Subject: [PATCH 01/12] Use config correctly --- custom_components/custom_updater.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/custom_components/custom_updater.py b/custom_components/custom_updater.py index fb27248..bceb69f 100644 --- a/custom_components/custom_updater.py +++ b/custom_components/custom_updater.py @@ -13,6 +13,7 @@ import requests import voluptuous as vol import homeassistant.helpers.config_validation as cv +from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.helpers.event import track_time_interval __version__ = '1.4.1' @@ -30,21 +31,19 @@ ATTR_CARD = 'card' ATTR_COMPONENT = 'component' -CONFIG_SCHEMA = vol.Schema({ - DOMAIN: vol.Schema({ - vol.Required(CONF_TRACK, default=None): - vol.All(cv.ensure_list, [cv.string]), - vol.Optional(CONF_HIDE_SENSOR, default=False): cv.boolean, - }) -}, extra=vol.ALLOW_EXTRA) +PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ + vol.Required(CONF_TRACK, default=None): + vol.All(cv.ensure_list, [cv.string]), + vol.Optional(CONF_HIDE_SENSOR, default=False): cv.boolean, +}) CARDS_JSON = 'https://raw.githubusercontent.com/custom-cards/information/master/repos.json' COMPS_JSON = 'https://raw.githubusercontent.com/custom-components/information/master/repos.json' def setup(hass, config): """Set up this component.""" - conf_track = config[DOMAIN][CONF_TRACK] - conf_hide_sensor = config[DOMAIN][CONF_HIDE_SENSOR] + conf_track = config.get(CONF_TRACK) + conf_hide_sensor = config.get(CONF_HIDE_SENSOR) _LOGGER.info('version %s is starting, if you have ANY issues with this, please report' ' them here: https://github.com/custom-components/custom_updater', __version__) From 9d2cbe0e788e57dfd1858c525e09100ca8266d2f Mon Sep 17 00:00:00 2001 From: Ryan Horiguchi Date: Fri, 10 Aug 2018 13:54:05 +0200 Subject: [PATCH 02/12] Format imports --- custom_components/custom_updater.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/custom_components/custom_updater.py b/custom_components/custom_updater.py index bceb69f..db5787d 100644 --- a/custom_components/custom_updater.py +++ b/custom_components/custom_updater.py @@ -8,10 +8,12 @@ import logging import os import subprocess -from datetime import timedelta import time +from datetime import timedelta + import requests import voluptuous as vol + import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.helpers.event import track_time_interval From 0e2773469e7063a900b38e01b73ac6ab15fcd06e Mon Sep 17 00:00:00 2001 From: Ryan Horiguchi Date: Fri, 10 Aug 2018 14:13:01 +0200 Subject: [PATCH 03/12] Remove unused code --- custom_components/custom_updater.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/custom_components/custom_updater.py b/custom_components/custom_updater.py index db5787d..564a7a1 100644 --- a/custom_components/custom_updater.py +++ b/custom_components/custom_updater.py @@ -60,11 +60,11 @@ def setup(hass, config): def check_all_service(call): """Set up service for manual trigger.""" if not conf_track or 'cards' in conf_track: - card_controller.cache_versions(call) + card_controller.cache_versions() if not conf_track or 'components' in conf_track: - components_controller.cache_versions(call) + components_controller.cache_versions() - def update_all_service(call): + def update_all_service(): """Set up service for manual trigger.""" if not conf_track or 'cards' in conf_track: card_controller.update_all() @@ -98,7 +98,7 @@ def __init__(self, hass, ha_conf_dir, conf_hide_sensor): self.ha_conf_dir = ha_conf_dir self.hass.data[CARD_DATA] = {} self.lovelace_gen_check() - self.cache_versions('now') + self.cache_versions() def lovelace_gen_check(self): """Check if lovelace-gen is in use""" @@ -114,7 +114,7 @@ def lovelace_gen_check(self): else: self._lovelace_gen = False - def cache_versions(self, call): + def cache_versions(self): """Cache""" self.cards = self.get_cards() self.hass.data[CARD_DATA] = {} @@ -225,7 +225,6 @@ def get_remote_info(self, card): ] except: _LOGGER.debug('Gathering remote info for %s failed...', card) - remote = False else: _LOGGER.debug('Could not get remote info for %s', card) return remote_info @@ -276,9 +275,9 @@ def __init__(self, hass, ha_conf_dir, conf_hide_sensor): self._hide_sensor = conf_hide_sensor self.ha_conf_dir = ha_conf_dir self.hass.data[COMPONENT_DATA] = {} - self.cache_versions('now') + self.cache_versions() - def cache_versions(self, call): + def cache_versions(self): """Cache""" self.components = self.get_components() self.hass.data[COMPONENT_DATA] = {} @@ -367,7 +366,6 @@ def get_remote_info(self, component): ] except: _LOGGER.debug('Gathering remote info for %s failed...', component) - remote = False else: _LOGGER.debug('Could not get remote info for %s', component) return remote_info From 40797c424d95dccbde29049eaef53cf59ca4c7ae Mon Sep 17 00:00:00 2001 From: Ryan Horiguchi Date: Fri, 10 Aug 2018 14:37:32 +0200 Subject: [PATCH 04/12] Use super class for duplicate code and code cleanup --- custom_components/custom_updater.py | 215 ++++++++++++++-------------- 1 file changed, 107 insertions(+), 108 deletions(-) diff --git a/custom_components/custom_updater.py b/custom_components/custom_updater.py index 564a7a1..e54e273 100644 --- a/custom_components/custom_updater.py +++ b/custom_components/custom_updater.py @@ -11,10 +11,9 @@ import time from datetime import timedelta +import homeassistant.helpers.config_validation as cv import requests import voluptuous as vol - -import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.helpers.event import track_time_interval @@ -42,6 +41,7 @@ CARDS_JSON = 'https://raw.githubusercontent.com/custom-cards/information/master/repos.json' COMPS_JSON = 'https://raw.githubusercontent.com/custom-components/information/master/repos.json' + def setup(hass, config): """Set up this component.""" conf_track = config.get(CONF_TRACK) @@ -88,14 +88,33 @@ def upgrade_component_service(call): return True -class CustomCards: - """Custom cards controller.""" +class CustomUpdaterController(object): + """Custom updater controller.""" def __init__(self, hass, ha_conf_dir, conf_hide_sensor): self.hass = hass - self.cards = None - self._lovelace_gen = False self._hide_sensor = conf_hide_sensor self.ha_conf_dir = ha_conf_dir + + @staticmethod + def get_all_available_entities(url): + """Get all available entities""" + _LOGGER.debug('Gathering all available entities.') + entities = [] + response = requests.get(url) + if response.status_code == 200: + for card in response.json(): + entities.append(card) + else: + _LOGGER.debug('Could not reach the remote information repo.') + return entities + + +class CustomCards(CustomUpdaterController): + """Custom cards controller.""" + def __init__(self, hass, ha_conf_dir, conf_hide_sensor): + super().__init__(hass, ha_conf_dir, conf_hide_sensor) + self.cards = None + self._lovelace_gen = False self.hass.data[CARD_DATA] = {} self.lovelace_gen_check() self.cache_versions() @@ -116,23 +135,23 @@ def lovelace_gen_check(self): def cache_versions(self): """Cache""" - self.cards = self.get_cards() + self.cards = super().get_all_available_entities(CARDS_JSON) self.hass.data[CARD_DATA] = {} if self.cards: for card in self.cards: - remoteinfo = self.get_remote_info(card) - remoteversion = remoteinfo[1] - localversion = self.get_local_version(remoteinfo[0]) - if localversion: - has_update = (remoteversion != False and remoteversion != localversion) - not_local = (remoteversion != False and not localversion) + remote_info = self.get_remote_info(card) + remote_version = remote_info[1] + local_version = self.get_local_version(remote_info[0]) + if local_version: + has_update = (remote_version != False and remote_version != local_version) + not_local = (remote_version != False and not local_version) self.hass.data[CARD_DATA][card] = { - "local": localversion, - "remote": remoteversion, + "local": local_version, + "remote": remote_version, "has_update": has_update, "not_local": not_local, - "repo": remoteinfo[3], - "change_log": remoteinfo[4], + "repo": remote_info[3], + "change_log": remote_info[4], } self.hass.data[CARD_DATA]['domain'] = 'custom_cards' self.hass.data[CARD_DATA]['repo'] = '#' @@ -155,13 +174,13 @@ def upgrade_single(self, card): _LOGGER.debug('Starting upgrade for "%s".', card) if card in self.hass.data[CARD_DATA]: if self.hass.data[CARD_DATA][card]['has_update']: - remoteinfo = self.get_remote_info(card) - remotefile = remoteinfo[2] - localfile = self.ha_conf_dir + self.get_card_dir(card) + card + '.js' - test_remotefile = requests.get(remotefile) - if test_remotefile.status_code == 200: - with open(localfile, 'wb') as card_file: - card_file.write(test_remotefile.content) + remote_info = self.get_remote_info(card) + remote_file = remote_info[2] + local_file = self.ha_conf_dir + self.get_card_dir(card) + card + '.js' + test_remote_file = requests.get(remote_file) + if test_remote_file.status_code == 200: + with open(local_file, 'wb') as card_file: + card_file.write(test_remote_file.content) card_file.close() self.update_resource_version(card) _LOGGER.info('Upgrade of %s from version %s to version %s complete', @@ -178,16 +197,16 @@ def upgrade_single(self, card): def update_resource_version(self, card): """Updating the ui-lovelace file""" - localversion = self.hass.data[CARD_DATA][card]['local'] - remoteversion = self.hass.data[CARD_DATA][card]['remote'] + local_version = self.hass.data[CARD_DATA][card]['local'] + remote_version = self.hass.data[CARD_DATA][card]['remote'] _LOGGER.debug('Updating configuration for %s', card) - _LOGGER.debug('Upgrading card in config from version %s to version %s', localversion, remoteversion) + _LOGGER.debug('Upgrading card in config from version %s to version %s', local_version, remote_version) if self._lovelace_gen: conf_file = self.ha_conf_dir + '/lovelace/main.yaml' - sedcmd = 's/'+ card + '.js?v=' + str(localversion) + '/'+ card + '.js?v=' + str(remoteversion) + '/' + sedcmd = 's/' + card + '.js?v=' + str(local_version) + '/' + card + '.js?v=' + str(remote_version) + '/' else: conf_file = self.ha_conf_dir + '/ui-lovelace.yaml' - sedcmd = 's/\/'+ card + '.js?v=' + str(localversion) + '/\/'+ card + '.js?v=' + str(remoteversion) + '/' + sedcmd = 's/\/' + card + '.js?v=' + str(local_version) + '/\/' + card + '.js?v=' + str(remote_version) + '/' subprocess.call(["sed", "-i", "-e", sedcmd, conf_file]) def get_card_dir(self, card): @@ -210,34 +229,37 @@ def get_card_dir(self, card): break return card_dir - def get_remote_info(self, card): + @staticmethod + def get_remote_info(card): """Return the remote info if any.""" response = requests.get(CARDS_JSON) remote_info = [None] if response.status_code == 200: try: remote = response.json()[card] - remote_info = [card, - remote['version'], - remote['remote_location'], - remote['visit_repo'], - remote['changelog'] - ] + remote_info = [ + card, + remote['version'], + remote['remote_location'], + remote['visit_repo'], + remote['changelog'] + ] except: _LOGGER.debug('Gathering remote info for %s failed...', card) + remote = False else: _LOGGER.debug('Could not get remote info for %s', card) return remote_info def get_local_version(self, card): """Return the local version if any.""" - cardconfig = '' + card_config = '' if self._lovelace_gen: conf_file = self.ha_conf_dir + '/lovelace/main.yaml' with open(conf_file, 'r') as local: for line in local.readlines(): if card + '.js' in line: - cardconfig = line + card_config = line break local.close() else: @@ -245,57 +267,43 @@ def get_local_version(self, card): with open(conf_file, 'r') as local: for line in local.readlines(): if '/' + card + '.js' in line: - cardconfig = line + card_config = line break local.close() - if '=' in cardconfig: - localversion = cardconfig.split('=')[1].split('\n')[0] - _LOGGER.debug('Local version of %s is %s', card, localversion) - return localversion + if '=' in card_config: + local_version = card_config.split('=')[1].split('\n')[0] + _LOGGER.debug('Local version of %s is %s', card, local_version) + return local_version return False - def get_cards(self): - """Get all available cards""" - _LOGGER.debug('Gathering all available cards.') - cards = [] - response = requests.get(CARDS_JSON) - if response.status_code == 200: - for card in response.json(): - cards.append(card) - else: - _LOGGER.debug('Could not reach the remote information repo.') - return cards - -class CustomComponents: +class CustomComponents(CustomUpdaterController): """Custom components controller.""" def __init__(self, hass, ha_conf_dir, conf_hide_sensor): - self.hass = hass + super().__init__(hass, ha_conf_dir, conf_hide_sensor) self.components = None - self._hide_sensor = conf_hide_sensor - self.ha_conf_dir = ha_conf_dir self.hass.data[COMPONENT_DATA] = {} self.cache_versions() def cache_versions(self): """Cache""" - self.components = self.get_components() + self.components = super().get_all_available_entities(COMPS_JSON) self.hass.data[COMPONENT_DATA] = {} if self.components: for component in self.components: - remoteinfo = self.get_remote_info(component) - remoteversion = remoteinfo[1] - localversion = self.get_local_version(component, remoteinfo[2]) - if localversion: - has_update = (remoteversion != False and remoteversion != localversion) - not_local = (remoteversion != False and not localversion) + remote_info = self.get_remote_info(component) + remote_version = remote_info[1] + local_version = self.get_local_version(component, remote_info[2]) + if local_version: + has_update = (remote_version != False and remote_version != local_version) + not_local = (remote_version != False and not local_version) self.hass.data[COMPONENT_DATA][component] = { - "local": localversion, - "remote": remoteversion, + "local": local_version, + "remote": remote_version, "has_update": has_update, "not_local": not_local, - "repo": remoteinfo[4], - "change_log": remoteinfo[5], + "repo": remote_info[4], + "change_log": remote_info[5], } self.hass.data[COMPONENT_DATA]['domain'] = 'custom_components' self.hass.data[COMPONENT_DATA]['repo'] = '#' @@ -318,13 +326,13 @@ def upgrade_single(self, component): _LOGGER.debug('Starting upgrade for "%s".', component) if component in self.hass.data[COMPONENT_DATA]: if self.hass.data[COMPONENT_DATA][component]['has_update']: - remoteinfo = self.get_remote_info(component) - remotefile = remoteinfo[3] - localfile = self.ha_conf_dir + remoteinfo[2] - test_remotefile = requests.get(remotefile) - if test_remotefile.status_code == 200: - with open(localfile, 'wb') as component_file: - component_file.write(test_remotefile.content) + remote_info = self.get_remote_info(component) + remote_file = remote_info[3] + local_file = self.ha_conf_dir + remote_info[2] + test_remote_file = requests.get(remote_file) + if test_remote_file.status_code == 200: + with open(local_file, 'wb') as component_file: + component_file.write(test_remote_file.content) component_file.close() _LOGGER.info('Upgrade of %s from version %s to version %s complete', component, self.hass.data[COMPONENT_DATA][component]['local'], @@ -338,55 +346,46 @@ def upgrade_single(self, component): else: _LOGGER.error('Upgrade failed, "%s" is not a valid component', component) - def get_components(self): - """Get all available components""" - _LOGGER.debug('Gathering all available components.') - components = [] - response = requests.get(COMPS_JSON) - if response.status_code == 200: - for component in response.json(): - components.append(component) - else: - _LOGGER.debug('Could not reach the remote information repo.') - return components - - def get_remote_info(self, component): + @staticmethod + def get_remote_info(component): """Return the remote info if any.""" response = requests.get(COMPS_JSON) remote_info = [None] if response.status_code == 200: try: remote = response.json()[component] - remote_info = [component, - remote['version'], - remote['local_location'], - remote['remote_location'], - remote['visit_repo'], - remote['changelog'] - ] + remote_info = [ + component, + remote['version'], + remote['local_location'], + remote['remote_location'], + remote['visit_repo'], + remote['changelog'] + ] except: _LOGGER.debug('Gathering remote info for %s failed...', component) + remote = False else: _LOGGER.debug('Could not get remote info for %s', component) return remote_info def get_local_version(self, component, local_path): """Return the local version if any.""" - localversion = None - componentpath = self.ha_conf_dir + local_path - if os.path.isfile(componentpath): - with open(componentpath, 'r') as local: + local_version = None + component_path = self.ha_conf_dir + local_path + if os.path.isfile(component_path): + with open(component_path, 'r') as local: for line in local.readlines(): if '__version__' in line: - localversion = line.split("'")[1] + local_version = line.split("'")[1] break local.close() - if not localversion: - localv = False + if not local_version: + local_v = False _LOGGER.debug('Could not get the local version for %s', component) else: - localv = localversion - _LOGGER.debug('Local version of %s is %s', component, localversion) + local_v = local_version + _LOGGER.debug('Local version of %s is %s', component, local_version) else: - localv = False - return localv + local_v = False + return local_v From 4d2247f59259a574989ff4c08966ec5b879af9fd Mon Sep 17 00:00:00 2001 From: Ryan Horiguchi Date: Sat, 11 Aug 2018 10:12:43 +0200 Subject: [PATCH 05/12] Reduce request amount and code cleanup --- custom_components/custom_updater.py | 241 +++++++++++++--------------- 1 file changed, 111 insertions(+), 130 deletions(-) diff --git a/custom_components/custom_updater.py b/custom_components/custom_updater.py index e54e273..a6f5650 100644 --- a/custom_components/custom_updater.py +++ b/custom_components/custom_updater.py @@ -88,31 +88,12 @@ def upgrade_component_service(call): return True -class CustomUpdaterController(object): - """Custom updater controller.""" +class CustomCards(object): + """Custom cards controller.""" def __init__(self, hass, ha_conf_dir, conf_hide_sensor): self.hass = hass self._hide_sensor = conf_hide_sensor self.ha_conf_dir = ha_conf_dir - - @staticmethod - def get_all_available_entities(url): - """Get all available entities""" - _LOGGER.debug('Gathering all available entities.') - entities = [] - response = requests.get(url) - if response.status_code == 200: - for card in response.json(): - entities.append(card) - else: - _LOGGER.debug('Could not reach the remote information repo.') - return entities - - -class CustomCards(CustomUpdaterController): - """Custom cards controller.""" - def __init__(self, hass, ha_conf_dir, conf_hide_sensor): - super().__init__(hass, ha_conf_dir, conf_hide_sensor) self.cards = None self._lovelace_gen = False self.hass.data[CARD_DATA] = {} @@ -135,23 +116,22 @@ def lovelace_gen_check(self): def cache_versions(self): """Cache""" - self.cards = super().get_all_available_entities(CARDS_JSON) + self.cards = self.get_all_remote_info() self.hass.data[CARD_DATA] = {} if self.cards: - for card in self.cards: - remote_info = self.get_remote_info(card) - remote_version = remote_info[1] - local_version = self.get_local_version(remote_info[0]) + for name, data in self.cards.items(): + remote_version = data[1] + local_version = self.get_local_version(data[0]) if local_version: has_update = (remote_version != False and remote_version != local_version) not_local = (remote_version != False and not local_version) - self.hass.data[CARD_DATA][card] = { + self.hass.data[CARD_DATA][name] = { "local": local_version, "remote": remote_version, "has_update": has_update, "not_local": not_local, - "repo": remote_info[3], - "change_log": remote_info[4], + "repo": data[3], + "change_log": data[4], } self.hass.data[CARD_DATA]['domain'] = 'custom_cards' self.hass.data[CARD_DATA]['repo'] = '#' @@ -161,55 +141,55 @@ def cache_versions(self): def update_all(self): """Update all cards""" - for card in self.hass.data[CARD_DATA]: - if card not in ('domain', 'repo', 'hidden'): + for name in self.hass.data[CARD_DATA]: + if name not in ('domain', 'repo', 'hidden'): try: - if self.hass.data[CARD_DATA][card]['has_update'] and not self.hass.data[CARD_DATA][card]['not_local']: - self.upgrade_single(card) - except: - _LOGGER.debug('Skipping upgrade for %s, no update available', card) + if self.hass.data[CARD_DATA][name]['has_update'] and not self.hass.data[CARD_DATA][name]['not_local']: + self.upgrade_single(name) + except KeyError: + _LOGGER.debug('Skipping upgrade for %s, no update available', name) - def upgrade_single(self, card): + def upgrade_single(self, name): """Update one components""" - _LOGGER.debug('Starting upgrade for "%s".', card) - if card in self.hass.data[CARD_DATA]: - if self.hass.data[CARD_DATA][card]['has_update']: - remote_info = self.get_remote_info(card) + _LOGGER.debug('Starting upgrade for "%s".', name) + if name in self.hass.data[CARD_DATA]: + if self.hass.data[CARD_DATA][name]['has_update']: + remote_info = self.get_all_remote_info()[name] remote_file = remote_info[2] - local_file = self.ha_conf_dir + self.get_card_dir(card) + card + '.js' + local_file = self.ha_conf_dir + self.get_card_dir(name) + name + '.js' test_remote_file = requests.get(remote_file) if test_remote_file.status_code == 200: with open(local_file, 'wb') as card_file: card_file.write(test_remote_file.content) card_file.close() - self.update_resource_version(card) + self.update_resource_version(name) _LOGGER.info('Upgrade of %s from version %s to version %s complete', - card, self.hass.data[CARD_DATA][card]['local'], - self.hass.data[CARD_DATA][card]['remote']) - self.hass.data[CARD_DATA][card]['local'] = self.hass.data[CARD_DATA][card]['remote'] - self.hass.data[CARD_DATA][card]['has_update'] = False - self.hass.data[CARD_DATA][card]['not_local'] = False + name, self.hass.data[CARD_DATA][name]['local'], + self.hass.data[CARD_DATA][name]['remote']) + self.hass.data[CARD_DATA][name]['local'] = self.hass.data[CARD_DATA][name]['remote'] + self.hass.data[CARD_DATA][name]['has_update'] = False + self.hass.data[CARD_DATA][name]['not_local'] = False self.hass.states.set('sensor.custom_card_tracker', time.time(), self.hass.data[CARD_DATA]) else: - _LOGGER.debug('Skipping upgrade for %s, no update available', card) + _LOGGER.debug('Skipping upgrade for %s, no update available', name) else: - _LOGGER.error('Upgrade failed, "%s" is not a valid card', card) + _LOGGER.error('Upgrade failed, "%s" is not a valid card', name) - def update_resource_version(self, card): + def update_resource_version(self, name): """Updating the ui-lovelace file""" - local_version = self.hass.data[CARD_DATA][card]['local'] - remote_version = self.hass.data[CARD_DATA][card]['remote'] - _LOGGER.debug('Updating configuration for %s', card) + local_version = self.hass.data[CARD_DATA][name]['local'] + remote_version = self.hass.data[CARD_DATA][name]['remote'] + _LOGGER.debug('Updating configuration for %s', name) _LOGGER.debug('Upgrading card in config from version %s to version %s', local_version, remote_version) if self._lovelace_gen: conf_file = self.ha_conf_dir + '/lovelace/main.yaml' - sedcmd = 's/' + card + '.js?v=' + str(local_version) + '/' + card + '.js?v=' + str(remote_version) + '/' + sedcmd = 's/' + name + '.js?v=' + str(local_version) + '/' + name + '.js?v=' + str(remote_version) + '/' else: conf_file = self.ha_conf_dir + '/ui-lovelace.yaml' - sedcmd = 's/\/' + card + '.js?v=' + str(local_version) + '/\/' + card + '.js?v=' + str(remote_version) + '/' + sedcmd = 's/\/' + name + '.js?v=' + str(local_version) + '/\/' + name + '.js?v=' + str(remote_version) + '/' subprocess.call(["sed", "-i", "-e", sedcmd, conf_file]) - def get_card_dir(self, card): + def get_card_dir(self, name): """Get card dir""" if self._lovelace_gen: conf_file = self.ha_conf_dir + '/lovelace/main.yaml' @@ -218,47 +198,47 @@ def get_card_dir(self, card): with open(conf_file, 'r') as local: for line in local.readlines(): if self._lovelace_gen: - if card + '.js' in line: - card_dir = '/lovelace/' + line.split('!resource ')[1].split(card + '.js')[0] - _LOGGER.debug('Found path "%s" for card "%s"', card_dir, card) + if name + '.js' in line: + card_dir = '/lovelace/' + line.split('!resource ')[1].split(name + '.js')[0] + _LOGGER.debug('Found path "%s" for card "%s"', card_dir, name) break else: - if '/' + card + '.js' in line: - card_dir = line.split(': ')[1].split(card + '.js')[0].replace("local", "www") - _LOGGER.debug('Found path "%s" for card "%s"', card_dir, card) + if '/' + name + '.js' in line: + card_dir = line.split(': ')[1].split(name + '.js')[0].replace("local", "www") + _LOGGER.debug('Found path "%s" for card "%s"', card_dir, name) break return card_dir @staticmethod - def get_remote_info(card): - """Return the remote info if any.""" + def get_all_remote_info(): + """Return all remote info if any.""" response = requests.get(CARDS_JSON) - remote_info = [None] + remote_info = {} if response.status_code == 200: - try: - remote = response.json()[card] - remote_info = [ - card, - remote['version'], - remote['remote_location'], - remote['visit_repo'], - remote['changelog'] - ] - except: - _LOGGER.debug('Gathering remote info for %s failed...', card) - remote = False + for name, card in response.json().items(): + try: + card = [ + name, + card['version'], + card['remote_location'], + card['visit_repo'], + card['changelog'] + ] + remote_info[name] = card + except KeyError: + _LOGGER.debug('Gathering remote info for %s failed...', name) else: - _LOGGER.debug('Could not get remote info for %s', card) + _LOGGER.debug('Could not get remote info for url %s', CARDS_JSON) return remote_info - def get_local_version(self, card): + def get_local_version(self, name): """Return the local version if any.""" card_config = '' if self._lovelace_gen: conf_file = self.ha_conf_dir + '/lovelace/main.yaml' with open(conf_file, 'r') as local: for line in local.readlines(): - if card + '.js' in line: + if name + '.js' in line: card_config = line break local.close() @@ -266,44 +246,45 @@ def get_local_version(self, card): conf_file = self.ha_conf_dir + '/ui-lovelace.yaml' with open(conf_file, 'r') as local: for line in local.readlines(): - if '/' + card + '.js' in line: + if '/' + name + '.js' in line: card_config = line break local.close() if '=' in card_config: local_version = card_config.split('=')[1].split('\n')[0] - _LOGGER.debug('Local version of %s is %s', card, local_version) + _LOGGER.debug('Local version of %s is %s', name, local_version) return local_version return False -class CustomComponents(CustomUpdaterController): +class CustomComponents(object): """Custom components controller.""" def __init__(self, hass, ha_conf_dir, conf_hide_sensor): - super().__init__(hass, ha_conf_dir, conf_hide_sensor) + self.hass = hass + self._hide_sensor = conf_hide_sensor + self.ha_conf_dir = ha_conf_dir self.components = None self.hass.data[COMPONENT_DATA] = {} self.cache_versions() def cache_versions(self): """Cache""" - self.components = super().get_all_available_entities(COMPS_JSON) + self.components = self.get_all_remote_info() self.hass.data[COMPONENT_DATA] = {} if self.components: - for component in self.components: - remote_info = self.get_remote_info(component) - remote_version = remote_info[1] - local_version = self.get_local_version(component, remote_info[2]) + for name, component in self.components.items(): + remote_version = component[1] + local_version = self.get_local_version(name, component[2]) if local_version: has_update = (remote_version != False and remote_version != local_version) not_local = (remote_version != False and not local_version) - self.hass.data[COMPONENT_DATA][component] = { + self.hass.data[COMPONENT_DATA][name] = { "local": local_version, "remote": remote_version, "has_update": has_update, "not_local": not_local, - "repo": remote_info[4], - "change_log": remote_info[5], + "repo": component[4], + "change_log": component[5], } self.hass.data[COMPONENT_DATA]['domain'] = 'custom_components' self.hass.data[COMPONENT_DATA]['repo'] = '#' @@ -313,20 +294,20 @@ def cache_versions(self): def update_all(self): """Update all components""" - for component in self.hass.data[COMPONENT_DATA]: - if component not in ('domain', 'repo'): + for name in self.hass.data[COMPONENT_DATA]: + if name not in ('domain', 'repo'): try: - if self.hass.data[COMPONENT_DATA][component]['has_update'] and not self.hass.data[COMPONENT_DATA][component]['not_local']: - self.upgrade_single(component) - except: - _LOGGER.debug('Skipping upgrade for %s, no update available', component) + if self.hass.data[COMPONENT_DATA][name]['has_update'] and not self.hass.data[COMPONENT_DATA][name]['not_local']: + self.upgrade_single(name) + except KeyError: + _LOGGER.debug('Skipping upgrade for %s, no update available', name) - def upgrade_single(self, component): + def upgrade_single(self, name): """Update one components""" - _LOGGER.debug('Starting upgrade for "%s".', component) - if component in self.hass.data[COMPONENT_DATA]: - if self.hass.data[COMPONENT_DATA][component]['has_update']: - remote_info = self.get_remote_info(component) + _LOGGER.debug('Starting upgrade for "%s".', name) + if name in self.hass.data[COMPONENT_DATA]: + if self.hass.data[COMPONENT_DATA][name]['has_update']: + remote_info = self.get_all_remote_info()[name] remote_file = remote_info[3] local_file = self.ha_conf_dir + remote_info[2] test_remote_file = requests.get(remote_file) @@ -335,41 +316,41 @@ def upgrade_single(self, component): component_file.write(test_remote_file.content) component_file.close() _LOGGER.info('Upgrade of %s from version %s to version %s complete', - component, self.hass.data[COMPONENT_DATA][component]['local'], - self.hass.data[COMPONENT_DATA][component]['remote']) - self.hass.data[COMPONENT_DATA][component]['local'] = self.hass.data[COMPONENT_DATA][component]['remote'] - self.hass.data[COMPONENT_DATA][component]['has_update'] = False - self.hass.data[COMPONENT_DATA][component]['not_local'] = False + name, self.hass.data[COMPONENT_DATA][name]['local'], + self.hass.data[COMPONENT_DATA][name]['remote']) + self.hass.data[COMPONENT_DATA][name]['local'] = self.hass.data[COMPONENT_DATA][name]['remote'] + self.hass.data[COMPONENT_DATA][name]['has_update'] = False + self.hass.data[COMPONENT_DATA][name]['not_local'] = False self.hass.states.set('sensor.custom_component_tracker', time.time(), self.hass.data[COMPONENT_DATA]) else: - _LOGGER.debug('Skipping upgrade for %s, no update available', component) + _LOGGER.debug('Skipping upgrade for %s, no update available', name) else: - _LOGGER.error('Upgrade failed, "%s" is not a valid component', component) + _LOGGER.error('Upgrade failed, "%s" is not a valid component', name) @staticmethod - def get_remote_info(component): - """Return the remote info if any.""" + def get_all_remote_info(): + """Return all remote info if any.""" response = requests.get(COMPS_JSON) - remote_info = [None] + remote_info = {} if response.status_code == 200: - try: - remote = response.json()[component] - remote_info = [ - component, - remote['version'], - remote['local_location'], - remote['remote_location'], - remote['visit_repo'], - remote['changelog'] - ] - except: - _LOGGER.debug('Gathering remote info for %s failed...', component) - remote = False + for name, component in response.json().items(): + try: + component = [ + name, + component['version'], + component['local_location'], + component['remote_location'], + component['visit_repo'], + component['changelog'] + ] + remote_info[name] = component + except KeyError: + _LOGGER.debug('Gathering remote info for %s failed...', name) else: - _LOGGER.debug('Could not get remote info for %s', component) + _LOGGER.debug('Could not get remote info for url %s', COMPS_JSON) return remote_info - def get_local_version(self, component, local_path): + def get_local_version(self, name, local_path): """Return the local version if any.""" local_version = None component_path = self.ha_conf_dir + local_path @@ -382,10 +363,10 @@ def get_local_version(self, component, local_path): local.close() if not local_version: local_v = False - _LOGGER.debug('Could not get the local version for %s', component) + _LOGGER.debug('Could not get the local version for %s', name) else: local_v = local_version - _LOGGER.debug('Local version of %s is %s', component, local_version) + _LOGGER.debug('Local version of %s is %s', name, local_version) else: local_v = False return local_v From 8e0dc09bd1b65d5a1dc853f9a845210659923c18 Mon Sep 17 00:00:00 2001 From: Ryan Horiguchi Date: Sat, 11 Aug 2018 22:37:49 +0200 Subject: [PATCH 06/12] Add .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file From d945a1b968daad8784002444db5a1c6f87842d63 Mon Sep 17 00:00:00 2001 From: Ryan Horiguchi Date: Sun, 12 Aug 2018 02:23:58 +0200 Subject: [PATCH 07/12] Add field that custom url can be defined and Revert config change --- custom_components/custom_updater.py | 128 +++++++++++++++------------- 1 file changed, 70 insertions(+), 58 deletions(-) diff --git a/custom_components/custom_updater.py b/custom_components/custom_updater.py index a6f5650..dcff9d6 100644 --- a/custom_components/custom_updater.py +++ b/custom_components/custom_updater.py @@ -14,7 +14,6 @@ import homeassistant.helpers.config_validation as cv import requests import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.helpers.event import track_time_interval __version__ = '1.4.1' @@ -23,6 +22,8 @@ CONF_TRACK = 'track' CONF_HIDE_SENSOR = 'hide_sensor' +CONF_CARD_CONFIG_URLS = 'card_urls' +CONF_COMPONENT_CONFIG_URLS = 'component_urls' DOMAIN = 'custom_updater' CARD_DATA = 'custom_card_data' @@ -32,29 +33,38 @@ ATTR_CARD = 'card' ATTR_COMPONENT = 'component' -PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ - vol.Required(CONF_TRACK, default=None): - vol.All(cv.ensure_list, [cv.string]), - vol.Optional(CONF_HIDE_SENSOR, default=False): cv.boolean, -}) +CONFIG_SCHEMA = vol.Schema({ + DOMAIN: vol.Schema({ + vol.Optional(CONF_TRACK, default=['cards', 'components']): + vol.All(cv.ensure_list, [cv.string]), + vol.Optional(CONF_HIDE_SENSOR, default=False): cv.boolean, + vol.Optional(CONF_CARD_CONFIG_URLS, default=[]): + vol.All(cv.ensure_list, [cv.url]), + vol.Optional(CONF_COMPONENT_CONFIG_URLS, default=[]): + vol.All(cv.ensure_list, [cv.url]), + }) +}, extra=vol.ALLOW_EXTRA) -CARDS_JSON = 'https://raw.githubusercontent.com/custom-cards/information/master/repos.json' -COMPS_JSON = 'https://raw.githubusercontent.com/custom-components/information/master/repos.json' +DEFAULT_REMOTE_CARD_CONFIG_URL = 'https://raw.githubusercontent.com/custom-cards/information/master/repos.json' +DEFAULT_REMOTE_COMPONENT_CONFIG_URL = 'https://raw.githubusercontent.com/custom-components/information/master/repos.json' def setup(hass, config): """Set up this component.""" - conf_track = config.get(CONF_TRACK) - conf_hide_sensor = config.get(CONF_HIDE_SENSOR) + conf_track = config[DOMAIN][CONF_TRACK] + conf_hide_sensor = config[DOMAIN][CONF_HIDE_SENSOR] + conf_card_urls = [DEFAULT_REMOTE_CARD_CONFIG_URL] + config[DOMAIN][CONF_CARD_CONFIG_URLS] + conf_component_urls = [DEFAULT_REMOTE_COMPONENT_CONFIG_URL] + config[DOMAIN][CONF_COMPONENT_CONFIG_URLS] + _LOGGER.info('version %s is starting, if you have ANY issues with this, please report' ' them here: https://github.com/custom-components/custom_updater', __version__) ha_conf_dir = str(hass.config.path()) - if not conf_track or 'cards' in conf_track: - card_controller = CustomCards(hass, ha_conf_dir, conf_hide_sensor) + if 'cards' in conf_track: + card_controller = CustomCards(hass, ha_conf_dir, conf_hide_sensor, conf_card_urls) track_time_interval(hass, card_controller.cache_versions, INTERVAL) - if not conf_track or 'components' in conf_track: - components_controller = CustomComponents(hass, ha_conf_dir, conf_hide_sensor) + if 'components' in conf_track: + components_controller = CustomComponents(hass, ha_conf_dir, conf_hide_sensor, conf_component_urls) track_time_interval(hass, components_controller.cache_versions, INTERVAL) def check_all_service(call): @@ -90,10 +100,11 @@ def upgrade_component_service(call): class CustomCards(object): """Custom cards controller.""" - def __init__(self, hass, ha_conf_dir, conf_hide_sensor): + def __init__(self, hass, ha_conf_dir, conf_hide_sensor, conf_card_urls): self.hass = hass self._hide_sensor = conf_hide_sensor self.ha_conf_dir = ha_conf_dir + self.conf_card_urls = conf_card_urls self.cards = None self._lovelace_gen = False self.hass.data[CARD_DATA] = {} @@ -119,9 +130,9 @@ def cache_versions(self): self.cards = self.get_all_remote_info() self.hass.data[CARD_DATA] = {} if self.cards: - for name, data in self.cards.items(): - remote_version = data[1] - local_version = self.get_local_version(data[0]) + for name, card in self.cards.items(): + remote_version = card[1] + local_version = self.get_local_version(card[0]) if local_version: has_update = (remote_version != False and remote_version != local_version) not_local = (remote_version != False and not local_version) @@ -130,8 +141,8 @@ def cache_versions(self): "remote": remote_version, "has_update": has_update, "not_local": not_local, - "repo": data[3], - "change_log": data[4], + "repo": card[3], + "change_log": card[4], } self.hass.data[CARD_DATA]['domain'] = 'custom_cards' self.hass.data[CARD_DATA]['repo'] = '#' @@ -209,26 +220,26 @@ def get_card_dir(self, name): break return card_dir - @staticmethod - def get_all_remote_info(): + def get_all_remote_info(self): """Return all remote info if any.""" - response = requests.get(CARDS_JSON) remote_info = {} - if response.status_code == 200: - for name, card in response.json().items(): - try: - card = [ - name, - card['version'], - card['remote_location'], - card['visit_repo'], - card['changelog'] - ] - remote_info[name] = card - except KeyError: - _LOGGER.debug('Gathering remote info for %s failed...', name) - else: - _LOGGER.debug('Could not get remote info for url %s', CARDS_JSON) + for url in self.conf_card_urls: + response = requests.get(url) + if response.status_code == 200: + for name, card in response.json().items(): + try: + card = [ + name, + card['version'], + card['remote_location'], + card['visit_repo'], + card['changelog'] + ] + remote_info[name] = card + except KeyError: + _LOGGER.debug('Gathering remote info for %s failed...', name) + else: + _LOGGER.debug('Could not get remote info for url %s', DEFAULT_REMOTE_CARD_CONFIG_URL) return remote_info def get_local_version(self, name): @@ -259,10 +270,11 @@ def get_local_version(self, name): class CustomComponents(object): """Custom components controller.""" - def __init__(self, hass, ha_conf_dir, conf_hide_sensor): + def __init__(self, hass, ha_conf_dir, conf_hide_sensor, conf_component_urls): self.hass = hass self._hide_sensor = conf_hide_sensor self.ha_conf_dir = ha_conf_dir + self.conf_component_urls = conf_component_urls self.components = None self.hass.data[COMPONENT_DATA] = {} self.cache_versions() @@ -327,27 +339,27 @@ def upgrade_single(self, name): else: _LOGGER.error('Upgrade failed, "%s" is not a valid component', name) - @staticmethod - def get_all_remote_info(): + def get_all_remote_info(self): """Return all remote info if any.""" - response = requests.get(COMPS_JSON) remote_info = {} - if response.status_code == 200: - for name, component in response.json().items(): - try: - component = [ - name, - component['version'], - component['local_location'], - component['remote_location'], - component['visit_repo'], - component['changelog'] - ] - remote_info[name] = component - except KeyError: - _LOGGER.debug('Gathering remote info for %s failed...', name) - else: - _LOGGER.debug('Could not get remote info for url %s', COMPS_JSON) + for url in self.conf_component_urls: + response = requests.get(url) + if response.status_code == 200: + for name, component in response.json().items(): + try: + component = [ + name, + component['version'], + component['local_location'], + component['remote_location'], + component['visit_repo'], + component['changelog'] + ] + remote_info[name] = component + except KeyError: + _LOGGER.debug('Gathering remote info for %s failed...', name) + else: + _LOGGER.debug('Could not get remote info for url %s', DEFAULT_REMOTE_COMPONENT_CONFIG_URL) return remote_info def get_local_version(self, name, local_path): From dddadf3291eb218c19ed4a5ea8781e4d33448ea8 Mon Sep 17 00:00:00 2001 From: Ryan Horiguchi Date: Sun, 12 Aug 2018 02:24:08 +0200 Subject: [PATCH 08/12] Update README.md --- README.md | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6468b61..64114d6 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ A component which allows you to track and update your custom cards and components.\ **To get the best use for this component, use it together with the [tracker-card](https://github.com/custom-cards/tracker-card)** -## ⚠️ This will **ONLY** work if your components and/or cards/elements is from +## ⚠️ This will **ONLY** work if your components and/or cards/elements is from else add custom url - https://github.com/custom-cards - https://github.com/custom-components @@ -45,9 +45,44 @@ custom_updater: | --- | --- | --- | --- | **track** | both | no | A list of what you want this component to track, possible values are `cards`/`components` | **hide_sensor** | False | no | Option to set the sensors to be `hidden`, possible values are `True` / `False` +| **card_urls** | Empty | no | A list of urls to json with card info +| **component_urls** | Empty | no | A list of urls to json with component info *** +### Format of card_urls json + +The json can have multiple cards + +```json +{ + "canvas-gauge-card": { + "updated_at": "2018-08-11", + "version": "0.0.2", + "remote_location": "https://raw.githubusercontent.com/custom-cards/canvas-gauge-card/master/canvas-gauge-card.js", + "visit_repo": "https://github.com/custom-cards/canvas-gauge-card", + "changelog": "https://github.com/custom-cards/canvas-gauge-card/releases/latest" + } +} +``` + +### Format of component_urls json + +The json can have multiple components + +```json +{ + "camera.combined": { + "updated_at": "2018-08-08", + "version": "0.0.1", + "local_location": "/custom_components/camera/combined.py", + "remote_location": "https://raw.githubusercontent.com/custom-components/camera.combined/master/custom_components/camera/combined.py", + "visit_repo": "https://github.com/custom-components/camera.combined", + "changelog": "https://github.com/custom-components/camera.combined/releases/latest" + } +} +``` + ## Activate Debug logging Put this in your `configuration.yaml` From d5b873bdc53cf37b05e2bf7135e374374c1389c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Sun, 12 Aug 2018 12:30:55 +0200 Subject: [PATCH 09/12] Removed unnecessary "warnings" --- README.md | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/README.md b/README.md index 64114d6..afac06e 100644 --- a/README.md +++ b/README.md @@ -3,27 +3,6 @@ A component which allows you to track and update your custom cards and components.\ **To get the best use for this component, use it together with the [tracker-card](https://github.com/custom-cards/tracker-card)** -## ⚠️ This will **ONLY** work if your components and/or cards/elements is from else add custom url - -- https://github.com/custom-cards -- https://github.com/custom-components -- https://github.com/ciotlosm/custom-lovelace - -*** - -## ⚠️ See here **if** you have used an earlier version of this - -Before you install this version make sure that you remove these files (if you have them): - -- `/custom_components/custom_components.py` -- `/custom_components/custom_cards.py` -- `/custom_components/sensor/custom_components.py` -- `/custom_components/sensor/custom_cards.py` - -And remove `custom_components` and `custom_cards` from your `configuration.yaml` - -*** - ## Installation ### Step 1 From 8f1c739d3b958fa15e6c6ae09a0afa193efcfee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Sun, 12 Aug 2018 12:32:47 +0200 Subject: [PATCH 10/12] Minor adjustments and version bump --- custom_components/custom_updater.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/custom_components/custom_updater.py b/custom_components/custom_updater.py index dcff9d6..5fe0c1d 100644 --- a/custom_components/custom_updater.py +++ b/custom_components/custom_updater.py @@ -10,13 +10,12 @@ import subprocess import time from datetime import timedelta - -import homeassistant.helpers.config_validation as cv import requests import voluptuous as vol +import homeassistant.helpers.config_validation as cv from homeassistant.helpers.event import track_time_interval -__version__ = '1.4.1' +__version__ = '2.0.0' _LOGGER = logging.getLogger(__name__) @@ -74,7 +73,7 @@ def check_all_service(call): if not conf_track or 'components' in conf_track: components_controller.cache_versions() - def update_all_service(): + def update_all_service(call): """Set up service for manual trigger.""" if not conf_track or 'cards' in conf_track: card_controller.update_all() @@ -134,7 +133,7 @@ def cache_versions(self): remote_version = card[1] local_version = self.get_local_version(card[0]) if local_version: - has_update = (remote_version != False and remote_version != local_version) + has_update = (remote_version != False and remote_version != local_version and remote_version != '') not_local = (remote_version != False and not local_version) self.hass.data[CARD_DATA][name] = { "local": local_version, @@ -307,8 +306,9 @@ def cache_versions(self): def update_all(self): """Update all components""" for name in self.hass.data[COMPONENT_DATA]: - if name not in ('domain', 'repo'): + if name not in ('domain', 'repo', 'hidden'): try: + _LOGGER.debug('Trying to upgrade %s, no update available', name) if self.hass.data[COMPONENT_DATA][name]['has_update'] and not self.hass.data[COMPONENT_DATA][name]['not_local']: self.upgrade_single(name) except KeyError: From 053e5e3ba1d2d7b3a803c01c3e874e93e9def9b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Sun, 12 Aug 2018 12:33:01 +0200 Subject: [PATCH 11/12] Delete .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 723ef36..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.idea \ No newline at end of file From a90dcdd78cd8726f1011a4ec3f567a2b5948c39d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Sun, 12 Aug 2018 12:37:18 +0200 Subject: [PATCH 12/12] Added clarification about urls --- README.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index afac06e..a3a341e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ A component which allows you to track and update your custom cards and component Install this component by copying `/custom_components/custom_updater.py` from this repo to `/custom_components/custom_updater.py` on your Home Assistant instanse. - ### Step 2 Add this to your `configuration.yaml` @@ -22,10 +21,17 @@ custom_updater: | key | default | required | description | --- | --- | --- | --- -| **track** | both | no | A list of what you want this component to track, possible values are `cards`/`components` -| **hide_sensor** | False | no | Option to set the sensors to be `hidden`, possible values are `True` / `False` -| **card_urls** | Empty | no | A list of urls to json with card info -| **component_urls** | Empty | no | A list of urls to json with component info +| **track** | both | no | A list of what you want this component to track, possible values are `cards`/`components`. +| **hide_sensor** | False | no | Option to set the sensors to be `hidden`, possible values are `True` / `False`. +| **card_urls** | Empty | no | A list of additional urls to json with card info. +| **component_urls** | Empty | no | A list of additional urls to json with component info. + +The component uses these json files to check for updates by default: + +- https://raw.githubusercontent.com/custom-cards/information/master/repos.json +- https://raw.githubusercontent.com/custom-components/information/master/repos.json + +Use the `card_urls` and `component_urls` options in the configuration to add more. ***