Esempio n. 1
0
async def async_setup_entry(hass, config_entry, async_add_entities):
    """Set up the Kumo thermostats."""
    data = hass.data[DOMAIN]
    data._setup_tries += 1
    if data._setup_tries > MAX_SETUP_TRIES:
        raise HomeAssistantError("Giving up trying to set up Kumo")

    devices = []
    units = await hass.async_add_executor_job(
        data.get_account().get_indoor_units)
    for unit in units:
        name = data.get_account().get_name(unit)
        address = data.get_account().get_address(unit)
        credentials = data.get_account().get_credentials(unit)
        connect_timeout = float(data.get_domain_options().get(
            CONF_CONNECT_TIMEOUT, "1.2"))
        response_timeout = float(data.get_domain_options().get(
            CONF_RESPONSE_TIMEOUT, "8"))
        kumo_api = pykumo.PyKumo(name, address, credentials,
                                 (connect_timeout, response_timeout))
        success = await hass.async_add_executor_job(kumo_api.update_status)
        if not success:
            _LOGGER.warning("Kumo %s could not be set up", name)
            continue
        kumo_thermostat = KumoThermostat(kumo_api, unit)
        await hass.async_add_executor_job(kumo_thermostat.update)
        devices.append(kumo_thermostat)
        _LOGGER.debug("Kumo adding entity: %s", name)
    if not devices:
        _LOGGER.warning(
            "Kumo could not set up any indoor units (try %d of %d)",
            data._setup_tries, MAX_SETUP_TRIES)
        raise PlatformNotReady
    async_add_entities(devices, True)
Esempio n. 2
0
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
    """Set up Kumo thermostats."""
    # pylint: disable=C0415
    import pykumo

    # Run once
    global __PLATFORM_IS_SET_UP
    if __PLATFORM_IS_SET_UP:
        return
    __PLATFORM_IS_SET_UP = True

    data = hass.data[KUMO_DATA]
    devices = []
    units = data.get_account().get_indoor_units()
    for unit in units:
        name = data.get_account().get_name(unit)
        address = data.get_account().get_address(unit)
        credentials = data.get_account().get_credentials(unit)
        connect_timeout = data.get_domain_config().get(CONF_CONNECT_TIMEOUT, None)
        response_timeout = data.get_domain_config().get(CONF_RESPONSE_TIMEOUT, None)
        kumo_api = pykumo.PyKumo(name, address, credentials,
                                 (connect_timeout, response_timeout))
        await hass.async_add_executor_job(kumo_api.update_status)
        devices.append(KumoThermostat(kumo_api))
        _LOGGER.debug("Kumo adding entity: %s", name)
    async_add_entities(devices)
Esempio n. 3
0
async def async_setup_platform(hass,
                               config,
                               async_add_entities,
                               discovery_info=None):
    """Set up Kumo thermostats. Run Once"""
    global __PLATFORM_IS_SET_UP
    if __PLATFORM_IS_SET_UP:
        return
    __PLATFORM_IS_SET_UP = True

    data = hass.data[KUMO_DATA]
    devices = []
    units = data.get_account().get_indoor_units()
    for unit in units:
        name = data.get_account().get_name(unit)
        address = data.get_account().get_address(unit)
        credentials = data.get_account().get_credentials(unit)
        if data.get_domain_options().get(CONF_CONNECT_TIMEOUT) is None:
            connect_timeout = 1.2
        else:
            connect_timeout = float(data.get_domain_options().get(
                CONF_CONNECT_TIMEOUT, "1.2"))
        if data.get_domain_options().get(CONF_RESPONSE_TIMEOUT) is None:
            response_timeout = 8.0
        else:
            response_timeout = float(data.get_domain_options().get(
                CONF_RESPONSE_TIMEOUT, "8"))
        kumo_api = pykumo.PyKumo(name, address, credentials,
                                 (connect_timeout, response_timeout))
        await hass.async_add_executor_job(kumo_api.update_status)
        kumo_thermostat = KumoThermostat(kumo_api, unit)
        await hass.async_add_executor_job(kumo_thermostat.update)
        devices.append(kumo_thermostat)
        _LOGGER.debug("Kumo adding entity: %s", name)
    async_add_entities(devices)
