2020-01-05 12:09:17 +00:00
|
|
|
"""Plugwise Climate component for Home Assistant."""
|
2022-02-10 16:13:22 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
from collections.abc import Mapping
|
2022-02-05 16:09:49 +00:00
|
|
|
from typing import Any
|
2019-08-01 20:22:57 +00:00
|
|
|
|
2022-04-26 07:03:23 +00:00
|
|
|
from homeassistant.components.climate import ClimateEntity
|
2019-08-01 20:22:57 +00:00
|
|
|
from homeassistant.components.climate.const import (
|
2022-04-26 07:03:23 +00:00
|
|
|
ClimateEntityFeature,
|
|
|
|
HVACAction,
|
|
|
|
HVACMode,
|
2019-08-01 20:22:57 +00:00
|
|
|
)
|
2022-01-03 12:09:43 +00:00
|
|
|
from homeassistant.config_entries import ConfigEntry
|
Update plugwise to async and config_flow (#33691)
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Fix formatting for pyupgrade
* Update homeassistant/components/plugwise/__init__.py
Co-Authored-By: Robert Svensson <Kane610@users.noreply.github.com>
* Add try/except on setup
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Readd already reviewd await try/except
* Readd already reviewed config_flow
* Fix pylint
* Fix per 0.109 translations
* Remove unused import from merge
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Bump module version
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Fix pylint
* Fix per 0.109 translations
* Translations and config_flow, module version bump with required changes
* Translations and config_flow, module version bump with required changes
* Fix requirements
* Fix requirements
* Fix pylint
* Fix pylint
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Include configentrynotready on import
* Update __init__.py
* DataUpdateCoordinator and comment non-PR-platforms
* Fix reqs
* Rename devices variable in favor of entities
* Rework updates with DataUpdateCoordinator
* Peer review
* Peer review second part
* Cleanup comments and redundant code
* Added required config_flow test
* Peer review third part
* Update service was replaced by DataUpdateCoordinator
* Corrected testing, version bump for InvalidAuth, move uniq_id
* Remove according to review
* Await connect (py38)
* Remove unneccesary code
* Show only when multiple
* Improve config_flow, rename consts
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Process review comments
Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-05-28 15:52:25 +00:00
|
|
|
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
2022-02-10 16:13:22 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
2022-01-03 12:09:43 +00:00
|
|
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
Update plugwise to async and config_flow (#33691)
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Fix formatting for pyupgrade
* Update homeassistant/components/plugwise/__init__.py
Co-Authored-By: Robert Svensson <Kane610@users.noreply.github.com>
* Add try/except on setup
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Readd already reviewd await try/except
* Readd already reviewed config_flow
* Fix pylint
* Fix per 0.109 translations
* Remove unused import from merge
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Bump module version
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Fix pylint
* Fix per 0.109 translations
* Translations and config_flow, module version bump with required changes
* Translations and config_flow, module version bump with required changes
* Fix requirements
* Fix requirements
* Fix pylint
* Fix pylint
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Include configentrynotready on import
* Update __init__.py
* DataUpdateCoordinator and comment non-PR-platforms
* Fix reqs
* Rename devices variable in favor of entities
* Rework updates with DataUpdateCoordinator
* Peer review
* Peer review second part
* Cleanup comments and redundant code
* Added required config_flow test
* Peer review third part
* Update service was replaced by DataUpdateCoordinator
* Corrected testing, version bump for InvalidAuth, move uniq_id
* Remove according to review
* Await connect (py38)
* Remove unneccesary code
* Show only when multiple
* Improve config_flow, rename consts
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Process review comments
Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-05-28 15:52:25 +00:00
|
|
|
|
2022-03-21 20:13:03 +00:00
|
|
|
from .const import DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP, DOMAIN, THERMOSTAT_CLASSES
|
2022-02-06 17:03:50 +00:00
|
|
|
from .coordinator import PlugwiseDataUpdateCoordinator
|
2022-02-05 18:09:37 +00:00
|
|
|
from .entity import PlugwiseEntity
|
2022-02-10 08:53:26 +00:00
|
|
|
from .util import plugwise_command
|
Update plugwise to async and config_flow (#33691)
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Fix formatting for pyupgrade
* Update homeassistant/components/plugwise/__init__.py
Co-Authored-By: Robert Svensson <Kane610@users.noreply.github.com>
* Add try/except on setup
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Readd already reviewd await try/except
* Readd already reviewed config_flow
* Fix pylint
* Fix per 0.109 translations
* Remove unused import from merge
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Bump module version
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Fix pylint
* Fix per 0.109 translations
* Translations and config_flow, module version bump with required changes
* Translations and config_flow, module version bump with required changes
* Fix requirements
* Fix requirements
* Fix pylint
* Fix pylint
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Include configentrynotready on import
* Update __init__.py
* DataUpdateCoordinator and comment non-PR-platforms
* Fix reqs
* Rename devices variable in favor of entities
* Rework updates with DataUpdateCoordinator
* Peer review
* Peer review second part
* Cleanup comments and redundant code
* Added required config_flow test
* Peer review third part
* Update service was replaced by DataUpdateCoordinator
* Corrected testing, version bump for InvalidAuth, move uniq_id
* Remove according to review
* Await connect (py38)
* Remove unneccesary code
* Show only when multiple
* Improve config_flow, rename consts
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Process review comments
Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-05-28 15:52:25 +00:00
|
|
|
|
2019-08-01 20:22:57 +00:00
|
|
|
|
2022-01-03 12:09:43 +00:00
|
|
|
async def async_setup_entry(
|
|
|
|
hass: HomeAssistant,
|
|
|
|
config_entry: ConfigEntry,
|
|
|
|
async_add_entities: AddEntitiesCallback,
|
|
|
|
) -> None:
|
Update plugwise to async and config_flow (#33691)
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Fix formatting for pyupgrade
* Update homeassistant/components/plugwise/__init__.py
Co-Authored-By: Robert Svensson <Kane610@users.noreply.github.com>
* Add try/except on setup
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Readd already reviewd await try/except
* Readd already reviewed config_flow
* Fix pylint
* Fix per 0.109 translations
* Remove unused import from merge
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Bump module version
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Fix pylint
* Fix per 0.109 translations
* Translations and config_flow, module version bump with required changes
* Translations and config_flow, module version bump with required changes
* Fix requirements
* Fix requirements
* Fix pylint
* Fix pylint
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Include configentrynotready on import
* Update __init__.py
* DataUpdateCoordinator and comment non-PR-platforms
* Fix reqs
* Rename devices variable in favor of entities
* Rework updates with DataUpdateCoordinator
* Peer review
* Peer review second part
* Cleanup comments and redundant code
* Added required config_flow test
* Peer review third part
* Update service was replaced by DataUpdateCoordinator
* Corrected testing, version bump for InvalidAuth, move uniq_id
* Remove according to review
* Await connect (py38)
* Remove unneccesary code
* Show only when multiple
* Improve config_flow, rename consts
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Process review comments
Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-05-28 15:52:25 +00:00
|
|
|
"""Set up the Smile Thermostats from a config entry."""
|
2022-02-08 19:17:49 +00:00
|
|
|
coordinator = hass.data[DOMAIN][config_entry.entry_id]
|
|
|
|
async_add_entities(
|
|
|
|
PlugwiseClimateEntity(coordinator, device_id)
|
|
|
|
for device_id, device in coordinator.data.devices.items()
|
2022-05-12 13:19:50 +00:00
|
|
|
if device["dev_class"] in THERMOSTAT_CLASSES
|
2022-02-08 19:17:49 +00:00
|
|
|
)
|
2019-08-01 20:22:57 +00:00
|
|
|
|
Update plugwise to async and config_flow (#33691)
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Fix formatting for pyupgrade
* Update homeassistant/components/plugwise/__init__.py
Co-Authored-By: Robert Svensson <Kane610@users.noreply.github.com>
* Add try/except on setup
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Readd already reviewd await try/except
* Readd already reviewed config_flow
* Fix pylint
* Fix per 0.109 translations
* Remove unused import from merge
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Bump module version
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Fix pylint
* Fix per 0.109 translations
* Translations and config_flow, module version bump with required changes
* Translations and config_flow, module version bump with required changes
* Fix requirements
* Fix requirements
* Fix pylint
* Fix pylint
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Include configentrynotready on import
* Update __init__.py
* DataUpdateCoordinator and comment non-PR-platforms
* Fix reqs
* Rename devices variable in favor of entities
* Rework updates with DataUpdateCoordinator
* Peer review
* Peer review second part
* Cleanup comments and redundant code
* Added required config_flow test
* Peer review third part
* Update service was replaced by DataUpdateCoordinator
* Corrected testing, version bump for InvalidAuth, move uniq_id
* Remove according to review
* Await connect (py38)
* Remove unneccesary code
* Show only when multiple
* Improve config_flow, rename consts
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Process review comments
Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-05-28 15:52:25 +00:00
|
|
|
|
2022-02-08 10:13:05 +00:00
|
|
|
class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity):
|
Update plugwise to async and config_flow (#33691)
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Fix formatting for pyupgrade
* Update homeassistant/components/plugwise/__init__.py
Co-Authored-By: Robert Svensson <Kane610@users.noreply.github.com>
* Add try/except on setup
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Readd already reviewd await try/except
* Readd already reviewed config_flow
* Fix pylint
* Fix per 0.109 translations
* Remove unused import from merge
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Bump module version
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Fix pylint
* Fix per 0.109 translations
* Translations and config_flow, module version bump with required changes
* Translations and config_flow, module version bump with required changes
* Fix requirements
* Fix requirements
* Fix pylint
* Fix pylint
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Include configentrynotready on import
* Update __init__.py
* DataUpdateCoordinator and comment non-PR-platforms
* Fix reqs
* Rename devices variable in favor of entities
* Rework updates with DataUpdateCoordinator
* Peer review
* Peer review second part
* Cleanup comments and redundant code
* Added required config_flow test
* Peer review third part
* Update service was replaced by DataUpdateCoordinator
* Corrected testing, version bump for InvalidAuth, move uniq_id
* Remove according to review
* Await connect (py38)
* Remove unneccesary code
* Show only when multiple
* Improve config_flow, rename consts
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Process review comments
Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-05-28 15:52:25 +00:00
|
|
|
"""Representation of an Plugwise thermostat."""
|
|
|
|
|
2022-02-05 16:09:49 +00:00
|
|
|
_attr_temperature_unit = TEMP_CELSIUS
|
|
|
|
|
Update plugwise to async and config_flow (#33691)
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Fix formatting for pyupgrade
* Update homeassistant/components/plugwise/__init__.py
Co-Authored-By: Robert Svensson <Kane610@users.noreply.github.com>
* Add try/except on setup
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Readd already reviewd await try/except
* Readd already reviewed config_flow
* Fix pylint
* Fix per 0.109 translations
* Remove unused import from merge
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Bump module version
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Fix pylint
* Fix per 0.109 translations
* Translations and config_flow, module version bump with required changes
* Translations and config_flow, module version bump with required changes
* Fix requirements
* Fix requirements
* Fix pylint
* Fix pylint
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Include configentrynotready on import
* Update __init__.py
* DataUpdateCoordinator and comment non-PR-platforms
* Fix reqs
* Rename devices variable in favor of entities
* Rework updates with DataUpdateCoordinator
* Peer review
* Peer review second part
* Cleanup comments and redundant code
* Added required config_flow test
* Peer review third part
* Update service was replaced by DataUpdateCoordinator
* Corrected testing, version bump for InvalidAuth, move uniq_id
* Remove according to review
* Await connect (py38)
* Remove unneccesary code
* Show only when multiple
* Improve config_flow, rename consts
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Process review comments
Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-05-28 15:52:25 +00:00
|
|
|
def __init__(
|
2022-02-05 16:09:49 +00:00
|
|
|
self,
|
2022-02-06 17:03:50 +00:00
|
|
|
coordinator: PlugwiseDataUpdateCoordinator,
|
2022-02-08 10:13:05 +00:00
|
|
|
device_id: str,
|
2022-02-05 16:09:49 +00:00
|
|
|
) -> None:
|
2019-08-01 20:22:57 +00:00
|
|
|
"""Set up the Plugwise API."""
|
2022-02-08 18:08:01 +00:00
|
|
|
super().__init__(coordinator, device_id)
|
2022-02-05 16:09:49 +00:00
|
|
|
self._attr_extra_state_attributes = {}
|
2022-02-08 10:13:05 +00:00
|
|
|
self._attr_unique_id = f"{device_id}-climate"
|
2022-02-10 16:13:22 +00:00
|
|
|
self._attr_name = self.device.get("name")
|
|
|
|
|
|
|
|
# Determine preset modes
|
2022-04-07 13:03:42 +00:00
|
|
|
self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
2022-05-12 13:19:50 +00:00
|
|
|
if presets := self.device.get("preset_modes"):
|
2022-04-07 13:03:42 +00:00
|
|
|
self._attr_supported_features |= ClimateEntityFeature.PRESET_MODE
|
2022-05-12 13:19:50 +00:00
|
|
|
self._attr_preset_modes = presets
|
2022-02-10 16:13:22 +00:00
|
|
|
|
|
|
|
# Determine hvac modes and current hvac mode
|
2022-04-26 07:03:23 +00:00
|
|
|
self._attr_hvac_modes = [HVACMode.HEAT]
|
2022-02-10 16:13:22 +00:00
|
|
|
if self.coordinator.data.gateway.get("cooling_present"):
|
2022-04-26 07:03:23 +00:00
|
|
|
self._attr_hvac_modes.append(HVACMode.COOL)
|
2022-02-10 17:10:21 +00:00
|
|
|
if self.device.get("available_schedules") != ["None"]:
|
2022-04-26 07:03:23 +00:00
|
|
|
self._attr_hvac_modes.append(HVACMode.AUTO)
|
2022-02-10 16:13:22 +00:00
|
|
|
|
2022-02-17 13:11:47 +00:00
|
|
|
self._attr_min_temp = self.device.get("lower_bound", DEFAULT_MIN_TEMP)
|
|
|
|
self._attr_max_temp = self.device.get("upper_bound", DEFAULT_MAX_TEMP)
|
|
|
|
if resolution := self.device.get("resolution"):
|
|
|
|
# Ensure we don't drop below 0.1
|
|
|
|
self._attr_target_temperature_step = max(resolution, 0.1)
|
|
|
|
|
2022-02-10 16:13:22 +00:00
|
|
|
@property
|
|
|
|
def current_temperature(self) -> float | None:
|
|
|
|
"""Return the current temperature."""
|
|
|
|
return self.device["sensors"].get("temperature")
|
|
|
|
|
|
|
|
@property
|
|
|
|
def target_temperature(self) -> float | None:
|
|
|
|
"""Return the temperature we try to reach."""
|
|
|
|
return self.device["sensors"].get("setpoint")
|
|
|
|
|
|
|
|
@property
|
2022-04-26 07:03:23 +00:00
|
|
|
def hvac_mode(self) -> HVACMode:
|
2022-02-10 16:13:22 +00:00
|
|
|
"""Return HVAC operation ie. heat, cool mode."""
|
|
|
|
if (mode := self.device.get("mode")) is None or mode not in self.hvac_modes:
|
2022-04-26 07:03:23 +00:00
|
|
|
return HVACMode.HEAT
|
|
|
|
return HVACMode(mode)
|
2022-02-10 16:13:22 +00:00
|
|
|
|
|
|
|
@property
|
2022-04-26 07:03:23 +00:00
|
|
|
def hvac_action(self) -> HVACAction:
|
2022-02-10 16:13:22 +00:00
|
|
|
"""Return the current running hvac operation if supported."""
|
2022-02-10 19:53:14 +00:00
|
|
|
# When control_state is present, prefer this data
|
|
|
|
if "control_state" in self.device:
|
|
|
|
if self.device.get("control_state") == "cooling":
|
2022-04-26 07:03:23 +00:00
|
|
|
return HVACAction.COOLING
|
2022-02-20 19:45:19 +00:00
|
|
|
# Support preheating state as heating, until preheating is added as a separate state
|
|
|
|
if self.device.get("control_state") in ["heating", "preheating"]:
|
2022-04-26 07:03:23 +00:00
|
|
|
return HVACAction.HEATING
|
2022-02-10 19:53:14 +00:00
|
|
|
else:
|
|
|
|
heater_central_data = self.coordinator.data.devices[
|
|
|
|
self.coordinator.data.gateway["heater_id"]
|
|
|
|
]
|
2022-02-20 19:45:19 +00:00
|
|
|
if heater_central_data["binary_sensors"].get("heating_state"):
|
2022-04-26 07:03:23 +00:00
|
|
|
return HVACAction.HEATING
|
2022-02-20 19:45:19 +00:00
|
|
|
if heater_central_data["binary_sensors"].get("cooling_state"):
|
2022-04-26 07:03:23 +00:00
|
|
|
return HVACAction.COOLING
|
2022-05-23 08:59:10 +00:00
|
|
|
|
2022-04-26 07:03:23 +00:00
|
|
|
return HVACAction.IDLE
|
2022-02-10 16:13:22 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def preset_mode(self) -> str | None:
|
|
|
|
"""Return the current preset mode."""
|
|
|
|
return self.device.get("active_preset")
|
|
|
|
|
|
|
|
@property
|
|
|
|
def extra_state_attributes(self) -> Mapping[str, Any] | None:
|
|
|
|
"""Return entity specific state attributes."""
|
|
|
|
return {
|
|
|
|
"available_schemas": self.device.get("available_schedules"),
|
|
|
|
"selected_schema": self.device.get("selected_schedule"),
|
|
|
|
}
|
Update plugwise to async and config_flow (#33691)
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Fix formatting for pyupgrade
* Update homeassistant/components/plugwise/__init__.py
Co-Authored-By: Robert Svensson <Kane610@users.noreply.github.com>
* Add try/except on setup
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Readd already reviewd await try/except
* Readd already reviewed config_flow
* Fix pylint
* Fix per 0.109 translations
* Remove unused import from merge
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Bump module version
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Fix pylint
* Fix per 0.109 translations
* Translations and config_flow, module version bump with required changes
* Translations and config_flow, module version bump with required changes
* Fix requirements
* Fix requirements
* Fix pylint
* Fix pylint
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Include configentrynotready on import
* Update __init__.py
* DataUpdateCoordinator and comment non-PR-platforms
* Fix reqs
* Rename devices variable in favor of entities
* Rework updates with DataUpdateCoordinator
* Peer review
* Peer review second part
* Cleanup comments and redundant code
* Added required config_flow test
* Peer review third part
* Update service was replaced by DataUpdateCoordinator
* Corrected testing, version bump for InvalidAuth, move uniq_id
* Remove according to review
* Await connect (py38)
* Remove unneccesary code
* Show only when multiple
* Improve config_flow, rename consts
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Process review comments
Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-05-28 15:52:25 +00:00
|
|
|
|
2022-02-10 08:53:26 +00:00
|
|
|
@plugwise_command
|
2022-02-05 16:09:49 +00:00
|
|
|
async def async_set_temperature(self, **kwargs: Any) -> None:
|
2019-08-01 20:22:57 +00:00
|
|
|
"""Set new target temperature."""
|
2022-02-10 08:53:26 +00:00
|
|
|
if ((temperature := kwargs.get(ATTR_TEMPERATURE)) is None) or (
|
|
|
|
self._attr_max_temp < temperature < self._attr_min_temp
|
Update plugwise to async and config_flow (#33691)
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Fix formatting for pyupgrade
* Update homeassistant/components/plugwise/__init__.py
Co-Authored-By: Robert Svensson <Kane610@users.noreply.github.com>
* Add try/except on setup
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Readd already reviewd await try/except
* Readd already reviewed config_flow
* Fix pylint
* Fix per 0.109 translations
* Remove unused import from merge
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Bump module version
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Fix pylint
* Fix per 0.109 translations
* Translations and config_flow, module version bump with required changes
* Translations and config_flow, module version bump with required changes
* Fix requirements
* Fix requirements
* Fix pylint
* Fix pylint
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Include configentrynotready on import
* Update __init__.py
* DataUpdateCoordinator and comment non-PR-platforms
* Fix reqs
* Rename devices variable in favor of entities
* Rework updates with DataUpdateCoordinator
* Peer review
* Peer review second part
* Cleanup comments and redundant code
* Added required config_flow test
* Peer review third part
* Update service was replaced by DataUpdateCoordinator
* Corrected testing, version bump for InvalidAuth, move uniq_id
* Remove according to review
* Await connect (py38)
* Remove unneccesary code
* Show only when multiple
* Improve config_flow, rename consts
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Process review comments
Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-05-28 15:52:25 +00:00
|
|
|
):
|
2022-02-10 08:53:26 +00:00
|
|
|
raise ValueError("Invalid temperature requested")
|
2022-02-10 16:13:22 +00:00
|
|
|
await self.coordinator.api.set_temperature(self.device["location"], temperature)
|
2019-08-01 20:22:57 +00:00
|
|
|
|
2022-02-10 08:53:26 +00:00
|
|
|
@plugwise_command
|
2022-04-26 07:03:23 +00:00
|
|
|
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
2019-08-01 20:22:57 +00:00
|
|
|
"""Set the hvac mode."""
|
2022-02-10 08:53:26 +00:00
|
|
|
await self.coordinator.api.set_schedule_state(
|
2022-02-10 17:10:21 +00:00
|
|
|
self.device["location"],
|
|
|
|
self.device.get("last_used"),
|
2022-04-26 07:03:23 +00:00
|
|
|
"on" if hvac_mode == HVACMode.AUTO else "off",
|
2022-02-10 08:53:26 +00:00
|
|
|
)
|
Update plugwise to async and config_flow (#33691)
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Fix formatting for pyupgrade
* Update homeassistant/components/plugwise/__init__.py
Co-Authored-By: Robert Svensson <Kane610@users.noreply.github.com>
* Add try/except on setup
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Readd already reviewd await try/except
* Readd already reviewed config_flow
* Fix pylint
* Fix per 0.109 translations
* Remove unused import from merge
* Update plugwise async, config_flow and multi entity
* Update battery percentage
* Fix yamllint on services
* Fix yamllint on services
* Bump module version
* Bump module version, battery version and valve position
* Removing sensor, switch, water_heater for later (child) PRs
* Catchup and version bump
* Remove title from strings.json
* Fix pylint
* Fix per 0.109 translations
* Translations and config_flow, module version bump with required changes
* Translations and config_flow, module version bump with required changes
* Fix requirements
* Fix requirements
* Fix pylint
* Fix pylint
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/__init__.py
Improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
* Include configentrynotready on import
* Update __init__.py
* DataUpdateCoordinator and comment non-PR-platforms
* Fix reqs
* Rename devices variable in favor of entities
* Rework updates with DataUpdateCoordinator
* Peer review
* Peer review second part
* Cleanup comments and redundant code
* Added required config_flow test
* Peer review third part
* Update service was replaced by DataUpdateCoordinator
* Corrected testing, version bump for InvalidAuth, move uniq_id
* Remove according to review
* Await connect (py38)
* Remove unneccesary code
* Show only when multiple
* Improve config_flow, rename consts
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Update homeassistant/components/plugwise/climate.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Process review comments
Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-05-28 15:52:25 +00:00
|
|
|
|
2022-02-10 08:53:26 +00:00
|
|
|
@plugwise_command
|
2022-02-05 16:09:49 +00:00
|
|
|
async def async_set_preset_mode(self, preset_mode: str) -> None:
|
2019-08-01 20:22:57 +00:00
|
|
|
"""Set the preset mode."""
|
2022-02-10 16:13:22 +00:00
|
|
|
await self.coordinator.api.set_preset(self.device["location"], preset_mode)
|