def __init__(self, name, username, password, host, port, min_temp, max_temp): _LOGGER.debug("Anna: Init called") self._name = name self._username = username self._password = password self._host = host self._port = port self._temperature = None self._current_temperature = None self._outdoor_temperature = None self._state = None self._hold_mode = None self._away_mode = False self._min_temp = min_temp self._max_temp = max_temp self._operation_list = DEFAULT_OPERATION_LIST _LOGGER.debug("Anna: Initializing API") self._api = haanna.Haanna(self._username, self._password, self._host, self._port) try: self._api.ping_anna_thermostat() except: _LOGGER.error("Anna: Unable to ping, platform not ready") raise PlatformNotReady _LOGGER.debug("Anna: platform ready") self.update()
def update(self): """Update the data from the thermostat""" import haanna api = haanna.Haanna(self._username, self._password, self._host) domain_objects = api.get_domain_objects() self._current_temperature = api.get_temperature(domain_objects) self._outdoor_temperature = api.get_outdoor_temperature(domain_objects) self._temperature = api.get_target_temperature(domain_objects) _LOGGER.debug("Update called")
def set_temperature(self, **kwargs): """Set new target temperature""" import haanna temperature = kwargs.get(ATTR_TEMPERATURE) if temperature is not None: self._temperature = temperature api = haanna.Haanna(self._username, self._password, self._host) domain_objects = api.get_domain_objects() api.set_temperature(domain_objects, temperature) self.schedule_update_ha_state()
def setup_platform(hass, config, add_entities, discovery_info=None): """Add the Plugwise (Anna) Thermostate.""" api = haanna.Haanna( config[CONF_USERNAME], config[CONF_PASSWORD], config[CONF_HOST], config[CONF_PORT], ) try: api.ping_anna_thermostat() except OSError: _LOGGER.debug("Ping failed, retrying later", exc_info=True) raise PlatformNotReady devices = [ ThermostatDevice(api, config[CONF_NAME], config[CONF_MIN_TEMP], config[CONF_MAX_TEMP]) ] add_entities(devices, True)
def setup(hass, config): """Add the Plugwise (Anna) Thermostate.""" conf = config.get(DOMAIN) if conf is None: raise PlatformNotReady #conf = {} _LOGGER.info('Plugwise %s', conf) hass.data[DOMAIN] = {} if CONF_SMILE in conf: smiles = conf[CONF_SMILE] _LOGGER.info('Smiles %s', smiles) hass.data[DOMAIN][CONF_SMILE] = {} for smile in smiles: _LOGGER.info('Smile %s', smile) smile_config = smile[0] api = haanna.Haanna( smile_config[CONF_USERNAME], smile_config[CONF_PASSWORD], smile_config[CONF_HOST], smile_config[CONF_PORT], smile_config[CONF_LEGACY], ) try: api.ping_anna_thermostat() except OSError: _LOGGER.debug("Ping failed, retrying later", exc_info=True) raise PlatformNotReady hass.data[DOMAIN][CONF_SMILE][smile_config[CONF_NAME]] = { 'api': api } hass.helpers.discovery.load_platform('climate', DOMAIN, {}, config) hass.helpers.discovery.load_platform('sensor', DOMAIN, {}, config) _LOGGER.info('Config %s', hass.data[DOMAIN]) return True