Esempio n. 4
0
async def async_setup_platform(hass,
                               config,
                               async_add_entities,
                               discovery_info=None):
    """Set up Kumo thermostats. Run Once"""
    global __PLATFORM_IS_SET_UP
    if __PLATFORM_IS_SET_UP:
        return
    __PLATFORM_IS_SET_UP = True

    data = hass.data[KUMO_DATA]
    data._setup_tries += 1
    if data._setup_tries > MAX_SETUP_TRIES:
        raise HomeAssistantError("Giving up trying to set up Kumo")

    devices = []
    units = data.get_account().get_indoor_units()
    for unit in units:
        name = data.get_account().get_name(unit)
        address = data.get_account().get_address(unit)
        credentials = data.get_account().get_credentials(unit)
        if data.get_domain_options().get(CONF_CONNECT_TIMEOUT) is None:
            connect_timeout = 1.2
        else:
            connect_timeout = float(data.get_domain_options().get(
                CONF_CONNECT_TIMEOUT, "1.2"))
        if data.get_domain_options().get(CONF_RESPONSE_TIMEOUT) is None:
            response_timeout = 8.0
        else:
            response_timeout = float(data.get_domain_options().get(
                CONF_RESPONSE_TIMEOUT, "8"))
        kumo_api = pykumo.PyKumo(name, address, credentials,
                                 (connect_timeout, response_timeout))
        success = await hass.async_add_executor_job(kumo_api.update_status)
        if not success:
            _LOGGER.warning("Kumo %s could not be set up", name)
            continue
        kumo_thermostat = KumoThermostat(kumo_api, unit)
        await hass.async_add_executor_job(kumo_thermostat.update)
        devices.append(kumo_thermostat)
        _LOGGER.debug("Kumo adding entity: %s", name)
    if not devices:
        _LOGGER.warning(
            "Kumo could not set up any indoor units (try %d of %d)",
            data._setup_tries,
            MAX_SETUP_TRIES,
        )
        raise PlatformNotReady
    async_add_entities(devices)
Esempio n. 5
0
    def __init__(self, name, address, config_js, timeouts):
        """Initialize the thermostat."""
        import pykumo

        self._name = name
        self._target_temperature = None
        self._target_temperature_low = None
        self._target_temperature_high = None
        self._current_humidity = None
        self._hvac_mode = None
        self._hvac_action = None
        self._fan_mode = None
        self._swing_mode = None
        self._current_temperature = None
        self._battery_percent = None
        self._filter_dirty = None
        self._defrost = None
        self._pykumo = pykumo.PyKumo(name,
                                     address,
                                     config_js,
                                     timeouts=timeouts)
        self._fan_modes = self._pykumo.get_fan_speeds()
        self._swing_modes = self._pykumo.get_vane_directions()
        self._hvac_modes = [HVAC_MODE_OFF, HVAC_MODE_COOL]
        self._supported_features = (SUPPORT_TARGET_TEMPERATURE
                                    | SUPPORT_FAN_MODE)
        if self._pykumo.has_dry_mode():
            self._hvac_modes.append(HVAC_MODE_DRY)
        if self._pykumo.has_heat_mode():
            self._hvac_modes.append(HVAC_MODE_HEAT)
        if self._pykumo.has_vent_mode():
            self._hvac_modes.append(HVAC_MODE_FAN_ONLY)
        if self._pykumo.has_auto_mode():
            self._hvac_modes.append(HVAC_MODE_HEAT_COOL)
            self._supported_features |= SUPPORT_TARGET_TEMPERATURE_RANGE
        if self._pykumo.has_vane_direction():
            self._supported_features |= SUPPORT_SWING_MODE
        for prop in KumoThermostat._update_properties:
            try:
                setattr(self, "_%s" % prop, None)
            except AttributeError as err:
                _LOGGER.debug("Kumo %s: Initializing attr %s error: %s",
                              self._name, prop, str(err))

        self._available = True
Esempio n. 6
0
async def async_setup_entry(hass, config_entry, async_add_entities):
    """Set up the Kumo thermostat."""
    data = hass.data[DOMAIN]
    devices = []
    units = await hass.async_add_executor_job(
        data.get_account().get_indoor_units)
    for unit in units:
        name = data.get_account().get_name(unit)
        address = data.get_account().get_address(unit)
        credentials = data.get_account().get_credentials(unit)
        connect_timeout = float(data.get_domain_options().get(
            CONF_CONNECT_TIMEOUT, "1.2"))
        response_timeout = float(data.get_domain_options().get(
            CONF_RESPONSE_TIMEOUT, "8"))
        kumo_api = pykumo.PyKumo(name, address, credentials,
                                 (connect_timeout, response_timeout))
        await hass.async_add_executor_job(kumo_api.update_status)
        kumo_thermostat = KumoThermostat(kumo_api, unit)
        await hass.async_add_executor_job(kumo_thermostat.update)
        devices.append(kumo_thermostat)
        _LOGGER.debug("Kumo adding entity: %s", name)
    async_add_entities(devices, True)