def update_linky_data(self, event_time=None): """Fetch new state data for the sensor.""" client = LinkyClient(self._username, self._password, None, self._timeout) try: client.login() client.fetch_data() self._data = client.get_data() _LOGGER.debug(json.dumps(self._data, indent=2)) except PyLinkyException as exp: _LOGGER.error(exp) finally: client.close_session()
def setup_platform(hass, config, add_entities, discovery_info=None): """Configure the platform and add the Linky sensor.""" username = config[CONF_USERNAME] password = config[CONF_PASSWORD] timeout = config[CONF_TIMEOUT] from pylinky.client import LinkyClient, PyLinkyError client = LinkyClient(username, password, None, timeout) try: client.fetch_data() except PyLinkyError as exp: _LOGGER.error(exp) return devices = [LinkySensor('Linky', client)] add_entities(devices, True)
def setup_platform(hass, config, add_entities, discovery_info=None): """Configure the platform and add the Linky sensor.""" username = config[CONF_USERNAME] password = config[CONF_PASSWORD] timeout = config[CONF_TIMEOUT] prix = config[CONF_PRIX] _LOGGER.debug("prix : " + str(prix)) from pylinky.client import LinkyClient, PyLinkyError client = LinkyClient(username, password, None, timeout) try: client.login() client.fetch_data() except PyLinkyError as exp: _LOGGER.error(exp) client.close_session() return devices = [LinkySensor('Linky / hier', client, 'daily', 'compteur', None)] add_entities(devices, True) devices = [ LinkySensor('Linky / Mois Current', client, "monthly", 'compteur', None) ] add_entities(devices, True) devices = [ LinkySensor('Linky / Année Current', client, "yearly", 'compteur', None) ] add_entities(devices, True) devices = [LinkySensor('Prix / hier', client, 'daily', 'prix', prix)] add_entities(devices, True) devices = [ LinkySensor('Prix / Mois Current', client, "monthly", 'prix', prix) ] add_entities(devices, True) devices = [ LinkySensor('prix / Année Current', client, "yearly", 'prix', prix) ] add_entities(devices, True)