|
@@ -4,44 +4,21 @@
|
|
| 4 |
|
| 5 |
from typing import Any
|
| 6 |
|
| 7 |
-
from
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
from homeassistant.const import CONF_TIMEOUT, Platform
|
| 11 |
-
from homeassistant.core import (
|
| 12 |
-
HomeAssistant,
|
| 13 |
-
ServiceCall, # pw-beta delete_notification
|
| 14 |
-
callback,
|
| 15 |
-
)
|
| 16 |
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
| 17 |
|
| 18 |
-
from .const import
|
| 19 |
-
CONF_REFRESH_INTERVAL, # pw-beta options
|
| 20 |
-
DOMAIN,
|
| 21 |
-
LOGGER,
|
| 22 |
-
PLATFORMS,
|
| 23 |
-
SERVICE_DELETE, # pw-beta delete_notifications
|
| 24 |
-
)
|
| 25 |
from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator
|
| 26 |
|
| 27 |
|
| 28 |
async def async_setup_entry(hass: HomeAssistant, entry: PlugwiseConfigEntry) -> bool:
|
| 29 |
-
"""Set up Plugwise from a config entry."""
|
| 30 |
await er.async_migrate_entries(hass, entry.entry_id, async_migrate_entity_entry)
|
| 31 |
|
| 32 |
-
|
| 33 |
-
if (
|
| 34 |
-
custom_refresh := entry.options.get(CONF_REFRESH_INTERVAL)
|
| 35 |
-
) is not None: # pragma: no cover
|
| 36 |
-
cooldown = custom_refresh
|
| 37 |
-
LOGGER.debug("DUC cooldown interval: %s", cooldown)
|
| 38 |
-
|
| 39 |
-
coordinator = PlugwiseDataUpdateCoordinator(
|
| 40 |
-
hass, cooldown, entry
|
| 41 |
-
) # pw-beta - cooldown, update_interval as extra
|
| 42 |
await coordinator.async_config_entry_first_refresh()
|
| 43 |
-
|
| 44 |
-
await async_migrate_sensor_entities(hass, coordinator)
|
| 45 |
|
| 46 |
entry.runtime_data = coordinator
|
| 47 |
|
|
@@ -56,49 +33,21 @@
|
|
| 56 |
sw_version=str(coordinator.api.smile.version),
|
| 57 |
) # required for adding the entity-less P1 Gateway
|
| 58 |
|
| 59 |
-
async def delete_notification(
|
| 60 |
-
call: ServiceCall,
|
| 61 |
-
) -> None: # pragma: no cover # pw-beta: HA service - delete_notification
|
| 62 |
-
"""Service: delete the Plugwise Notification."""
|
| 63 |
-
LOGGER.debug(
|
| 64 |
-
"Service delete PW Notification called for %s",
|
| 65 |
-
coordinator.api.smile.name,
|
| 66 |
-
)
|
| 67 |
-
try:
|
| 68 |
-
await coordinator.api.delete_notification()
|
| 69 |
-
LOGGER.debug("PW Notification deleted")
|
| 70 |
-
except PlugwiseError:
|
| 71 |
-
LOGGER.debug(
|
| 72 |
-
"Failed to delete the Plugwise Notification for %s",
|
| 73 |
-
coordinator.api.smile.name,
|
| 74 |
-
)
|
| 75 |
-
|
| 76 |
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
| 77 |
|
| 78 |
-
entry.async_on_unload(entry.add_update_listener(update_listener)) # pw-beta options_flow
|
| 79 |
-
for component in PLATFORMS: # pw-beta delete_notification
|
| 80 |
-
if component == Platform.BINARY_SENSOR:
|
| 81 |
-
hass.services.async_register(
|
| 82 |
-
DOMAIN, SERVICE_DELETE, delete_notification, schema=vol.Schema({})
|
| 83 |
-
)
|
| 84 |
-
|
| 85 |
return True
|
| 86 |
|
| 87 |
-
async def update_listener(
|
| 88 |
-
hass: HomeAssistant, entry: PlugwiseConfigEntry
|
| 89 |
-
) -> None: # pragma: no cover # pw-beta
|
| 90 |
-
"""Handle options update."""
|
| 91 |
-
await hass.config_entries.async_reload(entry.entry_id)
|
| 92 |
|
| 93 |
async def async_unload_entry(hass: HomeAssistant, entry: PlugwiseConfigEntry) -> bool:
|
| 94 |
-
"""Unload Plugwise."""
|
| 95 |
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
| 96 |
|
|
|
|
| 97 |
@callback
|
| 98 |
def async_migrate_entity_entry(entry: er.RegistryEntry) -> dict[str, Any] | None:
|
| 99 |
"""Migrate Plugwise entity entries.
|
| 100 |
|
| 101 |
-
|
| 102 |
"""
|
| 103 |
if entry.domain == Platform.BINARY_SENSOR and entry.unique_id.endswith(
|
| 104 |
"-slave_boiler_state"
|
|
@@ -120,17 +69,18 @@
|
|
| 120 |
# No migration needed
|
| 121 |
return None
|
| 122 |
|
| 123 |
-
|
|
|
|
| 124 |
hass: HomeAssistant,
|
| 125 |
coordinator: PlugwiseDataUpdateCoordinator,
|
| 126 |
) -> None:
|
| 127 |
"""Migrate Sensors if needed."""
|
| 128 |
ent_reg = er.async_get(hass)
|
| 129 |
|
| 130 |
-
#
|
| 131 |
# to opentherm_outdoor_air_temperature sensor
|
| 132 |
for device_id, device in coordinator.data.items():
|
| 133 |
-
if device[
|
| 134 |
continue
|
| 135 |
|
| 136 |
old_unique_id = f"{device_id}-outdoor_temperature"
|
|
@@ -138,27 +88,10 @@
|
|
| 138 |
Platform.SENSOR, DOMAIN, old_unique_id
|
| 139 |
):
|
| 140 |
new_unique_id = f"{device_id}-outdoor_air_temperature"
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
ent_reg.async_update_entity(entity_id, new_unique_id=new_unique_id)
|
| 143 |
-
|
| 144 |
-
# pw-beta only - revert adding CONF_TIMEOUT to config_entry in v0.53.3
|
| 145 |
-
async def async_migrate_entry(hass: HomeAssistant, entry: PlugwiseConfigEntry) -> bool:
|
| 146 |
-
"""Migrate back to v1.1 config entry."""
|
| 147 |
-
if entry.version > 1:
|
| 148 |
-
# This means the user has downgraded from a future version
|
| 149 |
-
return False #pragma: no cover
|
| 150 |
-
|
| 151 |
-
if entry.version == 1 and entry.minor_version == 2:
|
| 152 |
-
new_data = {**entry.data}
|
| 153 |
-
new_data.pop(CONF_TIMEOUT)
|
| 154 |
-
hass.config_entries.async_update_entry(
|
| 155 |
-
entry, data=new_data, minor_version=1, version=1
|
| 156 |
-
)
|
| 157 |
-
|
| 158 |
-
LOGGER.debug(
|
| 159 |
-
"Migration to version %s.%s successful",
|
| 160 |
-
entry.version,
|
| 161 |
-
entry.minor_version,
|
| 162 |
-
)
|
| 163 |
-
|
| 164 |
-
return True
|
|
|
|
| 4 |
|
| 5 |
from typing import Any
|
| 6 |
|
| 7 |
+
from homeassistant.const import Platform
|
| 8 |
+
from homeassistant.core import HomeAssistant, callback
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
| 10 |
|
| 11 |
+
from .const import DEV_CLASS, DOMAIN, LOGGER, PLATFORMS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator
|
| 13 |
|
| 14 |
|
| 15 |
async def async_setup_entry(hass: HomeAssistant, entry: PlugwiseConfigEntry) -> bool:
|
| 16 |
+
"""Set up Plugwise components from a config entry."""
|
| 17 |
await er.async_migrate_entries(hass, entry.entry_id, async_migrate_entity_entry)
|
| 18 |
|
| 19 |
+
coordinator = PlugwiseDataUpdateCoordinator(hass, entry)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
await coordinator.async_config_entry_first_refresh()
|
| 21 |
+
migrate_sensor_entities(hass, coordinator)
|
|
|
|
| 22 |
|
| 23 |
entry.runtime_data = coordinator
|
| 24 |
|
|
|
|
| 33 |
sw_version=str(coordinator.api.smile.version),
|
| 34 |
) # required for adding the entity-less P1 Gateway
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
return True
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
async def async_unload_entry(hass: HomeAssistant, entry: PlugwiseConfigEntry) -> bool:
|
| 42 |
+
"""Unload the Plugwise components."""
|
| 43 |
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
| 44 |
|
| 45 |
+
|
| 46 |
@callback
|
| 47 |
def async_migrate_entity_entry(entry: er.RegistryEntry) -> dict[str, Any] | None:
|
| 48 |
"""Migrate Plugwise entity entries.
|
| 49 |
|
| 50 |
+
Migrates old unique ID's from old binary_sensors and switches to the new unique ID's.
|
| 51 |
"""
|
| 52 |
if entry.domain == Platform.BINARY_SENSOR and entry.unique_id.endswith(
|
| 53 |
"-slave_boiler_state"
|
|
|
|
| 69 |
# No migration needed
|
| 70 |
return None
|
| 71 |
|
| 72 |
+
|
| 73 |
+
def migrate_sensor_entities(
|
| 74 |
hass: HomeAssistant,
|
| 75 |
coordinator: PlugwiseDataUpdateCoordinator,
|
| 76 |
) -> None:
|
| 77 |
"""Migrate Sensors if needed."""
|
| 78 |
ent_reg = er.async_get(hass)
|
| 79 |
|
| 80 |
+
# Migrating opentherm_outdoor_temperature
|
| 81 |
# to opentherm_outdoor_air_temperature sensor
|
| 82 |
for device_id, device in coordinator.data.items():
|
| 83 |
+
if device[DEV_CLASS] != "heater_central":
|
| 84 |
continue
|
| 85 |
|
| 86 |
old_unique_id = f"{device_id}-outdoor_temperature"
|
|
|
|
| 88 |
Platform.SENSOR, DOMAIN, old_unique_id
|
| 89 |
):
|
| 90 |
new_unique_id = f"{device_id}-outdoor_air_temperature"
|
| 91 |
+
LOGGER.debug(
|
| 92 |
+
"Migrating entity %s from old unique ID '%s' to new unique ID '%s'",
|
| 93 |
+
entity_id,
|
| 94 |
+
old_unique_id,
|
| 95 |
+
new_unique_id,
|
| 96 |
+
)
|
| 97 |
ent_reg.async_update_entity(entity_id, new_unique_id=new_unique_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -8,9 +8,6 @@
|
|
| 8 |
|
| 9 |
from plugwise.constants import BinarySensorType
|
| 10 |
|
| 11 |
-
from homeassistant.components import (
|
| 12 |
-
persistent_notification, # pw-beta Plugwise notifications
|
| 13 |
-
)
|
| 14 |
from homeassistant.components.binary_sensor import (
|
| 15 |
BinarySensorDeviceClass,
|
| 16 |
BinarySensorEntity,
|
|
@@ -20,26 +17,11 @@
|
|
| 20 |
from homeassistant.core import HomeAssistant, callback
|
| 21 |
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
| 22 |
|
| 23 |
-
from .const import (
|
| 24 |
-
BATTERY_STATE,
|
| 25 |
-
BINARY_SENSORS,
|
| 26 |
-
COMPRESSOR_STATE,
|
| 27 |
-
COOLING_ENABLED,
|
| 28 |
-
COOLING_STATE,
|
| 29 |
-
DHW_STATE,
|
| 30 |
-
DOMAIN,
|
| 31 |
-
FLAME_STATE,
|
| 32 |
-
HEATING_STATE,
|
| 33 |
-
LOGGER, # pw-beta
|
| 34 |
-
PLUGWISE_NOTIFICATION,
|
| 35 |
-
SECONDARY_BOILER_STATE,
|
| 36 |
-
SEVERITIES,
|
| 37 |
-
)
|
| 38 |
-
|
| 39 |
-
# Upstream
|
| 40 |
from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator
|
| 41 |
from .entity import PlugwiseEntity
|
| 42 |
|
|
|
|
|
|
|
| 43 |
# Coordinator is used to centralize the data updates
|
| 44 |
PARALLEL_UPDATES = 0
|
| 45 |
|
|
@@ -51,51 +33,50 @@
|
|
| 51 |
key: BinarySensorType
|
| 52 |
|
| 53 |
|
| 54 |
-
|
| 55 |
-
PLUGWISE_BINARY_SENSORS: tuple[PlugwiseBinarySensorEntityDescription, ...] = (
|
| 56 |
PlugwiseBinarySensorEntityDescription(
|
| 57 |
-
key=
|
| 58 |
device_class=BinarySensorDeviceClass.BATTERY,
|
| 59 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 60 |
),
|
| 61 |
PlugwiseBinarySensorEntityDescription(
|
| 62 |
-
key=
|
| 63 |
-
translation_key=
|
| 64 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 65 |
),
|
| 66 |
PlugwiseBinarySensorEntityDescription(
|
| 67 |
-
key=
|
| 68 |
-
translation_key=
|
| 69 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 70 |
),
|
| 71 |
PlugwiseBinarySensorEntityDescription(
|
| 72 |
-
key=
|
| 73 |
-
translation_key=
|
| 74 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 75 |
),
|
| 76 |
PlugwiseBinarySensorEntityDescription(
|
| 77 |
-
key=
|
| 78 |
-
translation_key=
|
| 79 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 80 |
),
|
| 81 |
PlugwiseBinarySensorEntityDescription(
|
| 82 |
-
key=
|
| 83 |
-
translation_key=
|
| 84 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 85 |
),
|
| 86 |
PlugwiseBinarySensorEntityDescription(
|
| 87 |
-
key=
|
| 88 |
-
translation_key=
|
| 89 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 90 |
),
|
| 91 |
PlugwiseBinarySensorEntityDescription(
|
| 92 |
-
key=
|
| 93 |
-
translation_key=
|
| 94 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 95 |
),
|
| 96 |
PlugwiseBinarySensorEntityDescription(
|
| 97 |
-
key=
|
| 98 |
-
translation_key=
|
| 99 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 100 |
),
|
| 101 |
)
|
|
@@ -106,7 +87,7 @@
|
|
| 106 |
entry: PlugwiseConfigEntry,
|
| 107 |
async_add_entities: AddConfigEntryEntitiesCallback,
|
| 108 |
) -> None:
|
| 109 |
-
"""Set up
|
| 110 |
coordinator = entry.runtime_data
|
| 111 |
|
| 112 |
@callback
|
|
@@ -115,40 +96,20 @@
|
|
| 115 |
if not coordinator.new_devices:
|
| 116 |
return
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
# )
|
| 126 |
-
# )
|
| 127 |
-
# for description in PLUGWISE_BINARY_SENSORS
|
| 128 |
-
# if description.key in binary_sensors
|
| 129 |
-
# )
|
| 130 |
-
|
| 131 |
-
# pw-beta alternative for debugging
|
| 132 |
-
entities: list[PlugwiseBinarySensorEntity] = []
|
| 133 |
-
for device_id in coordinator.new_devices:
|
| 134 |
-
device = coordinator.data[device_id]
|
| 135 |
-
if not (binary_sensors := device.get(BINARY_SENSORS)):
|
| 136 |
-
continue
|
| 137 |
-
for description in PLUGWISE_BINARY_SENSORS:
|
| 138 |
-
if description.key not in binary_sensors:
|
| 139 |
-
continue
|
| 140 |
-
entities.append(PlugwiseBinarySensorEntity(coordinator, device_id, description))
|
| 141 |
-
LOGGER.debug(
|
| 142 |
-
"Add %s %s binary sensor", device["name"], description.translation_key
|
| 143 |
-
)
|
| 144 |
-
async_add_entities(entities)
|
| 145 |
|
| 146 |
_add_entities()
|
| 147 |
entry.async_on_unload(coordinator.async_add_listener(_add_entities))
|
| 148 |
|
| 149 |
|
| 150 |
class PlugwiseBinarySensorEntity(PlugwiseEntity, BinarySensorEntity):
|
| 151 |
-
"""
|
| 152 |
|
| 153 |
entity_description: PlugwiseBinarySensorEntityDescription
|
| 154 |
|
|
@@ -162,46 +123,26 @@
|
|
| 162 |
super().__init__(coordinator, device_id)
|
| 163 |
self.entity_description = description
|
| 164 |
self._attr_unique_id = f"{device_id}-{description.key}"
|
| 165 |
-
self._notification: dict[str, str] = {} # pw-beta
|
| 166 |
|
| 167 |
@property
|
| 168 |
-
def is_on(self) -> bool
|
| 169 |
"""Return true if the binary sensor is on."""
|
| 170 |
-
|
| 171 |
-
if self._notification:
|
| 172 |
-
for notify_id, message in self._notification.items():
|
| 173 |
-
persistent_notification.async_create(
|
| 174 |
-
self.hass, message, "Plugwise Notification:", f"{DOMAIN}.{notify_id}"
|
| 175 |
-
)
|
| 176 |
-
|
| 177 |
-
return self.device.get(BINARY_SENSORS, {}).get(self.entity_description.key)
|
| 178 |
|
| 179 |
@property
|
| 180 |
def extra_state_attributes(self) -> Mapping[str, Any] | None:
|
| 181 |
"""Return entity specific state attributes."""
|
| 182 |
-
if self.entity_description.key !=
|
| 183 |
return None
|
| 184 |
|
| 185 |
-
|
| 186 |
-
# not all severities including those without content as empty lists
|
| 187 |
-
attrs: dict[str, list[str]] = {} # pw-beta Re-evaluate against Core
|
| 188 |
-
self._notification = {} # pw-beta
|
| 189 |
gateway_id = self.coordinator.api.gateway_id
|
| 190 |
if notify := self.coordinator.data[gateway_id]["notifications"]:
|
| 191 |
-
for
|
| 192 |
for msg_type, msg in details.items():
|
| 193 |
msg_type = msg_type.lower()
|
| 194 |
if msg_type not in SEVERITIES:
|
| 195 |
-
msg_type = "other"
|
| 196 |
-
|
| 197 |
-
if (
|
| 198 |
-
f"{msg_type}_msg" not in attrs
|
| 199 |
-
): # pw-beta Re-evaluate against Core
|
| 200 |
-
attrs[f"{msg_type}_msg"] = []
|
| 201 |
attrs[f"{msg_type}_msg"].append(msg)
|
| 202 |
|
| 203 |
-
self._notification[
|
| 204 |
-
notify_id
|
| 205 |
-
] = f"{msg_type.title()}: {msg}" # pw-beta
|
| 206 |
-
|
| 207 |
return attrs
|
|
|
|
| 8 |
|
| 9 |
from plugwise.constants import BinarySensorType
|
| 10 |
|
|
|
|
|
|
|
|
|
|
| 11 |
from homeassistant.components.binary_sensor import (
|
| 12 |
BinarySensorDeviceClass,
|
| 13 |
BinarySensorEntity,
|
|
|
|
| 17 |
from homeassistant.core import HomeAssistant, callback
|
| 18 |
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator
|
| 21 |
from .entity import PlugwiseEntity
|
| 22 |
|
| 23 |
+
SEVERITIES = ["other", "info", "warning", "error"]
|
| 24 |
+
|
| 25 |
# Coordinator is used to centralize the data updates
|
| 26 |
PARALLEL_UPDATES = 0
|
| 27 |
|
|
|
|
| 33 |
key: BinarySensorType
|
| 34 |
|
| 35 |
|
| 36 |
+
BINARY_SENSORS: tuple[PlugwiseBinarySensorEntityDescription, ...] = (
|
|
|
|
| 37 |
PlugwiseBinarySensorEntityDescription(
|
| 38 |
+
key="low_battery",
|
| 39 |
device_class=BinarySensorDeviceClass.BATTERY,
|
| 40 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 41 |
),
|
| 42 |
PlugwiseBinarySensorEntityDescription(
|
| 43 |
+
key="compressor_state",
|
| 44 |
+
translation_key="compressor_state",
|
| 45 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 46 |
),
|
| 47 |
PlugwiseBinarySensorEntityDescription(
|
| 48 |
+
key="cooling_enabled",
|
| 49 |
+
translation_key="cooling_enabled",
|
| 50 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 51 |
),
|
| 52 |
PlugwiseBinarySensorEntityDescription(
|
| 53 |
+
key="dhw_state",
|
| 54 |
+
translation_key="dhw_state",
|
| 55 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 56 |
),
|
| 57 |
PlugwiseBinarySensorEntityDescription(
|
| 58 |
+
key="flame_state",
|
| 59 |
+
translation_key="flame_state",
|
| 60 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 61 |
),
|
| 62 |
PlugwiseBinarySensorEntityDescription(
|
| 63 |
+
key="heating_state",
|
| 64 |
+
translation_key="heating_state",
|
| 65 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 66 |
),
|
| 67 |
PlugwiseBinarySensorEntityDescription(
|
| 68 |
+
key="cooling_state",
|
| 69 |
+
translation_key="cooling_state",
|
| 70 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 71 |
),
|
| 72 |
PlugwiseBinarySensorEntityDescription(
|
| 73 |
+
key="secondary_boiler_state",
|
| 74 |
+
translation_key="secondary_boiler_state",
|
| 75 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 76 |
),
|
| 77 |
PlugwiseBinarySensorEntityDescription(
|
| 78 |
+
key="plugwise_notification",
|
| 79 |
+
translation_key="plugwise_notification",
|
| 80 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 81 |
),
|
| 82 |
)
|
|
|
|
| 87 |
entry: PlugwiseConfigEntry,
|
| 88 |
async_add_entities: AddConfigEntryEntitiesCallback,
|
| 89 |
) -> None:
|
| 90 |
+
"""Set up the Smile binary_sensors from a config entry."""
|
| 91 |
coordinator = entry.runtime_data
|
| 92 |
|
| 93 |
@callback
|
|
|
|
| 96 |
if not coordinator.new_devices:
|
| 97 |
return
|
| 98 |
|
| 99 |
+
async_add_entities(
|
| 100 |
+
PlugwiseBinarySensorEntity(coordinator, device_id, description)
|
| 101 |
+
for device_id in coordinator.new_devices
|
| 102 |
+
if (binary_sensors := coordinator.data[device_id].get("binary_sensors"))
|
| 103 |
+
for description in BINARY_SENSORS
|
| 104 |
+
if description.key in binary_sensors
|
| 105 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
_add_entities()
|
| 108 |
entry.async_on_unload(coordinator.async_add_listener(_add_entities))
|
| 109 |
|
| 110 |
|
| 111 |
class PlugwiseBinarySensorEntity(PlugwiseEntity, BinarySensorEntity):
|
| 112 |
+
"""Represent Smile Binary Sensors."""
|
| 113 |
|
| 114 |
entity_description: PlugwiseBinarySensorEntityDescription
|
| 115 |
|
|
|
|
| 123 |
super().__init__(coordinator, device_id)
|
| 124 |
self.entity_description = description
|
| 125 |
self._attr_unique_id = f"{device_id}-{description.key}"
|
|
|
|
| 126 |
|
| 127 |
@property
|
| 128 |
+
def is_on(self) -> bool:
|
| 129 |
"""Return true if the binary sensor is on."""
|
| 130 |
+
return self.device["binary_sensors"][self.entity_description.key]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
@property
|
| 133 |
def extra_state_attributes(self) -> Mapping[str, Any] | None:
|
| 134 |
"""Return entity specific state attributes."""
|
| 135 |
+
if self.entity_description.key != "plugwise_notification":
|
| 136 |
return None
|
| 137 |
|
| 138 |
+
attrs: dict[str, list[str]] = {f"{severity}_msg": [] for severity in SEVERITIES}
|
|
|
|
|
|
|
|
|
|
| 139 |
gateway_id = self.coordinator.api.gateway_id
|
| 140 |
if notify := self.coordinator.data[gateway_id]["notifications"]:
|
| 141 |
+
for details in notify.values():
|
| 142 |
for msg_type, msg in details.items():
|
| 143 |
msg_type = msg_type.lower()
|
| 144 |
if msg_type not in SEVERITIES:
|
| 145 |
+
msg_type = "other"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
attrs[f"{msg_type}_msg"].append(msg)
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
return attrs
|
|
@@ -7,10 +7,7 @@
|
|
| 7 |
from homeassistant.core import HomeAssistant
|
| 8 |
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
| 9 |
|
| 10 |
-
from .const import
|
| 11 |
-
LOGGER, # pw-betea
|
| 12 |
-
REBOOT,
|
| 13 |
-
)
|
| 14 |
from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator
|
| 15 |
from .entity import PlugwiseEntity
|
| 16 |
from .util import plugwise_command
|
|
@@ -23,21 +20,14 @@
|
|
| 23 |
entry: PlugwiseConfigEntry,
|
| 24 |
async_add_entities: AddConfigEntryEntitiesCallback,
|
| 25 |
) -> None:
|
| 26 |
-
"""Set up Plugwise buttons from a
|
| 27 |
coordinator = entry.runtime_data
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
# pw-beta alternative for debugging
|
| 35 |
-
entities: list[PlugwiseButtonEntity] = []
|
| 36 |
-
for device_id, device in coordinator.data.items():
|
| 37 |
-
if device_id == coordinator.api.gateway_id and coordinator.api.reboot:
|
| 38 |
-
entities.append(PlugwiseButtonEntity(coordinator, device_id))
|
| 39 |
-
LOGGER.debug("Add %s reboot button", device["name"])
|
| 40 |
-
async_add_entities(entities)
|
| 41 |
|
| 42 |
|
| 43 |
class PlugwiseButtonEntity(PlugwiseEntity, ButtonEntity):
|
|
|
|
| 7 |
from homeassistant.core import HomeAssistant
|
| 8 |
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
| 9 |
|
| 10 |
+
from .const import REBOOT
|
|
|
|
|
|
|
|
|
|
| 11 |
from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator
|
| 12 |
from .entity import PlugwiseEntity
|
| 13 |
from .util import plugwise_command
|
|
|
|
| 20 |
entry: PlugwiseConfigEntry,
|
| 21 |
async_add_entities: AddConfigEntryEntitiesCallback,
|
| 22 |
) -> None:
|
| 23 |
+
"""Set up the Plugwise buttons from a ConfigEntry."""
|
| 24 |
coordinator = entry.runtime_data
|
| 25 |
|
| 26 |
+
async_add_entities(
|
| 27 |
+
PlugwiseButtonEntity(coordinator, device_id)
|
| 28 |
+
for device_id in coordinator.data
|
| 29 |
+
if device_id == coordinator.api.gateway_id and coordinator.api.reboot
|
| 30 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
|
| 33 |
class PlugwiseButtonEntity(PlugwiseEntity, ButtonEntity):
|
|
@@ -9,47 +9,18 @@
|
|
| 9 |
ATTR_HVAC_MODE,
|
| 10 |
ATTR_TARGET_TEMP_HIGH,
|
| 11 |
ATTR_TARGET_TEMP_LOW,
|
| 12 |
-
PRESET_AWAY, # pw-beta homekit emulation
|
| 13 |
-
PRESET_HOME, # pw-beta homekit emulation
|
| 14 |
ClimateEntity,
|
| 15 |
ClimateEntityFeature,
|
| 16 |
HVACAction,
|
| 17 |
HVACMode,
|
| 18 |
)
|
| 19 |
-
from homeassistant.const import
|
| 20 |
-
ATTR_NAME,
|
| 21 |
-
ATTR_TEMPERATURE,
|
| 22 |
-
STATE_OFF,
|
| 23 |
-
STATE_ON,
|
| 24 |
-
UnitOfTemperature,
|
| 25 |
-
)
|
| 26 |
from homeassistant.core import HomeAssistant, callback
|
| 27 |
from homeassistant.exceptions import HomeAssistantError
|
| 28 |
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
| 29 |
from homeassistant.helpers.restore_state import ExtraStoredData, RestoreEntity
|
| 30 |
|
| 31 |
-
from .const import
|
| 32 |
-
ACTIVE_PRESET,
|
| 33 |
-
AVAILABLE_SCHEDULES,
|
| 34 |
-
CLIMATE_MODE,
|
| 35 |
-
CONF_HOMEKIT_EMULATION, # pw-beta homekit emulation
|
| 36 |
-
CONTROL_STATE,
|
| 37 |
-
DEV_CLASS,
|
| 38 |
-
DOMAIN,
|
| 39 |
-
LOCATION,
|
| 40 |
-
LOGGER,
|
| 41 |
-
LOWER_BOUND,
|
| 42 |
-
MASTER_THERMOSTATS,
|
| 43 |
-
REGULATION_MODES,
|
| 44 |
-
RESOLUTION,
|
| 45 |
-
SELECT_REGULATION_MODE,
|
| 46 |
-
SENSORS,
|
| 47 |
-
TARGET_TEMP,
|
| 48 |
-
TARGET_TEMP_HIGH,
|
| 49 |
-
TARGET_TEMP_LOW,
|
| 50 |
-
THERMOSTAT,
|
| 51 |
-
UPPER_BOUND,
|
| 52 |
-
)
|
| 53 |
from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator
|
| 54 |
from .entity import PlugwiseEntity
|
| 55 |
from .util import plugwise_command
|
|
@@ -58,49 +29,6 @@
|
|
| 58 |
PARALLEL_UPDATES = 0
|
| 59 |
|
| 60 |
|
| 61 |
-
async def async_setup_entry(
|
| 62 |
-
hass: HomeAssistant,
|
| 63 |
-
entry: PlugwiseConfigEntry,
|
| 64 |
-
async_add_entities: AddConfigEntryEntitiesCallback,
|
| 65 |
-
) -> None:
|
| 66 |
-
"""Set up Plugwise thermostats from a config entry."""
|
| 67 |
-
coordinator = entry.runtime_data
|
| 68 |
-
homekit_enabled: bool = entry.options.get(
|
| 69 |
-
CONF_HOMEKIT_EMULATION, False
|
| 70 |
-
) # pw-beta homekit emulation
|
| 71 |
-
|
| 72 |
-
@callback
|
| 73 |
-
def _add_entities() -> None:
|
| 74 |
-
"""Add Entities during init and runtime."""
|
| 75 |
-
if not coordinator.new_devices:
|
| 76 |
-
return
|
| 77 |
-
|
| 78 |
-
entities: list[PlugwiseClimateEntity] = []
|
| 79 |
-
gateway_name = coordinator.api.smile.name
|
| 80 |
-
for device_id in coordinator.new_devices:
|
| 81 |
-
device = coordinator.data[device_id]
|
| 82 |
-
if gateway_name == "Adam":
|
| 83 |
-
if device[DEV_CLASS] == "climate":
|
| 84 |
-
entities.append(
|
| 85 |
-
PlugwiseClimateEntity(
|
| 86 |
-
coordinator, device_id, homekit_enabled
|
| 87 |
-
) # pw-beta homekit emulation
|
| 88 |
-
)
|
| 89 |
-
LOGGER.debug("Add climate %s", device[ATTR_NAME])
|
| 90 |
-
elif device[DEV_CLASS] in MASTER_THERMOSTATS:
|
| 91 |
-
entities.append(
|
| 92 |
-
PlugwiseClimateEntity(
|
| 93 |
-
coordinator, device_id, homekit_enabled
|
| 94 |
-
) # pw-beta homekit emulation
|
| 95 |
-
)
|
| 96 |
-
LOGGER.debug("Add climate %s", device[ATTR_NAME])
|
| 97 |
-
|
| 98 |
-
async_add_entities(entities)
|
| 99 |
-
|
| 100 |
-
_add_entities()
|
| 101 |
-
entry.async_on_unload(coordinator.async_add_listener(_add_entities))
|
| 102 |
-
|
| 103 |
-
|
| 104 |
@dataclass
|
| 105 |
class PlugwiseClimateExtraStoredData(ExtraStoredData):
|
| 106 |
"""Object to hold extra stored data."""
|
|
@@ -124,18 +52,46 @@
|
|
| 124 |
)
|
| 125 |
|
| 126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity, RestoreEntity):
|
| 128 |
"""Representation of a Plugwise thermostat."""
|
| 129 |
|
| 130 |
-
_attr_has_entity_name = True
|
| 131 |
_attr_name = None
|
| 132 |
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
| 133 |
_attr_translation_key = DOMAIN
|
| 134 |
-
_enable_turn_on_off_backwards_compatibility = False
|
| 135 |
|
| 136 |
_last_active_schedule: str | None = None
|
| 137 |
-
_previous_action_mode: str | None = HVACAction.HEATING.value
|
| 138 |
-
_homekit_mode: HVACMode | None = None # pw-beta homekit emulation + intentional unsort
|
| 139 |
|
| 140 |
async def async_added_to_hass(self) -> None:
|
| 141 |
"""Run when entity about to be added."""
|
|
@@ -152,26 +108,17 @@
|
|
| 152 |
self,
|
| 153 |
coordinator: PlugwiseDataUpdateCoordinator,
|
| 154 |
device_id: str,
|
| 155 |
-
homekit_enabled: bool, # pw-beta homekit emulation
|
| 156 |
) -> None:
|
| 157 |
"""Set up the Plugwise API."""
|
| 158 |
super().__init__(coordinator, device_id)
|
|
|
|
| 159 |
|
| 160 |
gateway_id: str = coordinator.api.gateway_id
|
| 161 |
self._gateway_data = coordinator.data[gateway_id]
|
| 162 |
-
self._homekit_enabled = homekit_enabled # pw-beta homekit emulation
|
| 163 |
self._location = device_id
|
| 164 |
-
if (location := self.device.get(
|
| 165 |
self._location = location
|
| 166 |
|
| 167 |
-
self._attr_max_temp = min(self.device.get(THERMOSTAT, {}).get(UPPER_BOUND, 35.0), 35.0)
|
| 168 |
-
self._attr_min_temp = self.device.get(THERMOSTAT, {}).get(LOWER_BOUND, 0.0)
|
| 169 |
-
# Ensure we don't drop below 0.1
|
| 170 |
-
self._attr_target_temperature_step = max(
|
| 171 |
-
self.device.get(THERMOSTAT, {}).get(RESOLUTION, 0.5), 0.1
|
| 172 |
-
)
|
| 173 |
-
self._attr_unique_id = f"{device_id}-climate"
|
| 174 |
-
|
| 175 |
# Determine supported features
|
| 176 |
self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
| 177 |
if (
|
|
@@ -185,14 +132,21 @@
|
|
| 185 |
self._attr_supported_features |= (
|
| 186 |
ClimateEntityFeature.TURN_OFF | ClimateEntityFeature.TURN_ON
|
| 187 |
)
|
| 188 |
-
if presets := self.device.get("preset_modes"
|
| 189 |
self._attr_supported_features |= ClimateEntityFeature.PRESET_MODE
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
|
| 192 |
@property
|
| 193 |
-
def current_temperature(self) -> float
|
| 194 |
"""Return the current temperature."""
|
| 195 |
-
return self.device
|
| 196 |
|
| 197 |
@property
|
| 198 |
def extra_restore_state_data(self) -> PlugwiseClimateExtraStoredData:
|
|
@@ -203,64 +157,52 @@
|
|
| 203 |
)
|
| 204 |
|
| 205 |
@property
|
| 206 |
-
def target_temperature(self) -> float
|
| 207 |
"""Return the temperature we try to reach.
|
| 208 |
|
| 209 |
Connected to the HVACMode combination of AUTO-HEAT.
|
| 210 |
"""
|
| 211 |
|
| 212 |
-
return self.device
|
| 213 |
|
| 214 |
@property
|
| 215 |
-
def target_temperature_high(self) -> float
|
| 216 |
"""Return the temperature we try to reach in case of cooling.
|
| 217 |
|
| 218 |
Connected to the HVACMode combination of AUTO-HEAT_COOL.
|
| 219 |
"""
|
| 220 |
-
return self.device
|
| 221 |
|
| 222 |
@property
|
| 223 |
-
def target_temperature_low(self) -> float
|
| 224 |
"""Return the heating temperature we try to reach in case of heating.
|
| 225 |
|
| 226 |
Connected to the HVACMode combination AUTO-HEAT_COOL.
|
| 227 |
"""
|
| 228 |
-
return self.device
|
| 229 |
|
| 230 |
@property
|
| 231 |
def hvac_mode(self) -> HVACMode:
|
| 232 |
"""Return HVAC operation ie. auto, cool, heat, heat_cool, or off mode."""
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
except ValueError: # pragma: no cover
|
| 239 |
-
return HVACMode.HEAT # pragma: no cover
|
| 240 |
-
if hvac not in self.hvac_modes:
|
| 241 |
-
return HVACMode.HEAT # pragma: no cover
|
| 242 |
-
# pw-beta homekit emulation
|
| 243 |
-
if self._homekit_enabled and self._homekit_mode == HVACMode.OFF:
|
| 244 |
-
return HVACMode.OFF # pragma: no cover
|
| 245 |
-
|
| 246 |
-
return hvac
|
| 247 |
|
| 248 |
@property
|
| 249 |
def hvac_modes(self) -> list[HVACMode]:
|
| 250 |
"""Return a list of available HVACModes."""
|
| 251 |
hvac_modes: list[HVACMode] = []
|
| 252 |
-
if
|
| 253 |
-
self._homekit_enabled # pw-beta homekit emulation
|
| 254 |
-
or REGULATION_MODES in self._gateway_data
|
| 255 |
-
):
|
| 256 |
hvac_modes.append(HVACMode.OFF)
|
| 257 |
|
| 258 |
-
if self.device.get(
|
| 259 |
hvac_modes.append(HVACMode.AUTO)
|
| 260 |
|
| 261 |
if self.coordinator.api.cooling_present:
|
| 262 |
-
if
|
| 263 |
-
selected = self._gateway_data.get(
|
| 264 |
if selected == HVACAction.COOLING.value:
|
| 265 |
hvac_modes.append(HVACMode.COOL)
|
| 266 |
if selected == HVACAction.HEATING.value:
|
|
@@ -273,19 +215,19 @@
|
|
| 273 |
return hvac_modes
|
| 274 |
|
| 275 |
@property
|
| 276 |
-
def hvac_action(self) -> HVACAction:
|
| 277 |
"""Return the current running hvac operation if supported."""
|
| 278 |
# Keep track of the previous hvac_action mode.
|
| 279 |
# When no cooling available, _previous_action_mode is always heating
|
| 280 |
if (
|
| 281 |
-
|
| 282 |
-
and HVACAction.COOLING.value in self._gateway_data[
|
| 283 |
):
|
| 284 |
-
mode = self._gateway_data[
|
| 285 |
if mode in (HVACAction.COOLING.value, HVACAction.HEATING.value):
|
| 286 |
self._previous_action_mode = mode
|
| 287 |
|
| 288 |
-
if (action := self.device.get(
|
| 289 |
return HVACAction(action)
|
| 290 |
|
| 291 |
return HVACAction.IDLE
|
|
@@ -293,20 +235,18 @@
|
|
| 293 |
@property
|
| 294 |
def preset_mode(self) -> str | None:
|
| 295 |
"""Return the current preset mode."""
|
| 296 |
-
return self.device.get(
|
| 297 |
|
| 298 |
@plugwise_command
|
| 299 |
async def async_set_temperature(self, **kwargs: Any) -> None:
|
| 300 |
"""Set new target temperature."""
|
| 301 |
data: dict[str, Any] = {}
|
| 302 |
if ATTR_TEMPERATURE in kwargs:
|
| 303 |
-
data[
|
| 304 |
if ATTR_TARGET_TEMP_HIGH in kwargs:
|
| 305 |
-
data[
|
| 306 |
if ATTR_TARGET_TEMP_LOW in kwargs:
|
| 307 |
-
data[
|
| 308 |
-
|
| 309 |
-
# Upstream removed input-valid check
|
| 310 |
|
| 311 |
if mode := kwargs.get(ATTR_HVAC_MODE):
|
| 312 |
await self.async_set_hvac_mode(mode)
|
|
@@ -319,7 +259,9 @@
|
|
| 319 |
if hvac_mode == self.hvac_mode:
|
| 320 |
return
|
| 321 |
|
| 322 |
-
if hvac_mode
|
|
|
|
|
|
|
| 323 |
current = self.device.get("select_schedule")
|
| 324 |
desired = current
|
| 325 |
|
|
@@ -341,27 +283,10 @@
|
|
| 341 |
STATE_ON if hvac_mode == HVACMode.AUTO else STATE_OFF,
|
| 342 |
desired,
|
| 343 |
)
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
"""Mimic HomeKit by setting a suitable preset, when homekit mode is enabled."""
|
| 349 |
-
if (
|
| 350 |
-
not self._homekit_enabled # pw-beta
|
| 351 |
-
):
|
| 352 |
-
if mode == HVACMode.OFF:
|
| 353 |
-
await self.coordinator.api.set_regulation_mode(mode.value)
|
| 354 |
-
elif self.hvac_mode == HVACMode.OFF and self._previous_action_mode:
|
| 355 |
-
await self.coordinator.api.set_regulation_mode(self._previous_action_mode)
|
| 356 |
-
else: # pw-beta
|
| 357 |
-
self._homekit_mode = mode # pragma: no cover
|
| 358 |
-
if self._homekit_mode == HVACMode.OFF: # pragma: no cover
|
| 359 |
-
await self.async_set_preset_mode(PRESET_AWAY) # pragma: no cover
|
| 360 |
-
if (
|
| 361 |
-
self._homekit_mode in [HVACMode.HEAT, HVACMode.HEAT_COOL]
|
| 362 |
-
and self.device.get(ACTIVE_PRESET) == PRESET_AWAY
|
| 363 |
-
): # pragma: no cover
|
| 364 |
-
await self.async_set_preset_mode(PRESET_HOME) # pragma: no cover
|
| 365 |
|
| 366 |
@plugwise_command
|
| 367 |
async def async_set_preset_mode(self, preset_mode: str) -> None:
|
|
|
|
| 9 |
ATTR_HVAC_MODE,
|
| 10 |
ATTR_TARGET_TEMP_HIGH,
|
| 11 |
ATTR_TARGET_TEMP_LOW,
|
|
|
|
|
|
|
| 12 |
ClimateEntity,
|
| 13 |
ClimateEntityFeature,
|
| 14 |
HVACAction,
|
| 15 |
HVACMode,
|
| 16 |
)
|
| 17 |
+
from homeassistant.const import ATTR_TEMPERATURE, STATE_OFF, STATE_ON, UnitOfTemperature
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
from homeassistant.core import HomeAssistant, callback
|
| 19 |
from homeassistant.exceptions import HomeAssistantError
|
| 20 |
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
| 21 |
from homeassistant.helpers.restore_state import ExtraStoredData, RestoreEntity
|
| 22 |
|
| 23 |
+
from .const import DOMAIN, MASTER_THERMOSTATS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator
|
| 25 |
from .entity import PlugwiseEntity
|
| 26 |
from .util import plugwise_command
|
|
|
|
| 29 |
PARALLEL_UPDATES = 0
|
| 30 |
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
@dataclass
|
| 33 |
class PlugwiseClimateExtraStoredData(ExtraStoredData):
|
| 34 |
"""Object to hold extra stored data."""
|
|
|
|
| 52 |
)
|
| 53 |
|
| 54 |
|
| 55 |
+
async def async_setup_entry(
|
| 56 |
+
hass: HomeAssistant,
|
| 57 |
+
entry: PlugwiseConfigEntry,
|
| 58 |
+
async_add_entities: AddConfigEntryEntitiesCallback,
|
| 59 |
+
) -> None:
|
| 60 |
+
"""Set up the Smile Thermostats from a config entry."""
|
| 61 |
+
coordinator = entry.runtime_data
|
| 62 |
+
|
| 63 |
+
@callback
|
| 64 |
+
def _add_entities() -> None:
|
| 65 |
+
"""Add Entities."""
|
| 66 |
+
if not coordinator.new_devices:
|
| 67 |
+
return
|
| 68 |
+
|
| 69 |
+
if coordinator.api.smile.name == "Adam":
|
| 70 |
+
async_add_entities(
|
| 71 |
+
PlugwiseClimateEntity(coordinator, device_id)
|
| 72 |
+
for device_id in coordinator.new_devices
|
| 73 |
+
if coordinator.data[device_id]["dev_class"] == "climate"
|
| 74 |
+
)
|
| 75 |
+
else:
|
| 76 |
+
async_add_entities(
|
| 77 |
+
PlugwiseClimateEntity(coordinator, device_id)
|
| 78 |
+
for device_id in coordinator.new_devices
|
| 79 |
+
if coordinator.data[device_id]["dev_class"] in MASTER_THERMOSTATS
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
_add_entities()
|
| 83 |
+
entry.async_on_unload(coordinator.async_add_listener(_add_entities))
|
| 84 |
+
|
| 85 |
+
|
| 86 |
class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity, RestoreEntity):
|
| 87 |
"""Representation of a Plugwise thermostat."""
|
| 88 |
|
|
|
|
| 89 |
_attr_name = None
|
| 90 |
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
| 91 |
_attr_translation_key = DOMAIN
|
|
|
|
| 92 |
|
| 93 |
_last_active_schedule: str | None = None
|
| 94 |
+
_previous_action_mode: str | None = HVACAction.HEATING.value
|
|
|
|
| 95 |
|
| 96 |
async def async_added_to_hass(self) -> None:
|
| 97 |
"""Run when entity about to be added."""
|
|
|
|
| 108 |
self,
|
| 109 |
coordinator: PlugwiseDataUpdateCoordinator,
|
| 110 |
device_id: str,
|
|
|
|
| 111 |
) -> None:
|
| 112 |
"""Set up the Plugwise API."""
|
| 113 |
super().__init__(coordinator, device_id)
|
| 114 |
+
self._attr_unique_id = f"{device_id}-climate"
|
| 115 |
|
| 116 |
gateway_id: str = coordinator.api.gateway_id
|
| 117 |
self._gateway_data = coordinator.data[gateway_id]
|
|
|
|
| 118 |
self._location = device_id
|
| 119 |
+
if (location := self.device.get("location")) is not None:
|
| 120 |
self._location = location
|
| 121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
# Determine supported features
|
| 123 |
self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
| 124 |
if (
|
|
|
|
| 132 |
self._attr_supported_features |= (
|
| 133 |
ClimateEntityFeature.TURN_OFF | ClimateEntityFeature.TURN_ON
|
| 134 |
)
|
| 135 |
+
if presets := self.device.get("preset_modes"):
|
| 136 |
self._attr_supported_features |= ClimateEntityFeature.PRESET_MODE
|
| 137 |
+
self._attr_preset_modes = presets
|
| 138 |
+
|
| 139 |
+
self._attr_min_temp = self.device["thermostat"]["lower_bound"]
|
| 140 |
+
self._attr_max_temp = min(self.device["thermostat"]["upper_bound"], 35.0)
|
| 141 |
+
# Ensure we don't drop below 0.1
|
| 142 |
+
self._attr_target_temperature_step = max(
|
| 143 |
+
self.device["thermostat"]["resolution"], 0.1
|
| 144 |
+
)
|
| 145 |
|
| 146 |
@property
|
| 147 |
+
def current_temperature(self) -> float:
|
| 148 |
"""Return the current temperature."""
|
| 149 |
+
return self.device["sensors"]["temperature"]
|
| 150 |
|
| 151 |
@property
|
| 152 |
def extra_restore_state_data(self) -> PlugwiseClimateExtraStoredData:
|
|
|
|
| 157 |
)
|
| 158 |
|
| 159 |
@property
|
| 160 |
+
def target_temperature(self) -> float:
|
| 161 |
"""Return the temperature we try to reach.
|
| 162 |
|
| 163 |
Connected to the HVACMode combination of AUTO-HEAT.
|
| 164 |
"""
|
| 165 |
|
| 166 |
+
return self.device["thermostat"]["setpoint"]
|
| 167 |
|
| 168 |
@property
|
| 169 |
+
def target_temperature_high(self) -> float:
|
| 170 |
"""Return the temperature we try to reach in case of cooling.
|
| 171 |
|
| 172 |
Connected to the HVACMode combination of AUTO-HEAT_COOL.
|
| 173 |
"""
|
| 174 |
+
return self.device["thermostat"]["setpoint_high"]
|
| 175 |
|
| 176 |
@property
|
| 177 |
+
def target_temperature_low(self) -> float:
|
| 178 |
"""Return the heating temperature we try to reach in case of heating.
|
| 179 |
|
| 180 |
Connected to the HVACMode combination AUTO-HEAT_COOL.
|
| 181 |
"""
|
| 182 |
+
return self.device["thermostat"]["setpoint_low"]
|
| 183 |
|
| 184 |
@property
|
| 185 |
def hvac_mode(self) -> HVACMode:
|
| 186 |
"""Return HVAC operation ie. auto, cool, heat, heat_cool, or off mode."""
|
| 187 |
+
if (
|
| 188 |
+
mode := self.device.get("climate_mode")
|
| 189 |
+
) is None or mode not in self.hvac_modes:
|
| 190 |
+
return HVACMode.HEAT
|
| 191 |
+
return HVACMode(mode)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
|
| 193 |
@property
|
| 194 |
def hvac_modes(self) -> list[HVACMode]:
|
| 195 |
"""Return a list of available HVACModes."""
|
| 196 |
hvac_modes: list[HVACMode] = []
|
| 197 |
+
if "regulation_modes" in self._gateway_data:
|
|
|
|
|
|
|
|
|
|
| 198 |
hvac_modes.append(HVACMode.OFF)
|
| 199 |
|
| 200 |
+
if self.device.get("available_schedules"):
|
| 201 |
hvac_modes.append(HVACMode.AUTO)
|
| 202 |
|
| 203 |
if self.coordinator.api.cooling_present:
|
| 204 |
+
if "regulation_modes" in self._gateway_data:
|
| 205 |
+
selected = self._gateway_data.get("select_regulation_mode")
|
| 206 |
if selected == HVACAction.COOLING.value:
|
| 207 |
hvac_modes.append(HVACMode.COOL)
|
| 208 |
if selected == HVACAction.HEATING.value:
|
|
|
|
| 215 |
return hvac_modes
|
| 216 |
|
| 217 |
@property
|
| 218 |
+
def hvac_action(self) -> HVACAction:
|
| 219 |
"""Return the current running hvac operation if supported."""
|
| 220 |
# Keep track of the previous hvac_action mode.
|
| 221 |
# When no cooling available, _previous_action_mode is always heating
|
| 222 |
if (
|
| 223 |
+
"regulation_modes" in self._gateway_data
|
| 224 |
+
and HVACAction.COOLING.value in self._gateway_data["regulation_modes"]
|
| 225 |
):
|
| 226 |
+
mode = self._gateway_data["select_regulation_mode"]
|
| 227 |
if mode in (HVACAction.COOLING.value, HVACAction.HEATING.value):
|
| 228 |
self._previous_action_mode = mode
|
| 229 |
|
| 230 |
+
if (action := self.device.get("control_state")) is not None:
|
| 231 |
return HVACAction(action)
|
| 232 |
|
| 233 |
return HVACAction.IDLE
|
|
|
|
| 235 |
@property
|
| 236 |
def preset_mode(self) -> str | None:
|
| 237 |
"""Return the current preset mode."""
|
| 238 |
+
return self.device.get("active_preset")
|
| 239 |
|
| 240 |
@plugwise_command
|
| 241 |
async def async_set_temperature(self, **kwargs: Any) -> None:
|
| 242 |
"""Set new target temperature."""
|
| 243 |
data: dict[str, Any] = {}
|
| 244 |
if ATTR_TEMPERATURE in kwargs:
|
| 245 |
+
data["setpoint"] = kwargs.get(ATTR_TEMPERATURE)
|
| 246 |
if ATTR_TARGET_TEMP_HIGH in kwargs:
|
| 247 |
+
data["setpoint_high"] = kwargs.get(ATTR_TARGET_TEMP_HIGH)
|
| 248 |
if ATTR_TARGET_TEMP_LOW in kwargs:
|
| 249 |
+
data["setpoint_low"] = kwargs.get(ATTR_TARGET_TEMP_LOW)
|
|
|
|
|
|
|
| 250 |
|
| 251 |
if mode := kwargs.get(ATTR_HVAC_MODE):
|
| 252 |
await self.async_set_hvac_mode(mode)
|
|
|
|
| 259 |
if hvac_mode == self.hvac_mode:
|
| 260 |
return
|
| 261 |
|
| 262 |
+
if hvac_mode == HVACMode.OFF:
|
| 263 |
+
await self.coordinator.api.set_regulation_mode(hvac_mode.value)
|
| 264 |
+
else:
|
| 265 |
current = self.device.get("select_schedule")
|
| 266 |
desired = current
|
| 267 |
|
|
|
|
| 283 |
STATE_ON if hvac_mode == HVACMode.AUTO else STATE_OFF,
|
| 284 |
desired,
|
| 285 |
)
|
| 286 |
+
if self.hvac_mode == HVACMode.OFF and self._previous_action_mode:
|
| 287 |
+
await self.coordinator.api.set_regulation_mode(
|
| 288 |
+
self._previous_action_mode
|
| 289 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
|
| 291 |
@plugwise_command
|
| 292 |
async def async_set_preset_mode(self, preset_mode: str) -> None:
|
|
@@ -2,7 +2,6 @@
|
|
| 2 |
|
| 3 |
from __future__ import annotations
|
| 4 |
|
| 5 |
-
from copy import deepcopy
|
| 6 |
import logging
|
| 7 |
from typing import Any, Self
|
| 8 |
|
|
@@ -17,15 +16,7 @@
|
|
| 17 |
)
|
| 18 |
import voluptuous as vol
|
| 19 |
|
| 20 |
-
from homeassistant.config_entries import
|
| 21 |
-
SOURCE_USER,
|
| 22 |
-
ConfigEntry,
|
| 23 |
-
ConfigFlow,
|
| 24 |
-
ConfigFlowResult,
|
| 25 |
-
OptionsFlow,
|
| 26 |
-
)
|
| 27 |
-
|
| 28 |
-
# Upstream
|
| 29 |
from homeassistant.const import (
|
| 30 |
ATTR_CONFIGURATION_URL,
|
| 31 |
CONF_BASE,
|
|
@@ -33,47 +24,30 @@
|
|
| 33 |
CONF_NAME,
|
| 34 |
CONF_PASSWORD,
|
| 35 |
CONF_PORT,
|
| 36 |
-
CONF_SCAN_INTERVAL,
|
| 37 |
CONF_USERNAME,
|
| 38 |
)
|
| 39 |
-
|
| 40 |
-
# Upstream
|
| 41 |
-
from homeassistant.core import HomeAssistant, callback
|
| 42 |
-
from homeassistant.helpers import config_validation as cv
|
| 43 |
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
| 44 |
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
| 45 |
|
| 46 |
from .const import (
|
| 47 |
ANNA_WITH_ADAM,
|
| 48 |
-
CONF_HOMEKIT_EMULATION, # pw-beta option
|
| 49 |
-
CONF_REFRESH_INTERVAL, # pw-beta option
|
| 50 |
DEFAULT_PORT,
|
| 51 |
-
DEFAULT_SCAN_INTERVAL, # pw-beta option
|
| 52 |
DEFAULT_USERNAME,
|
| 53 |
DOMAIN,
|
| 54 |
FLOW_SMILE,
|
| 55 |
FLOW_STRETCH,
|
| 56 |
-
INIT,
|
| 57 |
SMILE,
|
| 58 |
SMILE_OPEN_THERM,
|
| 59 |
SMILE_THERMO,
|
| 60 |
STRETCH,
|
| 61 |
STRETCH_USERNAME,
|
| 62 |
-
|
| 63 |
-
TITLE_PLACEHOLDERS,
|
| 64 |
-
VERSION,
|
| 65 |
ZEROCONF_MAP,
|
| 66 |
)
|
| 67 |
|
| 68 |
-
# Upstream
|
| 69 |
-
from .coordinator import PlugwiseDataUpdateCoordinator
|
| 70 |
-
|
| 71 |
-
type PlugwiseConfigEntry = ConfigEntry[PlugwiseDataUpdateCoordinator]
|
| 72 |
-
|
| 73 |
_LOGGER = logging.getLogger(__name__)
|
| 74 |
|
| 75 |
-
# Upstream basically the whole file (excluding the pw-beta options)
|
| 76 |
-
|
| 77 |
SMILE_RECONF_SCHEMA = vol.Schema(
|
| 78 |
{
|
| 79 |
vol.Required(CONF_HOST): str,
|
|
@@ -81,31 +55,21 @@
|
|
| 81 |
)
|
| 82 |
|
| 83 |
|
| 84 |
-
def smile_user_schema(
|
| 85 |
"""Generate base schema for gateways."""
|
| 86 |
-
|
| 87 |
-
|
|
|
|
|
|
|
| 88 |
{
|
| 89 |
vol.Required(CONF_HOST): str,
|
| 90 |
-
vol.Required(CONF_PASSWORD): str,
|
| 91 |
vol.Required(CONF_USERNAME, default=SMILE): vol.In(
|
| 92 |
{SMILE: FLOW_SMILE, STRETCH: FLOW_STRETCH}
|
| 93 |
),
|
| 94 |
}
|
| 95 |
)
|
| 96 |
|
| 97 |
-
|
| 98 |
-
return vol.Schema({vol.Required(CONF_PASSWORD): str})
|
| 99 |
-
|
| 100 |
-
return vol.Schema(
|
| 101 |
-
{
|
| 102 |
-
vol.Required(CONF_HOST, default=cf_input[CONF_HOST]): str,
|
| 103 |
-
vol.Required(CONF_PASSWORD, default=cf_input[CONF_PASSWORD]): str,
|
| 104 |
-
vol.Required(CONF_USERNAME, default=cf_input[CONF_USERNAME]): vol.In(
|
| 105 |
-
{SMILE: FLOW_SMILE, STRETCH: FLOW_STRETCH}
|
| 106 |
-
),
|
| 107 |
-
}
|
| 108 |
-
)
|
| 109 |
|
| 110 |
|
| 111 |
async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> Smile:
|
|
@@ -155,10 +119,9 @@
|
|
| 155 |
"""Handle a config flow for Plugwise Smile."""
|
| 156 |
|
| 157 |
VERSION = 1
|
| 158 |
-
MINOR_VERSION = 1
|
| 159 |
|
| 160 |
discovery_info: ZeroconfServiceInfo | None = None
|
| 161 |
-
product: str =
|
| 162 |
_username: str = DEFAULT_USERNAME
|
| 163 |
|
| 164 |
async def async_step_zeroconf(
|
|
@@ -167,21 +130,17 @@
|
|
| 167 |
"""Prepare configuration for a discovered Plugwise Smile."""
|
| 168 |
self.discovery_info = discovery_info
|
| 169 |
_properties = discovery_info.properties
|
| 170 |
-
_version = _properties.get(VERSION, "n/a")
|
| 171 |
-
self.product = _product = _properties.get("product", "Unknown Smile")
|
| 172 |
-
unique_id = discovery_info.hostname.split(".")[0].split("-")[0]
|
| 173 |
-
if DEFAULT_USERNAME not in unique_id:
|
| 174 |
-
self._username = STRETCH_USERNAME
|
| 175 |
|
|
|
|
| 176 |
if config_entry := await self.async_set_unique_id(unique_id):
|
| 177 |
try:
|
| 178 |
await validate_input(
|
| 179 |
self.hass,
|
| 180 |
{
|
| 181 |
CONF_HOST: discovery_info.host,
|
| 182 |
-
CONF_PASSWORD: config_entry.data[CONF_PASSWORD],
|
| 183 |
CONF_PORT: discovery_info.port,
|
| 184 |
CONF_USERNAME: config_entry.data[CONF_USERNAME],
|
|
|
|
| 185 |
},
|
| 186 |
)
|
| 187 |
except Exception: # noqa: BLE001
|
|
@@ -194,6 +153,12 @@
|
|
| 194 |
}
|
| 195 |
)
|
| 196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
# This is an Anna, but we already have config entries.
|
| 198 |
# Assuming that the user has already configured Adam, aborting discovery.
|
| 199 |
if self._async_current_entries() and _product == SMILE_THERMO:
|
|
@@ -203,15 +168,14 @@
|
|
| 203 |
# In that case, we need to cancel the Anna flow, as the Adam should
|
| 204 |
# be added.
|
| 205 |
if self.hass.config_entries.flow.async_has_matching_flow(self):
|
| 206 |
-
return self.async_abort(reason=
|
| 207 |
|
| 208 |
-
_name = f"{ZEROCONF_MAP.get(_product, _product)} v{_version}"
|
| 209 |
self.context.update(
|
| 210 |
{
|
| 211 |
-
|
| 212 |
ATTR_CONFIGURATION_URL: (
|
| 213 |
f"http://{discovery_info.host}:{discovery_info.port}"
|
| 214 |
-
)
|
| 215 |
}
|
| 216 |
)
|
| 217 |
return await self.async_step_user()
|
|
@@ -228,7 +192,6 @@
|
|
| 228 |
|
| 229 |
return False
|
| 230 |
|
| 231 |
-
|
| 232 |
async def async_step_user(
|
| 233 |
self, user_input: dict[str, Any] | None = None
|
| 234 |
) -> ConfigFlowResult:
|
|
@@ -245,19 +208,18 @@
|
|
| 245 |
api, errors = await verify_connection(self.hass, user_input)
|
| 246 |
if api:
|
| 247 |
await self.async_set_unique_id(
|
| 248 |
-
api.smile.hostname or api.gateway_id,
|
|
|
|
| 249 |
)
|
| 250 |
self._abort_if_unique_id_configured()
|
| 251 |
return self.async_create_entry(title=api.smile.name, data=user_input)
|
| 252 |
|
| 253 |
-
configure_input = self.discovery_info or user_input
|
| 254 |
return self.async_show_form(
|
| 255 |
step_id=SOURCE_USER,
|
| 256 |
-
data_schema=smile_user_schema(
|
| 257 |
errors=errors,
|
| 258 |
)
|
| 259 |
|
| 260 |
-
|
| 261 |
async def async_step_reconfigure(
|
| 262 |
self, user_input: dict[str, Any] | None = None
|
| 263 |
) -> ConfigFlowResult:
|
|
@@ -267,7 +229,7 @@
|
|
| 267 |
reconfigure_entry = self._get_reconfigure_entry()
|
| 268 |
|
| 269 |
if user_input:
|
| 270 |
-
#
|
| 271 |
full_input = {
|
| 272 |
CONF_HOST: user_input.get(CONF_HOST),
|
| 273 |
CONF_PORT: reconfigure_entry.data.get(CONF_PORT),
|
|
@@ -278,7 +240,8 @@
|
|
| 278 |
api, errors = await verify_connection(self.hass, full_input)
|
| 279 |
if api:
|
| 280 |
await self.async_set_unique_id(
|
| 281 |
-
api.smile.hostname or api.gateway_id,
|
|
|
|
| 282 |
)
|
| 283 |
self._abort_if_unique_id_mismatch(reason="not_the_same_smile")
|
| 284 |
return self.async_update_reload_and_abort(
|
|
@@ -295,69 +258,3 @@
|
|
| 295 |
description_placeholders={"title": reconfigure_entry.title},
|
| 296 |
errors=errors,
|
| 297 |
)
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
@staticmethod
|
| 301 |
-
@callback
|
| 302 |
-
def async_get_options_flow(
|
| 303 |
-
config_entry: PlugwiseConfigEntry,
|
| 304 |
-
) -> PlugwiseOptionsFlowHandler: # pw-beta options
|
| 305 |
-
"""Get the options flow for this handler."""
|
| 306 |
-
return PlugwiseOptionsFlowHandler(config_entry)
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
# pw-beta - change the scan-interval via CONFIGURE
|
| 310 |
-
# pw-beta - add homekit emulation via CONFIGURE
|
| 311 |
-
# pw-beta - change the frontend refresh interval via CONFIGURE
|
| 312 |
-
class PlugwiseOptionsFlowHandler(OptionsFlow): # pw-beta options
|
| 313 |
-
"""Plugwise option flow."""
|
| 314 |
-
|
| 315 |
-
def __init__(self, config_entry: ConfigEntry) -> None:
|
| 316 |
-
"""Initialize options flow."""
|
| 317 |
-
self.options = deepcopy(dict(config_entry.options))
|
| 318 |
-
|
| 319 |
-
def _create_options_schema(self, coordinator: PlugwiseDataUpdateCoordinator) -> vol.Schema:
|
| 320 |
-
interval = DEFAULT_SCAN_INTERVAL[coordinator.api.smile.type] # pw-beta options
|
| 321 |
-
schema = {
|
| 322 |
-
vol.Optional(
|
| 323 |
-
CONF_SCAN_INTERVAL,
|
| 324 |
-
default=self.options.get(CONF_SCAN_INTERVAL, interval.seconds),
|
| 325 |
-
): vol.All(cv.positive_int, vol.Clamp(min=10)),
|
| 326 |
-
} # pw-beta
|
| 327 |
-
|
| 328 |
-
if coordinator.api.smile.type == THERMOSTAT:
|
| 329 |
-
schema.update({
|
| 330 |
-
vol.Optional(
|
| 331 |
-
CONF_HOMEKIT_EMULATION,
|
| 332 |
-
default=self.options.get(CONF_HOMEKIT_EMULATION, False),
|
| 333 |
-
): vol.All(cv.boolean),
|
| 334 |
-
vol.Optional(
|
| 335 |
-
CONF_REFRESH_INTERVAL,
|
| 336 |
-
default=self.options.get(CONF_REFRESH_INTERVAL, 1.5),
|
| 337 |
-
): vol.All(vol.Coerce(float), vol.Range(min=1.5, max=10.0)),
|
| 338 |
-
}) # pw-beta
|
| 339 |
-
|
| 340 |
-
return vol.Schema(schema)
|
| 341 |
-
|
| 342 |
-
async def async_step_none(
|
| 343 |
-
self, user_input: dict[str, Any] | None = None
|
| 344 |
-
) -> ConfigFlowResult: # pragma: no cover
|
| 345 |
-
"""No options available."""
|
| 346 |
-
if user_input is not None:
|
| 347 |
-
# Apparently not possible to abort an options flow at the moment
|
| 348 |
-
return self.async_create_entry(title="", data=self.options)
|
| 349 |
-
return self.async_show_form(step_id="none")
|
| 350 |
-
|
| 351 |
-
async def async_step_init(self, user_input: dict[str, Any] | None = None) -> ConfigFlowResult:
|
| 352 |
-
"""Manage the Plugwise options."""
|
| 353 |
-
if not self.config_entry.data.get(CONF_HOST):
|
| 354 |
-
return await self.async_step_none(user_input) # pragma: no cover
|
| 355 |
-
|
| 356 |
-
if user_input is not None:
|
| 357 |
-
return self.async_create_entry(title="", data=user_input)
|
| 358 |
-
|
| 359 |
-
coordinator = self.config_entry.runtime_data
|
| 360 |
-
return self.async_show_form(
|
| 361 |
-
step_id=INIT,
|
| 362 |
-
data_schema=self._create_options_schema(coordinator)
|
| 363 |
-
)
|
|
|
|
| 2 |
|
| 3 |
from __future__ import annotations
|
| 4 |
|
|
|
|
| 5 |
import logging
|
| 6 |
from typing import Any, Self
|
| 7 |
|
|
|
|
| 16 |
)
|
| 17 |
import voluptuous as vol
|
| 18 |
|
| 19 |
+
from homeassistant.config_entries import SOURCE_USER, ConfigFlow, ConfigFlowResult
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
from homeassistant.const import (
|
| 21 |
ATTR_CONFIGURATION_URL,
|
| 22 |
CONF_BASE,
|
|
|
|
| 24 |
CONF_NAME,
|
| 25 |
CONF_PASSWORD,
|
| 26 |
CONF_PORT,
|
|
|
|
| 27 |
CONF_USERNAME,
|
| 28 |
)
|
| 29 |
+
from homeassistant.core import HomeAssistant
|
|
|
|
|
|
|
|
|
|
| 30 |
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
| 31 |
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
| 32 |
|
| 33 |
from .const import (
|
| 34 |
ANNA_WITH_ADAM,
|
|
|
|
|
|
|
| 35 |
DEFAULT_PORT,
|
|
|
|
| 36 |
DEFAULT_USERNAME,
|
| 37 |
DOMAIN,
|
| 38 |
FLOW_SMILE,
|
| 39 |
FLOW_STRETCH,
|
|
|
|
| 40 |
SMILE,
|
| 41 |
SMILE_OPEN_THERM,
|
| 42 |
SMILE_THERMO,
|
| 43 |
STRETCH,
|
| 44 |
STRETCH_USERNAME,
|
| 45 |
+
UNKNOWN_SMILE,
|
|
|
|
|
|
|
| 46 |
ZEROCONF_MAP,
|
| 47 |
)
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
_LOGGER = logging.getLogger(__name__)
|
| 50 |
|
|
|
|
|
|
|
| 51 |
SMILE_RECONF_SCHEMA = vol.Schema(
|
| 52 |
{
|
| 53 |
vol.Required(CONF_HOST): str,
|
|
|
|
| 55 |
)
|
| 56 |
|
| 57 |
|
| 58 |
+
def smile_user_schema(discovery_info: ZeroconfServiceInfo | None) -> vol.Schema:
|
| 59 |
"""Generate base schema for gateways."""
|
| 60 |
+
schema = vol.Schema({vol.Required(CONF_PASSWORD): str})
|
| 61 |
+
|
| 62 |
+
if not discovery_info:
|
| 63 |
+
schema = schema.extend(
|
| 64 |
{
|
| 65 |
vol.Required(CONF_HOST): str,
|
|
|
|
| 66 |
vol.Required(CONF_USERNAME, default=SMILE): vol.In(
|
| 67 |
{SMILE: FLOW_SMILE, STRETCH: FLOW_STRETCH}
|
| 68 |
),
|
| 69 |
}
|
| 70 |
)
|
| 71 |
|
| 72 |
+
return schema
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
|
| 75 |
async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> Smile:
|
|
|
|
| 119 |
"""Handle a config flow for Plugwise Smile."""
|
| 120 |
|
| 121 |
VERSION = 1
|
|
|
|
| 122 |
|
| 123 |
discovery_info: ZeroconfServiceInfo | None = None
|
| 124 |
+
product: str = UNKNOWN_SMILE
|
| 125 |
_username: str = DEFAULT_USERNAME
|
| 126 |
|
| 127 |
async def async_step_zeroconf(
|
|
|
|
| 130 |
"""Prepare configuration for a discovered Plugwise Smile."""
|
| 131 |
self.discovery_info = discovery_info
|
| 132 |
_properties = discovery_info.properties
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
|
| 134 |
+
unique_id = discovery_info.hostname.split(".")[0].split("-")[0]
|
| 135 |
if config_entry := await self.async_set_unique_id(unique_id):
|
| 136 |
try:
|
| 137 |
await validate_input(
|
| 138 |
self.hass,
|
| 139 |
{
|
| 140 |
CONF_HOST: discovery_info.host,
|
|
|
|
| 141 |
CONF_PORT: discovery_info.port,
|
| 142 |
CONF_USERNAME: config_entry.data[CONF_USERNAME],
|
| 143 |
+
CONF_PASSWORD: config_entry.data[CONF_PASSWORD],
|
| 144 |
},
|
| 145 |
)
|
| 146 |
except Exception: # noqa: BLE001
|
|
|
|
| 153 |
}
|
| 154 |
)
|
| 155 |
|
| 156 |
+
if DEFAULT_USERNAME not in unique_id:
|
| 157 |
+
self._username = STRETCH_USERNAME
|
| 158 |
+
self.product = _product = _properties.get("product", UNKNOWN_SMILE)
|
| 159 |
+
_version = _properties.get("version", "n/a")
|
| 160 |
+
_name = f"{ZEROCONF_MAP.get(_product, _product)} v{_version}"
|
| 161 |
+
|
| 162 |
# This is an Anna, but we already have config entries.
|
| 163 |
# Assuming that the user has already configured Adam, aborting discovery.
|
| 164 |
if self._async_current_entries() and _product == SMILE_THERMO:
|
|
|
|
| 168 |
# In that case, we need to cancel the Anna flow, as the Adam should
|
| 169 |
# be added.
|
| 170 |
if self.hass.config_entries.flow.async_has_matching_flow(self):
|
| 171 |
+
return self.async_abort(reason=ANNA_WITH_ADAM)
|
| 172 |
|
|
|
|
| 173 |
self.context.update(
|
| 174 |
{
|
| 175 |
+
"title_placeholders": {CONF_NAME: _name},
|
| 176 |
ATTR_CONFIGURATION_URL: (
|
| 177 |
f"http://{discovery_info.host}:{discovery_info.port}"
|
| 178 |
+
),
|
| 179 |
}
|
| 180 |
)
|
| 181 |
return await self.async_step_user()
|
|
|
|
| 192 |
|
| 193 |
return False
|
| 194 |
|
|
|
|
| 195 |
async def async_step_user(
|
| 196 |
self, user_input: dict[str, Any] | None = None
|
| 197 |
) -> ConfigFlowResult:
|
|
|
|
| 208 |
api, errors = await verify_connection(self.hass, user_input)
|
| 209 |
if api:
|
| 210 |
await self.async_set_unique_id(
|
| 211 |
+
api.smile.hostname or api.gateway_id,
|
| 212 |
+
raise_on_progress=False,
|
| 213 |
)
|
| 214 |
self._abort_if_unique_id_configured()
|
| 215 |
return self.async_create_entry(title=api.smile.name, data=user_input)
|
| 216 |
|
|
|
|
| 217 |
return self.async_show_form(
|
| 218 |
step_id=SOURCE_USER,
|
| 219 |
+
data_schema=smile_user_schema(self.discovery_info),
|
| 220 |
errors=errors,
|
| 221 |
)
|
| 222 |
|
|
|
|
| 223 |
async def async_step_reconfigure(
|
| 224 |
self, user_input: dict[str, Any] | None = None
|
| 225 |
) -> ConfigFlowResult:
|
|
|
|
| 229 |
reconfigure_entry = self._get_reconfigure_entry()
|
| 230 |
|
| 231 |
if user_input:
|
| 232 |
+
# Keep current username and password
|
| 233 |
full_input = {
|
| 234 |
CONF_HOST: user_input.get(CONF_HOST),
|
| 235 |
CONF_PORT: reconfigure_entry.data.get(CONF_PORT),
|
|
|
|
| 240 |
api, errors = await verify_connection(self.hass, full_input)
|
| 241 |
if api:
|
| 242 |
await self.async_set_unique_id(
|
| 243 |
+
api.smile.hostname or api.gateway_id,
|
| 244 |
+
raise_on_progress=False,
|
| 245 |
)
|
| 246 |
self._abort_if_unique_id_mismatch(reason="not_the_same_smile")
|
| 247 |
return self.async_update_reload_and_abort(
|
|
|
|
| 258 |
description_placeholders={"title": reconfigure_entry.title},
|
| 259 |
errors=errors,
|
| 260 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,163 +1,35 @@
|
|
| 1 |
"""Constants for Plugwise component."""
|
| 2 |
|
|
|
|
|
|
|
| 3 |
from datetime import timedelta
|
| 4 |
import logging
|
| 5 |
from typing import Final, Literal
|
| 6 |
|
| 7 |
from homeassistant.const import Platform
|
| 8 |
|
| 9 |
-
# Upstream basically the whole file excluding pw-beta options
|
| 10 |
-
|
| 11 |
DOMAIN: Final = "plugwise"
|
| 12 |
|
| 13 |
LOGGER = logging.getLogger(__package__)
|
| 14 |
|
|
|
|
| 15 |
API: Final = "api"
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
| 20 |
GATEWAY: Final = "gateway"
|
| 21 |
LOCATION: Final = "location"
|
| 22 |
-
|
| 23 |
REBOOT: Final = "reboot"
|
| 24 |
SMILE: Final = "smile"
|
| 25 |
-
STRETCH: Final = "stretch"
|
| 26 |
-
STRETCH_USERNAME: Final = "stretch"
|
| 27 |
-
UNIQUE_IDS: Final = "unique_ids"
|
| 28 |
-
ZIGBEE_MAC_ADDRESS: Final = "zigbee_mac_address"
|
| 29 |
-
|
| 30 |
-
# Binary Sensor constants
|
| 31 |
-
BINARY_SENSORS: Final = "binary_sensors"
|
| 32 |
-
BATTERY_STATE: Final = "low_battery"
|
| 33 |
-
COMPRESSOR_STATE: Final = "compressor_state"
|
| 34 |
-
COOLING_ENABLED: Final = "cooling_enabled"
|
| 35 |
-
COOLING_STATE: Final = "cooling_state"
|
| 36 |
-
DHW_STATE: Final = "dhw_state"
|
| 37 |
-
FLAME_STATE: Final = "flame_state"
|
| 38 |
-
HEATING_STATE: Final = "heating_state"
|
| 39 |
-
PLUGWISE_NOTIFICATION: Final = "plugwise_notification"
|
| 40 |
-
SECONDARY_BOILER_STATE: Final = "secondary_boiler_state"
|
| 41 |
-
|
| 42 |
-
# Climate constants
|
| 43 |
-
ACTIVE_PRESET: Final = "active_preset"
|
| 44 |
-
CLIMATE_MODE: Final = "climate_mode"
|
| 45 |
-
CONTROL_STATE: Final = "control_state"
|
| 46 |
-
COOLING_PRESENT: Final ="cooling_present"
|
| 47 |
-
DEV_CLASS: Final = "dev_class"
|
| 48 |
-
NONE : Final = "None"
|
| 49 |
-
TARGET_TEMP: Final = "setpoint"
|
| 50 |
-
TARGET_TEMP_HIGH: Final = "setpoint_high"
|
| 51 |
-
TARGET_TEMP_LOW: Final = "setpoint_low"
|
| 52 |
-
THERMOSTAT: Final = "thermostat"
|
| 53 |
-
|
| 54 |
-
# Config_flow constants
|
| 55 |
-
ANNA_WITH_ADAM: Final = "anna_with_adam"
|
| 56 |
-
CONTEXT: Final = "context"
|
| 57 |
-
FLOW_ID: Final = "flow_id"
|
| 58 |
-
FLOW_NET: Final = "Network: Smile/Stretch"
|
| 59 |
-
FLOW_SMILE: Final = "Smile (Adam/Anna/P1)"
|
| 60 |
-
FLOW_STRETCH: Final = "Stretch (Stretch)"
|
| 61 |
-
FLOW_TYPE: Final = "flow_type"
|
| 62 |
-
INIT: Final = "init"
|
| 63 |
-
PRODUCT: Final = "product"
|
| 64 |
SMILE_OPEN_THERM: Final = "smile_open_therm"
|
| 65 |
SMILE_THERMO: Final = "smile_thermo"
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
# Entity constants
|
| 70 |
-
AVAILABLE: Final = "available"
|
| 71 |
-
FIRMWARE: Final = "firmware"
|
| 72 |
-
HARDWARE: Final = "hardware"
|
| 73 |
-
MODEL: Final = "model"
|
| 74 |
-
MODEL_ID: Final = "model_id"
|
| 75 |
-
VENDOR: Final = "vendor"
|
| 76 |
-
|
| 77 |
-
# Number constants
|
| 78 |
-
MAX_BOILER_TEMP: Final = "maximum_boiler_temperature"
|
| 79 |
-
MAX_DHW_TEMP: Final = "max_dhw_temperature"
|
| 80 |
-
LOWER_BOUND: Final = "lower_bound"
|
| 81 |
-
RESOLUTION: Final = "resolution"
|
| 82 |
-
TEMPERATURE_OFFSET: Final = "temperature_offset"
|
| 83 |
-
UPPER_BOUND: Final = "upper_bound"
|
| 84 |
-
|
| 85 |
-
# Sensor constants
|
| 86 |
-
DHW_TEMP: Final = "dhw_temperature"
|
| 87 |
-
DHW_SETPOINT: Final = "domestic_hot_water_setpoint"
|
| 88 |
-
EL_CONSUMED: Final = "electricity_consumed"
|
| 89 |
-
EL_CONS_INTERVAL: Final = "electricity_consumed_interval"
|
| 90 |
-
EL_CONS_OP_CUMULATIVE: Final = "electricity_consumed_off_peak_cumulative"
|
| 91 |
-
EL_CONS_OP_INTERVAL: Final = "electricity_consumed_off_peak_interval"
|
| 92 |
-
EL_CONS_OP_POINT: Final = "electricity_consumed_off_peak_point"
|
| 93 |
-
EL_CONS_P_CUMULATIVE: Final = "electricity_consumed_peak_cumulative"
|
| 94 |
-
EL_CONS_P_INTERVAL: Final = "electricity_consumed_peak_interval"
|
| 95 |
-
EL_CONS_P_POINT: Final = "electricity_consumed_peak_point"
|
| 96 |
-
EL_CONS_POINT: Final = "electricity_consumed_point"
|
| 97 |
-
EL_PH1_CONSUMED: Final = "electricity_phase_one_consumed"
|
| 98 |
-
EL_PH2_CONSUMED: Final = "electricity_phase_two_consumed"
|
| 99 |
-
EL_PH3_CONSUMED: Final = "electricity_phase_three_consumed"
|
| 100 |
-
EL_PH1_PRODUCED: Final = "electricity_phase_one_produced"
|
| 101 |
-
EL_PH2_PRODUCED: Final = "electricity_phase_two_produced"
|
| 102 |
-
EL_PH3_PRODUCED: Final = "electricity_phase_three_produced"
|
| 103 |
-
EL_PRODUCED: Final = "electricity_produced"
|
| 104 |
-
EL_PROD_INTERVAL: Final = "electricity_produced_interval"
|
| 105 |
-
EL_PROD_OP_CUMULATIVE: Final = "electricity_produced_off_peak_cumulative"
|
| 106 |
-
EL_PROD_OP_INTERVAL: Final = "electricity_produced_off_peak_interval"
|
| 107 |
-
EL_PROD_OP_POINT: Final = "electricity_produced_off_peak_point"
|
| 108 |
-
EL_PROD_P_CUMULATIVE: Final = "electricity_produced_peak_cumulative"
|
| 109 |
-
EL_PROD_P_INTERVAL: Final = "electricity_produced_peak_interval"
|
| 110 |
-
EL_PROD_P_POINT: Final = "electricity_produced_peak_point"
|
| 111 |
-
EL_PROD_POINT: Final = "electricity_produced_point"
|
| 112 |
-
GAS_CONS_CUMULATIVE: Final = "gas_consumed_cumulative"
|
| 113 |
-
GAS_CONS_INTERVAL: Final = "gas_consumed_interval"
|
| 114 |
-
INTENDED_BOILER_TEMP: Final = "intended_boiler_temperature"
|
| 115 |
-
MOD_LEVEL: Final = "modulation_level"
|
| 116 |
-
NET_EL_POINT: Final = "net_electricity_point"
|
| 117 |
-
NET_EL_CUMULATIVE: Final = "net_electricity_cumulative"
|
| 118 |
-
OUTDOOR_AIR_TEMP: Final = "outdoor_air_temperature"
|
| 119 |
-
OUTDOOR_TEMP: Final = "outdoor_temperature"
|
| 120 |
-
RETURN_TEMP: Final = "return_temperature"
|
| 121 |
-
SENSORS: Final = "sensors"
|
| 122 |
-
TEMP_DIFF: Final = "temperature_difference"
|
| 123 |
-
VALVE_POS: Final = "valve_position"
|
| 124 |
-
VOLTAGE_PH1: Final = "voltage_phase_one"
|
| 125 |
-
VOLTAGE_PH2: Final = "voltage_phase_two"
|
| 126 |
-
VOLTAGE_PH3: Final = "voltage_phase_three"
|
| 127 |
-
WATER_TEMP: Final = "water_temperature"
|
| 128 |
-
WATER_PRESSURE: Final = "water_pressure"
|
| 129 |
-
|
| 130 |
-
# Select constants
|
| 131 |
-
AVAILABLE_SCHEDULES: Final = "available_schedules"
|
| 132 |
-
DHW_MODES: Final = "dhw_modes"
|
| 133 |
-
GATEWAY_MODES: Final = "gateway_modes"
|
| 134 |
-
REGULATION_MODES: Final = "regulation_modes"
|
| 135 |
-
ZONE_PROFILES: Final = "zone_profiles"
|
| 136 |
-
SELECT_DHW_MODE: Final = "select_dhw_mode"
|
| 137 |
-
SELECT_GATEWAY_MODE: Final = "select_gateway_mode"
|
| 138 |
-
SELECT_REGULATION_MODE: Final = "select_regulation_mode"
|
| 139 |
-
SELECT_SCHEDULE: Final = "select_schedule"
|
| 140 |
-
SELECT_ZONE_PROFILE: Final = "select_zone_profile"
|
| 141 |
-
|
| 142 |
-
# Switch constants
|
| 143 |
-
DHW_CM_SWITCH: Final = "dhw_cm_switch"
|
| 144 |
-
LOCK: Final = "lock"
|
| 145 |
-
MEMBERS: Final ="members"
|
| 146 |
-
RELAY: Final = "relay"
|
| 147 |
-
COOLING_ENA_SWITCH: Final ="cooling_ena_switch"
|
| 148 |
-
SWITCHES: Final = "switches"
|
| 149 |
-
|
| 150 |
-
# Default directives
|
| 151 |
-
DEFAULT_PORT: Final[int] = 80
|
| 152 |
-
DEFAULT_SCAN_INTERVAL: Final[dict[str, timedelta]] = {
|
| 153 |
-
"power": timedelta(seconds=10),
|
| 154 |
-
"stretch": timedelta(seconds=60),
|
| 155 |
-
"thermostat": timedelta(seconds=60),
|
| 156 |
-
}
|
| 157 |
-
DEFAULT_TIMEOUT: Final[int] = 30
|
| 158 |
-
DEFAULT_USERNAME: Final = "smile"
|
| 159 |
|
| 160 |
-
# --- Const for Plugwise Smile and Stretch
|
| 161 |
PLATFORMS: Final[list[str]] = [
|
| 162 |
Platform.BINARY_SENSOR,
|
| 163 |
Platform.BUTTON,
|
|
@@ -167,18 +39,6 @@
|
|
| 167 |
Platform.SENSOR,
|
| 168 |
Platform.SWITCH,
|
| 169 |
]
|
| 170 |
-
SERVICE_DELETE: Final = "delete_notification"
|
| 171 |
-
SEVERITIES: Final[list[str]] = ["other", "info", "message", "warning", "error"]
|
| 172 |
-
|
| 173 |
-
# Climate const:
|
| 174 |
-
MASTER_THERMOSTATS: Final[list[str]] = [
|
| 175 |
-
"thermostat",
|
| 176 |
-
"zone_thermometer",
|
| 177 |
-
"zone_thermostat",
|
| 178 |
-
"thermostatic_radiator_valve",
|
| 179 |
-
]
|
| 180 |
-
|
| 181 |
-
# Config_flow const:
|
| 182 |
ZEROCONF_MAP: Final[dict[str, str]] = {
|
| 183 |
"smile": "Smile P1",
|
| 184 |
"smile_thermo": "Smile Anna",
|
|
@@ -197,7 +57,7 @@
|
|
| 197 |
"select_gateway_mode",
|
| 198 |
"select_regulation_mode",
|
| 199 |
"select_schedule",
|
| 200 |
-
"select_zone_profile"
|
| 201 |
]
|
| 202 |
type SelectOptionsType = Literal[
|
| 203 |
"available_schedules",
|
|
@@ -206,3 +66,28 @@
|
|
| 206 |
"regulation_modes",
|
| 207 |
"zone_profiles",
|
| 208 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
"""Constants for Plugwise component."""
|
| 2 |
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
from datetime import timedelta
|
| 6 |
import logging
|
| 7 |
from typing import Final, Literal
|
| 8 |
|
| 9 |
from homeassistant.const import Platform
|
| 10 |
|
|
|
|
|
|
|
| 11 |
DOMAIN: Final = "plugwise"
|
| 12 |
|
| 13 |
LOGGER = logging.getLogger(__package__)
|
| 14 |
|
| 15 |
+
ANNA_WITH_ADAM: Final = "anna_with_adam"
|
| 16 |
API: Final = "api"
|
| 17 |
+
AVAILABLE: Final = "available"
|
| 18 |
+
DEV_CLASS: Final = "dev_class"
|
| 19 |
+
FLOW_SMILE: Final = "smile (Adam/Anna/P1)"
|
| 20 |
+
FLOW_STRETCH: Final = "stretch (Stretch)"
|
| 21 |
+
FLOW_TYPE: Final = "flow_type"
|
| 22 |
GATEWAY: Final = "gateway"
|
| 23 |
LOCATION: Final = "location"
|
| 24 |
+
PW_TYPE: Final = "plugwise_type"
|
| 25 |
REBOOT: Final = "reboot"
|
| 26 |
SMILE: Final = "smile"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
SMILE_OPEN_THERM: Final = "smile_open_therm"
|
| 28 |
SMILE_THERMO: Final = "smile_thermo"
|
| 29 |
+
STRETCH: Final = "stretch"
|
| 30 |
+
STRETCH_USERNAME: Final = "stretch"
|
| 31 |
+
UNKNOWN_SMILE: Final = "Unknown Smile"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
|
|
|
| 33 |
PLATFORMS: Final[list[str]] = [
|
| 34 |
Platform.BINARY_SENSOR,
|
| 35 |
Platform.BUTTON,
|
|
|
|
| 39 |
Platform.SENSOR,
|
| 40 |
Platform.SWITCH,
|
| 41 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
ZEROCONF_MAP: Final[dict[str, str]] = {
|
| 43 |
"smile": "Smile P1",
|
| 44 |
"smile_thermo": "Smile Anna",
|
|
|
|
| 57 |
"select_gateway_mode",
|
| 58 |
"select_regulation_mode",
|
| 59 |
"select_schedule",
|
| 60 |
+
"select_zone_profile",
|
| 61 |
]
|
| 62 |
type SelectOptionsType = Literal[
|
| 63 |
"available_schedules",
|
|
|
|
| 66 |
"regulation_modes",
|
| 67 |
"zone_profiles",
|
| 68 |
]
|
| 69 |
+
|
| 70 |
+
# Default directives
|
| 71 |
+
DEFAULT_MAX_TEMP: Final = 30
|
| 72 |
+
DEFAULT_MIN_TEMP: Final = 4
|
| 73 |
+
DEFAULT_PORT: Final = 80
|
| 74 |
+
DEFAULT_SCAN_INTERVAL: Final[dict[str, timedelta]] = {
|
| 75 |
+
"power": timedelta(seconds=10),
|
| 76 |
+
"stretch": timedelta(seconds=60),
|
| 77 |
+
"thermostat": timedelta(seconds=60),
|
| 78 |
+
}
|
| 79 |
+
DEFAULT_USERNAME: Final = "smile"
|
| 80 |
+
|
| 81 |
+
MASTER_THERMOSTATS: Final[list[str]] = [
|
| 82 |
+
"thermostat",
|
| 83 |
+
"thermostatic_radiator_valve",
|
| 84 |
+
"zone_thermometer",
|
| 85 |
+
"zone_thermostat",
|
| 86 |
+
]
|
| 87 |
+
|
| 88 |
+
# Select constants
|
| 89 |
+
SELECT_DHW_MODE: Final = "select_dhw_mode"
|
| 90 |
+
SELECT_GATEWAY_MODE: Final = "select_gateway_mode"
|
| 91 |
+
SELECT_REGULATION_MODE: Final = "select_regulation_mode"
|
| 92 |
+
SELECT_SCHEDULE: Final = "select_schedule"
|
| 93 |
+
SELECT_ZONE_PROFILE: Final = "select_zone_profile"
|
|
@@ -2,6 +2,7 @@
|
|
| 2 |
|
| 3 |
from datetime import timedelta
|
| 4 |
|
|
|
|
| 5 |
from plugwise import GwEntityData, Smile
|
| 6 |
from plugwise.exceptions import (
|
| 7 |
ConnectionFailedError,
|
|
@@ -13,22 +14,15 @@
|
|
| 13 |
)
|
| 14 |
|
| 15 |
from homeassistant.config_entries import ConfigEntry
|
| 16 |
-
from homeassistant.const import
|
| 17 |
-
CONF_HOST,
|
| 18 |
-
CONF_PASSWORD,
|
| 19 |
-
CONF_PORT,
|
| 20 |
-
CONF_SCAN_INTERVAL, # pw-beta options
|
| 21 |
-
CONF_USERNAME,
|
| 22 |
-
)
|
| 23 |
from homeassistant.core import HomeAssistant
|
| 24 |
from homeassistant.exceptions import ConfigEntryError
|
| 25 |
from homeassistant.helpers import device_registry as dr
|
| 26 |
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
| 27 |
from homeassistant.helpers.debounce import Debouncer
|
| 28 |
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
| 29 |
-
from packaging.version import Version
|
| 30 |
|
| 31 |
-
from .const import
|
| 32 |
|
| 33 |
type PlugwiseConfigEntry = ConfigEntry[PlugwiseDataUpdateCoordinator]
|
| 34 |
|
|
@@ -40,57 +34,38 @@
|
|
| 40 |
|
| 41 |
config_entry: PlugwiseConfigEntry
|
| 42 |
|
| 43 |
-
def __init__(
|
| 44 |
-
self,
|
| 45 |
-
hass: HomeAssistant,
|
| 46 |
-
cooldown: float,
|
| 47 |
-
config_entry: PlugwiseConfigEntry,
|
| 48 |
-
update_interval: timedelta = timedelta(seconds=60),
|
| 49 |
-
) -> None: # pw-beta cooldown
|
| 50 |
"""Initialize the coordinator."""
|
| 51 |
super().__init__(
|
| 52 |
hass,
|
| 53 |
LOGGER,
|
| 54 |
config_entry=config_entry,
|
| 55 |
name=DOMAIN,
|
| 56 |
-
|
| 57 |
-
# Upstream check correct progress for adjusting
|
| 58 |
-
update_interval=update_interval,
|
| 59 |
# Don't refresh immediately, give the device time to process
|
| 60 |
# the change in state before we query it.
|
| 61 |
request_refresh_debouncer=Debouncer(
|
| 62 |
hass,
|
| 63 |
LOGGER,
|
| 64 |
-
cooldown=
|
| 65 |
immediate=False,
|
| 66 |
),
|
| 67 |
)
|
| 68 |
|
| 69 |
self.api = Smile(
|
| 70 |
host=self.config_entry.data[CONF_HOST],
|
|
|
|
| 71 |
password=self.config_entry.data[CONF_PASSWORD],
|
| 72 |
-
port=self.config_entry.data
|
| 73 |
-
username=self.config_entry.data[CONF_USERNAME],
|
| 74 |
websession=async_get_clientsession(hass, verify_ssl=False),
|
| 75 |
)
|
| 76 |
self._current_devices: set[str] = set()
|
| 77 |
self.new_devices: set[str] = set()
|
| 78 |
-
self.update_interval = update_interval
|
| 79 |
|
| 80 |
async def _connect(self) -> None:
|
| 81 |
"""Connect to the Plugwise Smile."""
|
| 82 |
version = await self.api.connect()
|
| 83 |
self._connected = isinstance(version, Version)
|
| 84 |
-
if self._connected:
|
| 85 |
-
self.update_interval = DEFAULT_SCAN_INTERVAL.get(
|
| 86 |
-
self.api.smile.type, timedelta(seconds=60)
|
| 87 |
-
) # pw-beta options scan-interval
|
| 88 |
-
if (custom_time := self.config_entry.options.get(CONF_SCAN_INTERVAL)) is not None:
|
| 89 |
-
self.update_interval = timedelta(
|
| 90 |
-
seconds=int(custom_time)
|
| 91 |
-
) # pragma: no cover # pw-beta options
|
| 92 |
-
|
| 93 |
-
LOGGER.debug("DUC update interval: %s", self.update_interval) # pw-beta options
|
| 94 |
|
| 95 |
async def _async_update_data(self) -> dict[str, GwEntityData]:
|
| 96 |
"""Fetch data from Plugwise."""
|
|
@@ -109,7 +84,6 @@
|
|
| 109 |
translation_key="authentication_failed",
|
| 110 |
) from err
|
| 111 |
except (InvalidXMLError, ResponseError) as err:
|
| 112 |
-
# pwbeta TODO; we had {err} in the text, but not upstream, do we want this?
|
| 113 |
raise UpdateFailed(
|
| 114 |
translation_domain=DOMAIN,
|
| 115 |
translation_key="invalid_xml_data",
|
|
@@ -125,11 +99,10 @@
|
|
| 125 |
translation_key="unsupported_firmware",
|
| 126 |
) from err
|
| 127 |
|
| 128 |
-
|
| 129 |
-
await self._async_add_remove_devices(data)
|
| 130 |
return data
|
| 131 |
|
| 132 |
-
|
| 133 |
"""Add new Plugwise devices, remove non-existing devices."""
|
| 134 |
# Check for new or removed devices
|
| 135 |
self.new_devices = set(data) - self._current_devices
|
|
@@ -137,34 +110,34 @@
|
|
| 137 |
self._current_devices = set(data)
|
| 138 |
|
| 139 |
if removed_devices:
|
| 140 |
-
|
| 141 |
|
| 142 |
-
|
| 143 |
"""Clean registries when removed devices found."""
|
| 144 |
device_reg = dr.async_get(self.hass)
|
| 145 |
device_list = dr.async_entries_for_config_entry(
|
| 146 |
device_reg, self.config_entry.entry_id
|
| 147 |
)
|
| 148 |
-
|
| 149 |
# First find the Plugwise via_device
|
| 150 |
gateway_device = device_reg.async_get_device({(DOMAIN, self.api.gateway_id)})
|
| 151 |
-
|
| 152 |
-
|
| 153 |
|
| 154 |
# Then remove the connected orphaned device(s)
|
| 155 |
for device_entry in device_list:
|
| 156 |
for identifier in device_entry.identifiers:
|
| 157 |
-
if
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
|
|
|
|
|
| 2 |
|
| 3 |
from datetime import timedelta
|
| 4 |
|
| 5 |
+
from packaging.version import Version
|
| 6 |
from plugwise import GwEntityData, Smile
|
| 7 |
from plugwise.exceptions import (
|
| 8 |
ConnectionFailedError,
|
|
|
|
| 14 |
)
|
| 15 |
|
| 16 |
from homeassistant.config_entries import ConfigEntry
|
| 17 |
+
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
from homeassistant.core import HomeAssistant
|
| 19 |
from homeassistant.exceptions import ConfigEntryError
|
| 20 |
from homeassistant.helpers import device_registry as dr
|
| 21 |
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
| 22 |
from homeassistant.helpers.debounce import Debouncer
|
| 23 |
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
|
|
|
| 24 |
|
| 25 |
+
from .const import DEFAULT_PORT, DEFAULT_USERNAME, DOMAIN, LOGGER
|
| 26 |
|
| 27 |
type PlugwiseConfigEntry = ConfigEntry[PlugwiseDataUpdateCoordinator]
|
| 28 |
|
|
|
|
| 34 |
|
| 35 |
config_entry: PlugwiseConfigEntry
|
| 36 |
|
| 37 |
+
def __init__(self, hass: HomeAssistant, config_entry: PlugwiseConfigEntry) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
"""Initialize the coordinator."""
|
| 39 |
super().__init__(
|
| 40 |
hass,
|
| 41 |
LOGGER,
|
| 42 |
config_entry=config_entry,
|
| 43 |
name=DOMAIN,
|
| 44 |
+
update_interval=timedelta(seconds=60),
|
|
|
|
|
|
|
| 45 |
# Don't refresh immediately, give the device time to process
|
| 46 |
# the change in state before we query it.
|
| 47 |
request_refresh_debouncer=Debouncer(
|
| 48 |
hass,
|
| 49 |
LOGGER,
|
| 50 |
+
cooldown=1.5,
|
| 51 |
immediate=False,
|
| 52 |
),
|
| 53 |
)
|
| 54 |
|
| 55 |
self.api = Smile(
|
| 56 |
host=self.config_entry.data[CONF_HOST],
|
| 57 |
+
username=self.config_entry.data.get(CONF_USERNAME, DEFAULT_USERNAME),
|
| 58 |
password=self.config_entry.data[CONF_PASSWORD],
|
| 59 |
+
port=self.config_entry.data.get(CONF_PORT, DEFAULT_PORT),
|
|
|
|
| 60 |
websession=async_get_clientsession(hass, verify_ssl=False),
|
| 61 |
)
|
| 62 |
self._current_devices: set[str] = set()
|
| 63 |
self.new_devices: set[str] = set()
|
|
|
|
| 64 |
|
| 65 |
async def _connect(self) -> None:
|
| 66 |
"""Connect to the Plugwise Smile."""
|
| 67 |
version = await self.api.connect()
|
| 68 |
self._connected = isinstance(version, Version)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
async def _async_update_data(self) -> dict[str, GwEntityData]:
|
| 71 |
"""Fetch data from Plugwise."""
|
|
|
|
| 84 |
translation_key="authentication_failed",
|
| 85 |
) from err
|
| 86 |
except (InvalidXMLError, ResponseError) as err:
|
|
|
|
| 87 |
raise UpdateFailed(
|
| 88 |
translation_domain=DOMAIN,
|
| 89 |
translation_key="invalid_xml_data",
|
|
|
|
| 99 |
translation_key="unsupported_firmware",
|
| 100 |
) from err
|
| 101 |
|
| 102 |
+
self._async_add_remove_devices(data)
|
|
|
|
| 103 |
return data
|
| 104 |
|
| 105 |
+
def _async_add_remove_devices(self, data: dict[str, GwEntityData]) -> None:
|
| 106 |
"""Add new Plugwise devices, remove non-existing devices."""
|
| 107 |
# Check for new or removed devices
|
| 108 |
self.new_devices = set(data) - self._current_devices
|
|
|
|
| 110 |
self._current_devices = set(data)
|
| 111 |
|
| 112 |
if removed_devices:
|
| 113 |
+
self._async_remove_devices(data)
|
| 114 |
|
| 115 |
+
def _async_remove_devices(self, data: dict[str, GwEntityData]) -> None:
|
| 116 |
"""Clean registries when removed devices found."""
|
| 117 |
device_reg = dr.async_get(self.hass)
|
| 118 |
device_list = dr.async_entries_for_config_entry(
|
| 119 |
device_reg, self.config_entry.entry_id
|
| 120 |
)
|
|
|
|
| 121 |
# First find the Plugwise via_device
|
| 122 |
gateway_device = device_reg.async_get_device({(DOMAIN, self.api.gateway_id)})
|
| 123 |
+
assert gateway_device is not None
|
| 124 |
+
via_device_id = gateway_device.id
|
| 125 |
|
| 126 |
# Then remove the connected orphaned device(s)
|
| 127 |
for device_entry in device_list:
|
| 128 |
for identifier in device_entry.identifiers:
|
| 129 |
+
if identifier[0] == DOMAIN:
|
| 130 |
+
if (
|
| 131 |
+
device_entry.via_device_id == via_device_id
|
| 132 |
+
and identifier[1] not in data
|
| 133 |
+
):
|
| 134 |
+
device_reg.async_update_device(
|
| 135 |
+
device_entry.id,
|
| 136 |
+
remove_config_entry_id=self.config_entry.entry_id,
|
| 137 |
+
)
|
| 138 |
+
LOGGER.debug(
|
| 139 |
+
"Removed %s device %s %s from device_registry",
|
| 140 |
+
DOMAIN,
|
| 141 |
+
device_entry.model,
|
| 142 |
+
identifier[1],
|
| 143 |
+
)
|
|
@@ -12,19 +12,7 @@
|
|
| 12 |
)
|
| 13 |
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
| 14 |
|
| 15 |
-
from .const import
|
| 16 |
-
AVAILABLE,
|
| 17 |
-
DOMAIN,
|
| 18 |
-
FIRMWARE,
|
| 19 |
-
HARDWARE,
|
| 20 |
-
MAC_ADDRESS,
|
| 21 |
-
MODEL,
|
| 22 |
-
MODEL_ID,
|
| 23 |
-
VENDOR,
|
| 24 |
-
ZIGBEE_MAC_ADDRESS,
|
| 25 |
-
)
|
| 26 |
-
|
| 27 |
-
# Upstream consts
|
| 28 |
from .coordinator import PlugwiseDataUpdateCoordinator
|
| 29 |
|
| 30 |
|
|
@@ -43,29 +31,26 @@
|
|
| 43 |
self._dev_id = device_id
|
| 44 |
|
| 45 |
configuration_url: str | None = None
|
| 46 |
-
if
|
| 47 |
-
device_id == coordinator.api.gateway_id
|
| 48 |
-
and (entry := self.coordinator.config_entry)
|
| 49 |
-
):
|
| 50 |
configuration_url = f"http://{entry.data[CONF_HOST]}"
|
| 51 |
|
| 52 |
data = coordinator.data[device_id]
|
| 53 |
connections = set()
|
| 54 |
-
if mac := data.get(
|
| 55 |
connections.add((CONNECTION_NETWORK_MAC, mac))
|
| 56 |
-
if mac := data.get(
|
| 57 |
connections.add((CONNECTION_ZIGBEE, mac))
|
| 58 |
|
| 59 |
self._attr_device_info = DeviceInfo(
|
| 60 |
configuration_url=configuration_url,
|
| 61 |
identifiers={(DOMAIN, device_id)},
|
| 62 |
connections=connections,
|
| 63 |
-
manufacturer=data.get(
|
| 64 |
-
model=data.get(
|
| 65 |
-
model_id=data.get(
|
| 66 |
name=coordinator.api.smile.name,
|
| 67 |
-
sw_version=data.get(
|
| 68 |
-
hw_version=data.get(
|
| 69 |
)
|
| 70 |
|
| 71 |
if device_id != coordinator.api.gateway_id:
|
|
@@ -83,10 +68,8 @@
|
|
| 83 |
def available(self) -> bool:
|
| 84 |
"""Return if entity is available."""
|
| 85 |
return (
|
| 86 |
-
# Upstream: Do not change the AVAILABLE line below: some Plugwise devices and zones
|
| 87 |
-
# Upstream: do not provide their availability-status!
|
| 88 |
self._dev_id in self.coordinator.data
|
| 89 |
-
and (self.device.
|
| 90 |
and super().available
|
| 91 |
)
|
| 92 |
|
|
|
|
| 12 |
)
|
| 13 |
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
| 14 |
|
| 15 |
+
from .const import AVAILABLE, DOMAIN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
from .coordinator import PlugwiseDataUpdateCoordinator
|
| 17 |
|
| 18 |
|
|
|
|
| 31 |
self._dev_id = device_id
|
| 32 |
|
| 33 |
configuration_url: str | None = None
|
| 34 |
+
if entry := self.coordinator.config_entry:
|
|
|
|
|
|
|
|
|
|
| 35 |
configuration_url = f"http://{entry.data[CONF_HOST]}"
|
| 36 |
|
| 37 |
data = coordinator.data[device_id]
|
| 38 |
connections = set()
|
| 39 |
+
if mac := data.get("mac_address"):
|
| 40 |
connections.add((CONNECTION_NETWORK_MAC, mac))
|
| 41 |
+
if mac := data.get("zigbee_mac_address"):
|
| 42 |
connections.add((CONNECTION_ZIGBEE, mac))
|
| 43 |
|
| 44 |
self._attr_device_info = DeviceInfo(
|
| 45 |
configuration_url=configuration_url,
|
| 46 |
identifiers={(DOMAIN, device_id)},
|
| 47 |
connections=connections,
|
| 48 |
+
manufacturer=data.get("vendor"),
|
| 49 |
+
model=data.get("model"),
|
| 50 |
+
model_id=data.get("model_id"),
|
| 51 |
name=coordinator.api.smile.name,
|
| 52 |
+
sw_version=data.get("firmware"),
|
| 53 |
+
hw_version=data.get("hardware"),
|
| 54 |
)
|
| 55 |
|
| 56 |
if device_id != coordinator.api.gateway_id:
|
|
|
|
| 68 |
def available(self) -> bool:
|
| 69 |
"""Return if entity is available."""
|
| 70 |
return (
|
|
|
|
|
|
|
| 71 |
self._dev_id in self.coordinator.data
|
| 72 |
+
and (AVAILABLE not in self.device or self.device[AVAILABLE] is True)
|
| 73 |
and super().available
|
| 74 |
)
|
| 75 |
|
|
@@ -66,11 +66,11 @@
|
|
| 66 |
"dhw_mode": {
|
| 67 |
"default": "mdi:shower",
|
| 68 |
"state": {
|
|
|
|
|
|
|
| 69 |
"comfort": "mdi:sofa",
|
| 70 |
"eco": "mdi:leaf",
|
| 71 |
-
"off": "mdi:circle-off-outline"
|
| 72 |
-
"boost": "mdi:rocket-launch",
|
| 73 |
-
"auto": "mdi:auto-mode"
|
| 74 |
}
|
| 75 |
},
|
| 76 |
"gateway_mode": {
|
|
@@ -84,11 +84,11 @@
|
|
| 84 |
"regulation_mode": {
|
| 85 |
"default": "mdi:hvac",
|
| 86 |
"state": {
|
| 87 |
-
"bleeding_hot": "mdi:fire-circle",
|
| 88 |
"bleeding_cold": "mdi:water-circle",
|
| 89 |
-
"
|
|
|
|
| 90 |
"heating": "mdi:radiator",
|
| 91 |
-
"
|
| 92 |
}
|
| 93 |
},
|
| 94 |
"select_schedule": {
|
|
@@ -120,8 +120,5 @@
|
|
| 120 |
"default": "mdi:lock"
|
| 121 |
}
|
| 122 |
}
|
| 123 |
-
},
|
| 124 |
-
"services": {
|
| 125 |
-
"delete_notification": "mdi:trash-can"
|
| 126 |
}
|
| 127 |
}
|
|
|
|
| 66 |
"dhw_mode": {
|
| 67 |
"default": "mdi:shower",
|
| 68 |
"state": {
|
| 69 |
+
"auto": "mdi:auto-mode",
|
| 70 |
+
"boost": "mdi:rocket-launch",
|
| 71 |
"comfort": "mdi:sofa",
|
| 72 |
"eco": "mdi:leaf",
|
| 73 |
+
"off": "mdi:circle-off-outline"
|
|
|
|
|
|
|
| 74 |
}
|
| 75 |
},
|
| 76 |
"gateway_mode": {
|
|
|
|
| 84 |
"regulation_mode": {
|
| 85 |
"default": "mdi:hvac",
|
| 86 |
"state": {
|
|
|
|
| 87 |
"bleeding_cold": "mdi:water-circle",
|
| 88 |
+
"bleeding_hot": "mdi:fire-circle",
|
| 89 |
+
"cooling": "mdi:snowflake",
|
| 90 |
"heating": "mdi:radiator",
|
| 91 |
+
"off": "mdi:circle-off-outline"
|
| 92 |
}
|
| 93 |
},
|
| 94 |
"select_schedule": {
|
|
|
|
| 120 |
"default": "mdi:lock"
|
| 121 |
}
|
| 122 |
}
|
|
|
|
|
|
|
|
|
|
| 123 |
}
|
| 124 |
}
|
|
@@ -1,13 +1,13 @@
|
|
| 1 |
{
|
| 2 |
"domain": "plugwise",
|
| 3 |
-
"name": "Plugwise
|
| 4 |
"codeowners": ["@CoMPaTech", "@bouwew"],
|
| 5 |
"config_flow": true,
|
| 6 |
-
"documentation": "https://
|
| 7 |
"integration_type": "hub",
|
| 8 |
"iot_class": "local_polling",
|
| 9 |
"loggers": ["plugwise"],
|
| 10 |
-
"
|
| 11 |
-
"
|
| 12 |
"zeroconf": ["_plugwise._tcp.local."]
|
| 13 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"domain": "plugwise",
|
| 3 |
+
"name": "Plugwise",
|
| 4 |
"codeowners": ["@CoMPaTech", "@bouwew"],
|
| 5 |
"config_flow": true,
|
| 6 |
+
"documentation": "https://www.home-assistant.io/integrations/plugwise",
|
| 7 |
"integration_type": "hub",
|
| 8 |
"iot_class": "local_polling",
|
| 9 |
"loggers": ["plugwise"],
|
| 10 |
+
"quality_scale": "platinum",
|
| 11 |
+
"requirements": ["plugwise==1.10.0"],
|
| 12 |
"zeroconf": ["_plugwise._tcp.local."]
|
| 13 |
}
|
|
@@ -14,18 +14,7 @@
|
|
| 14 |
from homeassistant.core import HomeAssistant, callback
|
| 15 |
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
| 16 |
|
| 17 |
-
from .const import
|
| 18 |
-
LOGGER,
|
| 19 |
-
LOWER_BOUND,
|
| 20 |
-
MAX_BOILER_TEMP,
|
| 21 |
-
MAX_DHW_TEMP,
|
| 22 |
-
RESOLUTION,
|
| 23 |
-
TEMPERATURE_OFFSET,
|
| 24 |
-
UPPER_BOUND,
|
| 25 |
-
NumberType,
|
| 26 |
-
)
|
| 27 |
-
|
| 28 |
-
# Upstream consts
|
| 29 |
from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator
|
| 30 |
from .entity import PlugwiseEntity
|
| 31 |
from .util import plugwise_command
|
|
@@ -40,25 +29,24 @@
|
|
| 40 |
key: NumberType
|
| 41 |
|
| 42 |
|
| 43 |
-
# Upstream + is there a reason we didn't rename this one prefixed?
|
| 44 |
NUMBER_TYPES = (
|
| 45 |
PlugwiseNumberEntityDescription(
|
| 46 |
-
key=
|
| 47 |
-
translation_key=
|
| 48 |
device_class=NumberDeviceClass.TEMPERATURE,
|
| 49 |
entity_category=EntityCategory.CONFIG,
|
| 50 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 51 |
),
|
| 52 |
PlugwiseNumberEntityDescription(
|
| 53 |
-
key=
|
| 54 |
-
translation_key=
|
| 55 |
device_class=NumberDeviceClass.TEMPERATURE,
|
| 56 |
entity_category=EntityCategory.CONFIG,
|
| 57 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 58 |
),
|
| 59 |
PlugwiseNumberEntityDescription(
|
| 60 |
-
key=
|
| 61 |
-
translation_key=
|
| 62 |
device_class=NumberDeviceClass.TEMPERATURE,
|
| 63 |
entity_category=EntityCategory.CONFIG,
|
| 64 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
@@ -71,8 +59,7 @@
|
|
| 71 |
entry: PlugwiseConfigEntry,
|
| 72 |
async_add_entities: AddConfigEntryEntitiesCallback,
|
| 73 |
) -> None:
|
| 74 |
-
"""Set up Plugwise number platform
|
| 75 |
-
# Upstream above to adhere to standard used
|
| 76 |
coordinator = entry.runtime_data
|
| 77 |
|
| 78 |
@callback
|
|
@@ -81,28 +68,12 @@
|
|
| 81 |
if not coordinator.new_devices:
|
| 82 |
return
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
# )
|
| 91 |
-
|
| 92 |
-
# pw-beta alternative for debugging
|
| 93 |
-
entities: list[PlugwiseNumberEntity] = []
|
| 94 |
-
for device_id in coordinator.new_devices:
|
| 95 |
-
device = coordinator.data[device_id]
|
| 96 |
-
for description in NUMBER_TYPES:
|
| 97 |
-
if description.key in device:
|
| 98 |
-
entities.append(
|
| 99 |
-
PlugwiseNumberEntity(coordinator, device_id, description)
|
| 100 |
-
)
|
| 101 |
-
LOGGER.debug(
|
| 102 |
-
"Add %s %s number", device["name"], description.translation_key
|
| 103 |
-
)
|
| 104 |
-
|
| 105 |
-
async_add_entities(entities)
|
| 106 |
|
| 107 |
_add_entities()
|
| 108 |
entry.async_on_unload(coordinator.async_add_listener(_add_entities))
|
|
@@ -121,28 +92,26 @@
|
|
| 121 |
) -> None:
|
| 122 |
"""Initiate Plugwise Number."""
|
| 123 |
super().__init__(coordinator, device_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
self.device_id = device_id
|
| 125 |
self.entity_description = description
|
| 126 |
-
self._attr_unique_id = f"{device_id}-{description.key}"
|
| 127 |
-
self._attr_mode = NumberMode.BOX
|
| 128 |
-
ctrl = self.device.get(description.key, {})
|
| 129 |
-
self._attr_native_max_value = ctrl.get(UPPER_BOUND, 100.0) # Upstream const
|
| 130 |
-
self._attr_native_min_value = ctrl.get(LOWER_BOUND, 0.0) # Upstream const
|
| 131 |
|
| 132 |
-
native_step =
|
| 133 |
-
if description.key !=
|
| 134 |
native_step = max(native_step, 0.5)
|
| 135 |
self._attr_native_step = native_step
|
| 136 |
|
| 137 |
@property
|
| 138 |
-
def native_value(self) -> float
|
| 139 |
"""Return the present setpoint value."""
|
| 140 |
-
return self.device
|
| 141 |
|
| 142 |
@plugwise_command
|
| 143 |
async def async_set_native_value(self, value: float) -> None:
|
| 144 |
"""Change to the new setpoint value."""
|
| 145 |
-
await self.coordinator.api.set_number(
|
| 146 |
-
|
| 147 |
-
"Setting %s to %s was successful", self.entity_description.key, value
|
| 148 |
)
|
|
|
|
| 14 |
from homeassistant.core import HomeAssistant, callback
|
| 15 |
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
| 16 |
|
| 17 |
+
from .const import NumberType
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator
|
| 19 |
from .entity import PlugwiseEntity
|
| 20 |
from .util import plugwise_command
|
|
|
|
| 29 |
key: NumberType
|
| 30 |
|
| 31 |
|
|
|
|
| 32 |
NUMBER_TYPES = (
|
| 33 |
PlugwiseNumberEntityDescription(
|
| 34 |
+
key="maximum_boiler_temperature",
|
| 35 |
+
translation_key="maximum_boiler_temperature",
|
| 36 |
device_class=NumberDeviceClass.TEMPERATURE,
|
| 37 |
entity_category=EntityCategory.CONFIG,
|
| 38 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 39 |
),
|
| 40 |
PlugwiseNumberEntityDescription(
|
| 41 |
+
key="max_dhw_temperature",
|
| 42 |
+
translation_key="max_dhw_temperature",
|
| 43 |
device_class=NumberDeviceClass.TEMPERATURE,
|
| 44 |
entity_category=EntityCategory.CONFIG,
|
| 45 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 46 |
),
|
| 47 |
PlugwiseNumberEntityDescription(
|
| 48 |
+
key="temperature_offset",
|
| 49 |
+
translation_key="temperature_offset",
|
| 50 |
device_class=NumberDeviceClass.TEMPERATURE,
|
| 51 |
entity_category=EntityCategory.CONFIG,
|
| 52 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
|
|
| 59 |
entry: PlugwiseConfigEntry,
|
| 60 |
async_add_entities: AddConfigEntryEntitiesCallback,
|
| 61 |
) -> None:
|
| 62 |
+
"""Set up Plugwise number platform."""
|
|
|
|
| 63 |
coordinator = entry.runtime_data
|
| 64 |
|
| 65 |
@callback
|
|
|
|
| 68 |
if not coordinator.new_devices:
|
| 69 |
return
|
| 70 |
|
| 71 |
+
async_add_entities(
|
| 72 |
+
PlugwiseNumberEntity(coordinator, device_id, description)
|
| 73 |
+
for device_id in coordinator.new_devices
|
| 74 |
+
for description in NUMBER_TYPES
|
| 75 |
+
if description.key in coordinator.data[device_id]
|
| 76 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
_add_entities()
|
| 79 |
entry.async_on_unload(coordinator.async_add_listener(_add_entities))
|
|
|
|
| 92 |
) -> None:
|
| 93 |
"""Initiate Plugwise Number."""
|
| 94 |
super().__init__(coordinator, device_id)
|
| 95 |
+
self._attr_mode = NumberMode.BOX
|
| 96 |
+
self._attr_native_max_value = self.device[description.key]["upper_bound"]
|
| 97 |
+
self._attr_native_min_value = self.device[description.key]["lower_bound"]
|
| 98 |
+
self._attr_unique_id = f"{device_id}-{description.key}"
|
| 99 |
self.device_id = device_id
|
| 100 |
self.entity_description = description
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
+
native_step = self.device[description.key]["resolution"]
|
| 103 |
+
if description.key != "temperature_offset":
|
| 104 |
native_step = max(native_step, 0.5)
|
| 105 |
self._attr_native_step = native_step
|
| 106 |
|
| 107 |
@property
|
| 108 |
+
def native_value(self) -> float:
|
| 109 |
"""Return the present setpoint value."""
|
| 110 |
+
return self.device[self.entity_description.key]["setpoint"]
|
| 111 |
|
| 112 |
@plugwise_command
|
| 113 |
async def async_set_native_value(self, value: float) -> None:
|
| 114 |
"""Change to the new setpoint value."""
|
| 115 |
+
await self.coordinator.api.set_number(
|
| 116 |
+
self.device_id, self.entity_description.key, value
|
|
|
|
| 117 |
)
|
|
@@ -10,23 +10,14 @@
|
|
| 10 |
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
| 11 |
|
| 12 |
from .const import (
|
| 13 |
-
AVAILABLE_SCHEDULES,
|
| 14 |
-
DHW_MODES,
|
| 15 |
-
GATEWAY_MODES,
|
| 16 |
-
LOCATION,
|
| 17 |
-
LOGGER,
|
| 18 |
-
REGULATION_MODES,
|
| 19 |
SELECT_DHW_MODE,
|
| 20 |
SELECT_GATEWAY_MODE,
|
| 21 |
SELECT_REGULATION_MODE,
|
| 22 |
SELECT_SCHEDULE,
|
| 23 |
SELECT_ZONE_PROFILE,
|
| 24 |
-
ZONE_PROFILES,
|
| 25 |
SelectOptionsType,
|
| 26 |
SelectType,
|
| 27 |
)
|
| 28 |
-
|
| 29 |
-
# Upstream consts
|
| 30 |
from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator
|
| 31 |
from .entity import PlugwiseEntity
|
| 32 |
from .util import plugwise_command
|
|
@@ -42,37 +33,36 @@
|
|
| 42 |
options_key: SelectOptionsType
|
| 43 |
|
| 44 |
|
| 45 |
-
# Upstream
|
| 46 |
SELECT_TYPES = (
|
| 47 |
PlugwiseSelectEntityDescription(
|
| 48 |
key=SELECT_SCHEDULE,
|
| 49 |
translation_key=SELECT_SCHEDULE,
|
| 50 |
entity_category=EntityCategory.CONFIG,
|
| 51 |
-
options_key=
|
| 52 |
),
|
| 53 |
PlugwiseSelectEntityDescription(
|
| 54 |
key=SELECT_REGULATION_MODE,
|
| 55 |
translation_key=SELECT_REGULATION_MODE,
|
| 56 |
entity_category=EntityCategory.CONFIG,
|
| 57 |
-
options_key=
|
| 58 |
),
|
| 59 |
PlugwiseSelectEntityDescription(
|
| 60 |
key=SELECT_DHW_MODE,
|
| 61 |
translation_key=SELECT_DHW_MODE,
|
| 62 |
entity_category=EntityCategory.CONFIG,
|
| 63 |
-
options_key=
|
| 64 |
),
|
| 65 |
PlugwiseSelectEntityDescription(
|
| 66 |
key=SELECT_GATEWAY_MODE,
|
| 67 |
translation_key=SELECT_GATEWAY_MODE,
|
| 68 |
entity_category=EntityCategory.CONFIG,
|
| 69 |
-
options_key=
|
| 70 |
),
|
| 71 |
PlugwiseSelectEntityDescription(
|
| 72 |
key=SELECT_ZONE_PROFILE,
|
| 73 |
translation_key=SELECT_ZONE_PROFILE,
|
| 74 |
entity_category=EntityCategory.CONFIG,
|
| 75 |
-
options_key=
|
| 76 |
),
|
| 77 |
)
|
| 78 |
|
|
@@ -82,7 +72,7 @@
|
|
| 82 |
entry: PlugwiseConfigEntry,
|
| 83 |
async_add_entities: AddConfigEntryEntitiesCallback,
|
| 84 |
) -> None:
|
| 85 |
-
"""Set up
|
| 86 |
coordinator = entry.runtime_data
|
| 87 |
|
| 88 |
@callback
|
|
@@ -91,27 +81,12 @@
|
|
| 91 |
if not coordinator.new_devices:
|
| 92 |
return
|
| 93 |
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
# )
|
| 101 |
-
# pw-beta alternative for debugging
|
| 102 |
-
entities: list[PlugwiseSelectEntity] = []
|
| 103 |
-
for device_id in coordinator.new_devices:
|
| 104 |
-
device = coordinator.data[device_id]
|
| 105 |
-
for description in SELECT_TYPES:
|
| 106 |
-
if device.get(description.options_key):
|
| 107 |
-
entities.append(
|
| 108 |
-
PlugwiseSelectEntity(coordinator, device_id, description)
|
| 109 |
-
)
|
| 110 |
-
LOGGER.debug(
|
| 111 |
-
"Add %s %s selector", device["name"], description.translation_key
|
| 112 |
-
)
|
| 113 |
-
|
| 114 |
-
async_add_entities(entities)
|
| 115 |
|
| 116 |
_add_entities()
|
| 117 |
entry.async_on_unload(coordinator.async_add_listener(_add_entities))
|
|
@@ -134,30 +109,25 @@
|
|
| 134 |
self.entity_description = entity_description
|
| 135 |
|
| 136 |
self._location = device_id
|
| 137 |
-
if (location := self.device.get(
|
| 138 |
self._location = location
|
| 139 |
|
| 140 |
@property
|
| 141 |
def current_option(self) -> str | None:
|
| 142 |
"""Return the selected entity option to represent the entity state."""
|
| 143 |
-
return self.device
|
| 144 |
|
| 145 |
@property
|
| 146 |
def options(self) -> list[str]:
|
| 147 |
"""Return the available select-options."""
|
| 148 |
-
return self.device
|
| 149 |
|
| 150 |
@plugwise_command
|
| 151 |
async def async_select_option(self, option: str) -> None:
|
| 152 |
"""Change to the selected entity option.
|
| 153 |
|
| 154 |
-
|
| 155 |
"""
|
| 156 |
await self.coordinator.api.set_select(
|
| 157 |
self.entity_description.key, self._location, option, STATE_ON
|
| 158 |
)
|
| 159 |
-
LOGGER.debug(
|
| 160 |
-
"Set %s to %s was successful",
|
| 161 |
-
self.entity_description.key,
|
| 162 |
-
option,
|
| 163 |
-
)
|
|
|
|
| 10 |
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
| 11 |
|
| 12 |
from .const import (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
SELECT_DHW_MODE,
|
| 14 |
SELECT_GATEWAY_MODE,
|
| 15 |
SELECT_REGULATION_MODE,
|
| 16 |
SELECT_SCHEDULE,
|
| 17 |
SELECT_ZONE_PROFILE,
|
|
|
|
| 18 |
SelectOptionsType,
|
| 19 |
SelectType,
|
| 20 |
)
|
|
|
|
|
|
|
| 21 |
from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator
|
| 22 |
from .entity import PlugwiseEntity
|
| 23 |
from .util import plugwise_command
|
|
|
|
| 33 |
options_key: SelectOptionsType
|
| 34 |
|
| 35 |
|
|
|
|
| 36 |
SELECT_TYPES = (
|
| 37 |
PlugwiseSelectEntityDescription(
|
| 38 |
key=SELECT_SCHEDULE,
|
| 39 |
translation_key=SELECT_SCHEDULE,
|
| 40 |
entity_category=EntityCategory.CONFIG,
|
| 41 |
+
options_key="available_schedules",
|
| 42 |
),
|
| 43 |
PlugwiseSelectEntityDescription(
|
| 44 |
key=SELECT_REGULATION_MODE,
|
| 45 |
translation_key=SELECT_REGULATION_MODE,
|
| 46 |
entity_category=EntityCategory.CONFIG,
|
| 47 |
+
options_key="regulation_modes",
|
| 48 |
),
|
| 49 |
PlugwiseSelectEntityDescription(
|
| 50 |
key=SELECT_DHW_MODE,
|
| 51 |
translation_key=SELECT_DHW_MODE,
|
| 52 |
entity_category=EntityCategory.CONFIG,
|
| 53 |
+
options_key="dhw_modes",
|
| 54 |
),
|
| 55 |
PlugwiseSelectEntityDescription(
|
| 56 |
key=SELECT_GATEWAY_MODE,
|
| 57 |
translation_key=SELECT_GATEWAY_MODE,
|
| 58 |
entity_category=EntityCategory.CONFIG,
|
| 59 |
+
options_key="gateway_modes",
|
| 60 |
),
|
| 61 |
PlugwiseSelectEntityDescription(
|
| 62 |
key=SELECT_ZONE_PROFILE,
|
| 63 |
translation_key=SELECT_ZONE_PROFILE,
|
| 64 |
entity_category=EntityCategory.CONFIG,
|
| 65 |
+
options_key="zone_profiles",
|
| 66 |
),
|
| 67 |
)
|
| 68 |
|
|
|
|
| 72 |
entry: PlugwiseConfigEntry,
|
| 73 |
async_add_entities: AddConfigEntryEntitiesCallback,
|
| 74 |
) -> None:
|
| 75 |
+
"""Set up the Smile selector from a config entry."""
|
| 76 |
coordinator = entry.runtime_data
|
| 77 |
|
| 78 |
@callback
|
|
|
|
| 81 |
if not coordinator.new_devices:
|
| 82 |
return
|
| 83 |
|
| 84 |
+
async_add_entities(
|
| 85 |
+
PlugwiseSelectEntity(coordinator, device_id, description)
|
| 86 |
+
for device_id in coordinator.new_devices
|
| 87 |
+
for description in SELECT_TYPES
|
| 88 |
+
if coordinator.data[device_id].get(description.options_key)
|
| 89 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
_add_entities()
|
| 92 |
entry.async_on_unload(coordinator.async_add_listener(_add_entities))
|
|
|
|
| 109 |
self.entity_description = entity_description
|
| 110 |
|
| 111 |
self._location = device_id
|
| 112 |
+
if (location := self.device.get("location")) is not None:
|
| 113 |
self._location = location
|
| 114 |
|
| 115 |
@property
|
| 116 |
def current_option(self) -> str | None:
|
| 117 |
"""Return the selected entity option to represent the entity state."""
|
| 118 |
+
return self.device[self.entity_description.key]
|
| 119 |
|
| 120 |
@property
|
| 121 |
def options(self) -> list[str]:
|
| 122 |
"""Return the available select-options."""
|
| 123 |
+
return self.device[self.entity_description.options_key]
|
| 124 |
|
| 125 |
@plugwise_command
|
| 126 |
async def async_select_option(self, option: str) -> None:
|
| 127 |
"""Change to the selected entity option.
|
| 128 |
|
| 129 |
+
self._location and STATE_ON are required for the thermostat-schedule select.
|
| 130 |
"""
|
| 131 |
await self.coordinator.api.set_select(
|
| 132 |
self.entity_description.key, self._location, option, STATE_ON
|
| 133 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -13,7 +13,6 @@
|
|
| 13 |
SensorStateClass,
|
| 14 |
)
|
| 15 |
from homeassistant.const import (
|
| 16 |
-
ATTR_TEMPERATURE, # Upstream
|
| 17 |
LIGHT_LUX,
|
| 18 |
PERCENTAGE,
|
| 19 |
EntityCategory,
|
|
@@ -28,57 +27,6 @@
|
|
| 28 |
from homeassistant.core import HomeAssistant, callback
|
| 29 |
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
| 30 |
|
| 31 |
-
from .const import (
|
| 32 |
-
DHW_SETPOINT,
|
| 33 |
-
DHW_TEMP,
|
| 34 |
-
EL_CONS_INTERVAL,
|
| 35 |
-
EL_CONS_OP_CUMULATIVE,
|
| 36 |
-
EL_CONS_OP_INTERVAL,
|
| 37 |
-
EL_CONS_OP_POINT,
|
| 38 |
-
EL_CONS_P_CUMULATIVE,
|
| 39 |
-
EL_CONS_P_INTERVAL,
|
| 40 |
-
EL_CONS_P_POINT,
|
| 41 |
-
EL_CONS_POINT,
|
| 42 |
-
EL_CONSUMED,
|
| 43 |
-
EL_PH1_CONSUMED,
|
| 44 |
-
EL_PH1_PRODUCED,
|
| 45 |
-
EL_PH2_CONSUMED,
|
| 46 |
-
EL_PH2_PRODUCED,
|
| 47 |
-
EL_PH3_CONSUMED,
|
| 48 |
-
EL_PH3_PRODUCED,
|
| 49 |
-
EL_PROD_INTERVAL,
|
| 50 |
-
EL_PROD_OP_CUMULATIVE,
|
| 51 |
-
EL_PROD_OP_INTERVAL,
|
| 52 |
-
EL_PROD_OP_POINT,
|
| 53 |
-
EL_PROD_P_CUMULATIVE,
|
| 54 |
-
EL_PROD_P_INTERVAL,
|
| 55 |
-
EL_PROD_P_POINT,
|
| 56 |
-
EL_PROD_POINT,
|
| 57 |
-
EL_PRODUCED,
|
| 58 |
-
GAS_CONS_CUMULATIVE,
|
| 59 |
-
GAS_CONS_INTERVAL,
|
| 60 |
-
INTENDED_BOILER_TEMP,
|
| 61 |
-
LOGGER, # pw-beta
|
| 62 |
-
MOD_LEVEL,
|
| 63 |
-
NET_EL_CUMULATIVE,
|
| 64 |
-
NET_EL_POINT,
|
| 65 |
-
OUTDOOR_AIR_TEMP,
|
| 66 |
-
OUTDOOR_TEMP,
|
| 67 |
-
RETURN_TEMP,
|
| 68 |
-
SENSORS,
|
| 69 |
-
TARGET_TEMP,
|
| 70 |
-
TARGET_TEMP_HIGH,
|
| 71 |
-
TARGET_TEMP_LOW,
|
| 72 |
-
TEMP_DIFF,
|
| 73 |
-
VALVE_POS,
|
| 74 |
-
VOLTAGE_PH1,
|
| 75 |
-
VOLTAGE_PH2,
|
| 76 |
-
VOLTAGE_PH3,
|
| 77 |
-
WATER_PRESSURE,
|
| 78 |
-
WATER_TEMP,
|
| 79 |
-
)
|
| 80 |
-
|
| 81 |
-
# Upstream consts
|
| 82 |
from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator
|
| 83 |
from .entity import PlugwiseEntity
|
| 84 |
|
|
@@ -93,301 +41,299 @@
|
|
| 93 |
key: SensorType
|
| 94 |
|
| 95 |
|
| 96 |
-
|
| 97 |
-
PLUGWISE_SENSORS: tuple[PlugwiseSensorEntityDescription, ...] = (
|
| 98 |
PlugwiseSensorEntityDescription(
|
| 99 |
-
key=
|
| 100 |
-
translation_key=
|
| 101 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 102 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 103 |
state_class=SensorStateClass.MEASUREMENT,
|
| 104 |
),
|
| 105 |
PlugwiseSensorEntityDescription(
|
| 106 |
-
key=
|
| 107 |
translation_key="cooling_setpoint",
|
| 108 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 109 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 110 |
state_class=SensorStateClass.MEASUREMENT,
|
| 111 |
),
|
| 112 |
PlugwiseSensorEntityDescription(
|
| 113 |
-
key=
|
| 114 |
translation_key="heating_setpoint",
|
| 115 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 116 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 117 |
state_class=SensorStateClass.MEASUREMENT,
|
| 118 |
),
|
| 119 |
PlugwiseSensorEntityDescription(
|
| 120 |
-
key=
|
| 121 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 122 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 123 |
state_class=SensorStateClass.MEASUREMENT,
|
| 124 |
),
|
| 125 |
PlugwiseSensorEntityDescription(
|
| 126 |
-
key=
|
| 127 |
-
translation_key=
|
| 128 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 129 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 130 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 131 |
state_class=SensorStateClass.MEASUREMENT,
|
| 132 |
),
|
| 133 |
PlugwiseSensorEntityDescription(
|
| 134 |
-
key=
|
| 135 |
-
translation_key=
|
| 136 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 137 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 138 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 139 |
state_class=SensorStateClass.MEASUREMENT,
|
| 140 |
),
|
| 141 |
PlugwiseSensorEntityDescription(
|
| 142 |
-
key=
|
| 143 |
-
translation_key=
|
| 144 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 145 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 146 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 147 |
state_class=SensorStateClass.MEASUREMENT,
|
| 148 |
-
suggested_display_precision=1,
|
| 149 |
),
|
| 150 |
PlugwiseSensorEntityDescription(
|
| 151 |
-
key=
|
| 152 |
-
translation_key=
|
| 153 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 154 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 155 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 156 |
state_class=SensorStateClass.MEASUREMENT,
|
| 157 |
),
|
| 158 |
PlugwiseSensorEntityDescription(
|
| 159 |
-
key=
|
| 160 |
-
translation_key=
|
| 161 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 162 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 163 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 164 |
state_class=SensorStateClass.MEASUREMENT,
|
| 165 |
),
|
| 166 |
PlugwiseSensorEntityDescription(
|
| 167 |
-
key=
|
| 168 |
-
translation_key=
|
| 169 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 170 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 171 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 172 |
state_class=SensorStateClass.MEASUREMENT,
|
| 173 |
),
|
| 174 |
PlugwiseSensorEntityDescription(
|
| 175 |
-
key=
|
| 176 |
-
translation_key=
|
| 177 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 178 |
device_class=SensorDeviceClass.POWER,
|
| 179 |
state_class=SensorStateClass.MEASUREMENT,
|
| 180 |
),
|
| 181 |
PlugwiseSensorEntityDescription(
|
| 182 |
-
key=
|
| 183 |
-
translation_key=
|
| 184 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 185 |
device_class=SensorDeviceClass.POWER,
|
| 186 |
state_class=SensorStateClass.MEASUREMENT,
|
| 187 |
entity_registry_enabled_default=False,
|
| 188 |
),
|
| 189 |
PlugwiseSensorEntityDescription(
|
| 190 |
-
key=
|
| 191 |
-
translation_key=
|
| 192 |
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
| 193 |
device_class=SensorDeviceClass.ENERGY,
|
| 194 |
state_class=SensorStateClass.TOTAL,
|
| 195 |
),
|
| 196 |
PlugwiseSensorEntityDescription(
|
| 197 |
-
key=
|
| 198 |
-
translation_key=
|
| 199 |
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
| 200 |
device_class=SensorDeviceClass.ENERGY,
|
| 201 |
state_class=SensorStateClass.TOTAL,
|
| 202 |
),
|
| 203 |
PlugwiseSensorEntityDescription(
|
| 204 |
-
key=
|
| 205 |
-
translation_key=
|
| 206 |
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
| 207 |
device_class=SensorDeviceClass.ENERGY,
|
| 208 |
state_class=SensorStateClass.TOTAL,
|
| 209 |
),
|
| 210 |
PlugwiseSensorEntityDescription(
|
| 211 |
-
key=
|
| 212 |
-
translation_key=
|
| 213 |
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
| 214 |
device_class=SensorDeviceClass.ENERGY,
|
| 215 |
state_class=SensorStateClass.TOTAL,
|
| 216 |
entity_registry_enabled_default=False,
|
| 217 |
),
|
| 218 |
PlugwiseSensorEntityDescription(
|
| 219 |
-
key=
|
| 220 |
-
translation_key=
|
| 221 |
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
| 222 |
device_class=SensorDeviceClass.ENERGY,
|
| 223 |
state_class=SensorStateClass.TOTAL,
|
| 224 |
),
|
| 225 |
PlugwiseSensorEntityDescription(
|
| 226 |
-
key=
|
| 227 |
-
translation_key=
|
| 228 |
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
| 229 |
device_class=SensorDeviceClass.ENERGY,
|
| 230 |
state_class=SensorStateClass.TOTAL,
|
| 231 |
),
|
| 232 |
PlugwiseSensorEntityDescription(
|
| 233 |
-
key=
|
| 234 |
-
translation_key=
|
| 235 |
device_class=SensorDeviceClass.POWER,
|
| 236 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 237 |
state_class=SensorStateClass.MEASUREMENT,
|
| 238 |
),
|
| 239 |
PlugwiseSensorEntityDescription(
|
| 240 |
-
key=
|
| 241 |
-
translation_key=
|
| 242 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 243 |
device_class=SensorDeviceClass.POWER,
|
| 244 |
state_class=SensorStateClass.MEASUREMENT,
|
| 245 |
),
|
| 246 |
PlugwiseSensorEntityDescription(
|
| 247 |
-
key=
|
| 248 |
-
translation_key=
|
| 249 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 250 |
device_class=SensorDeviceClass.POWER,
|
| 251 |
state_class=SensorStateClass.MEASUREMENT,
|
| 252 |
),
|
| 253 |
PlugwiseSensorEntityDescription(
|
| 254 |
-
key=
|
| 255 |
-
translation_key=
|
| 256 |
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
| 257 |
device_class=SensorDeviceClass.ENERGY,
|
| 258 |
state_class=SensorStateClass.TOTAL_INCREASING,
|
| 259 |
),
|
| 260 |
PlugwiseSensorEntityDescription(
|
| 261 |
-
key=
|
| 262 |
-
translation_key=
|
| 263 |
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
| 264 |
device_class=SensorDeviceClass.ENERGY,
|
| 265 |
state_class=SensorStateClass.TOTAL_INCREASING,
|
| 266 |
),
|
| 267 |
PlugwiseSensorEntityDescription(
|
| 268 |
-
key=
|
| 269 |
-
translation_key=
|
| 270 |
device_class=SensorDeviceClass.POWER,
|
| 271 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 272 |
state_class=SensorStateClass.MEASUREMENT,
|
| 273 |
),
|
| 274 |
PlugwiseSensorEntityDescription(
|
| 275 |
-
key=
|
| 276 |
-
translation_key=
|
| 277 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 278 |
device_class=SensorDeviceClass.POWER,
|
| 279 |
state_class=SensorStateClass.MEASUREMENT,
|
| 280 |
),
|
| 281 |
PlugwiseSensorEntityDescription(
|
| 282 |
-
key=
|
| 283 |
-
translation_key=
|
| 284 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 285 |
device_class=SensorDeviceClass.POWER,
|
| 286 |
state_class=SensorStateClass.MEASUREMENT,
|
| 287 |
),
|
| 288 |
PlugwiseSensorEntityDescription(
|
| 289 |
-
key=
|
| 290 |
-
translation_key=
|
| 291 |
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
| 292 |
device_class=SensorDeviceClass.ENERGY,
|
| 293 |
state_class=SensorStateClass.TOTAL_INCREASING,
|
| 294 |
),
|
| 295 |
PlugwiseSensorEntityDescription(
|
| 296 |
-
key=
|
| 297 |
-
translation_key=
|
| 298 |
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
| 299 |
device_class=SensorDeviceClass.ENERGY,
|
| 300 |
state_class=SensorStateClass.TOTAL_INCREASING,
|
| 301 |
),
|
| 302 |
PlugwiseSensorEntityDescription(
|
| 303 |
-
key=
|
| 304 |
-
translation_key=
|
| 305 |
device_class=SensorDeviceClass.POWER,
|
| 306 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 307 |
state_class=SensorStateClass.MEASUREMENT,
|
| 308 |
),
|
| 309 |
PlugwiseSensorEntityDescription(
|
| 310 |
-
key=
|
| 311 |
-
translation_key=
|
| 312 |
device_class=SensorDeviceClass.POWER,
|
| 313 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 314 |
state_class=SensorStateClass.MEASUREMENT,
|
| 315 |
),
|
| 316 |
PlugwiseSensorEntityDescription(
|
| 317 |
-
key=
|
| 318 |
-
translation_key=
|
| 319 |
device_class=SensorDeviceClass.POWER,
|
| 320 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 321 |
state_class=SensorStateClass.MEASUREMENT,
|
| 322 |
),
|
| 323 |
PlugwiseSensorEntityDescription(
|
| 324 |
-
key=
|
| 325 |
-
translation_key=
|
| 326 |
device_class=SensorDeviceClass.POWER,
|
| 327 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 328 |
state_class=SensorStateClass.MEASUREMENT,
|
| 329 |
),
|
| 330 |
PlugwiseSensorEntityDescription(
|
| 331 |
-
key=
|
| 332 |
-
translation_key=
|
| 333 |
device_class=SensorDeviceClass.POWER,
|
| 334 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 335 |
state_class=SensorStateClass.MEASUREMENT,
|
| 336 |
),
|
| 337 |
PlugwiseSensorEntityDescription(
|
| 338 |
-
key=
|
| 339 |
-
translation_key=
|
| 340 |
device_class=SensorDeviceClass.POWER,
|
| 341 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 342 |
state_class=SensorStateClass.MEASUREMENT,
|
| 343 |
),
|
| 344 |
PlugwiseSensorEntityDescription(
|
| 345 |
-
key=
|
| 346 |
-
translation_key=
|
| 347 |
device_class=SensorDeviceClass.VOLTAGE,
|
| 348 |
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
| 349 |
state_class=SensorStateClass.MEASUREMENT,
|
| 350 |
entity_registry_enabled_default=False,
|
| 351 |
),
|
| 352 |
PlugwiseSensorEntityDescription(
|
| 353 |
-
key=
|
| 354 |
-
translation_key=
|
| 355 |
device_class=SensorDeviceClass.VOLTAGE,
|
| 356 |
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
| 357 |
state_class=SensorStateClass.MEASUREMENT,
|
| 358 |
entity_registry_enabled_default=False,
|
| 359 |
),
|
| 360 |
PlugwiseSensorEntityDescription(
|
| 361 |
-
key=
|
| 362 |
-
translation_key=
|
| 363 |
device_class=SensorDeviceClass.VOLTAGE,
|
| 364 |
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
| 365 |
state_class=SensorStateClass.MEASUREMENT,
|
| 366 |
entity_registry_enabled_default=False,
|
| 367 |
),
|
| 368 |
PlugwiseSensorEntityDescription(
|
| 369 |
-
key=
|
| 370 |
-
translation_key=
|
| 371 |
native_unit_of_measurement=UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR,
|
| 372 |
state_class=SensorStateClass.MEASUREMENT,
|
| 373 |
),
|
| 374 |
PlugwiseSensorEntityDescription(
|
| 375 |
-
key=
|
| 376 |
-
translation_key=
|
| 377 |
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
| 378 |
device_class=SensorDeviceClass.GAS,
|
| 379 |
state_class=SensorStateClass.TOTAL,
|
| 380 |
),
|
| 381 |
PlugwiseSensorEntityDescription(
|
| 382 |
-
key=
|
| 383 |
-
translation_key=
|
| 384 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 385 |
device_class=SensorDeviceClass.POWER,
|
| 386 |
state_class=SensorStateClass.MEASUREMENT,
|
| 387 |
),
|
| 388 |
PlugwiseSensorEntityDescription(
|
| 389 |
-
key=
|
| 390 |
-
translation_key=
|
| 391 |
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
| 392 |
device_class=SensorDeviceClass.ENERGY,
|
| 393 |
state_class=SensorStateClass.TOTAL,
|
|
@@ -407,22 +353,22 @@
|
|
| 407 |
state_class=SensorStateClass.MEASUREMENT,
|
| 408 |
),
|
| 409 |
PlugwiseSensorEntityDescription(
|
| 410 |
-
key=
|
| 411 |
-
translation_key=
|
| 412 |
native_unit_of_measurement=PERCENTAGE,
|
| 413 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 414 |
state_class=SensorStateClass.MEASUREMENT,
|
| 415 |
),
|
| 416 |
PlugwiseSensorEntityDescription(
|
| 417 |
-
key=
|
| 418 |
-
translation_key=
|
| 419 |
native_unit_of_measurement=PERCENTAGE,
|
| 420 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 421 |
state_class=SensorStateClass.MEASUREMENT,
|
| 422 |
),
|
| 423 |
PlugwiseSensorEntityDescription(
|
| 424 |
-
key=
|
| 425 |
-
translation_key=
|
| 426 |
native_unit_of_measurement=UnitOfPressure.BAR,
|
| 427 |
device_class=SensorDeviceClass.PRESSURE,
|
| 428 |
entity_category=EntityCategory.DIAGNOSTIC,
|
|
@@ -435,16 +381,16 @@
|
|
| 435 |
state_class=SensorStateClass.MEASUREMENT,
|
| 436 |
),
|
| 437 |
PlugwiseSensorEntityDescription(
|
| 438 |
-
key=
|
| 439 |
-
translation_key=
|
| 440 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 441 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 442 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 443 |
state_class=SensorStateClass.MEASUREMENT,
|
| 444 |
),
|
| 445 |
PlugwiseSensorEntityDescription(
|
| 446 |
-
key=
|
| 447 |
-
translation_key=
|
| 448 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 449 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 450 |
entity_category=EntityCategory.DIAGNOSTIC,
|
|
@@ -458,8 +404,7 @@
|
|
| 458 |
entry: PlugwiseConfigEntry,
|
| 459 |
async_add_entities: AddConfigEntryEntitiesCallback,
|
| 460 |
) -> None:
|
| 461 |
-
"""Set up
|
| 462 |
-
# Upstream as Plugwise not Smile
|
| 463 |
coordinator = entry.runtime_data
|
| 464 |
|
| 465 |
@callback
|
|
@@ -468,29 +413,13 @@
|
|
| 468 |
if not coordinator.new_devices:
|
| 469 |
return
|
| 470 |
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
# )
|
| 479 |
-
# pw-beta alternative for debugging
|
| 480 |
-
entities: list[PlugwiseSensorEntity] = []
|
| 481 |
-
for device_id in coordinator.new_devices:
|
| 482 |
-
device = coordinator.data[device_id]
|
| 483 |
-
if not (sensors := device.get(SENSORS)):
|
| 484 |
-
continue
|
| 485 |
-
for description in PLUGWISE_SENSORS:
|
| 486 |
-
if description.key not in sensors:
|
| 487 |
-
continue
|
| 488 |
-
entities.append(PlugwiseSensorEntity(coordinator, device_id, description))
|
| 489 |
-
LOGGER.debug(
|
| 490 |
-
"Add %s %s sensor", device["name"], description.translation_key or description.key
|
| 491 |
-
)
|
| 492 |
-
|
| 493 |
-
async_add_entities(entities)
|
| 494 |
|
| 495 |
_add_entities()
|
| 496 |
entry.async_on_unload(coordinator.async_add_listener(_add_entities))
|
|
@@ -509,10 +438,10 @@
|
|
| 509 |
) -> None:
|
| 510 |
"""Initialise the sensor."""
|
| 511 |
super().__init__(coordinator, device_id)
|
| 512 |
-
self.entity_description = description
|
| 513 |
self._attr_unique_id = f"{device_id}-{description.key}"
|
|
|
|
| 514 |
|
| 515 |
@property
|
| 516 |
-
def native_value(self) -> int | float
|
| 517 |
"""Return the value reported by the sensor."""
|
| 518 |
-
return self.device
|
|
|
|
| 13 |
SensorStateClass,
|
| 14 |
)
|
| 15 |
from homeassistant.const import (
|
|
|
|
| 16 |
LIGHT_LUX,
|
| 17 |
PERCENTAGE,
|
| 18 |
EntityCategory,
|
|
|
|
| 27 |
from homeassistant.core import HomeAssistant, callback
|
| 28 |
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator
|
| 31 |
from .entity import PlugwiseEntity
|
| 32 |
|
|
|
|
| 41 |
key: SensorType
|
| 42 |
|
| 43 |
|
| 44 |
+
SENSORS: tuple[PlugwiseSensorEntityDescription, ...] = (
|
|
|
|
| 45 |
PlugwiseSensorEntityDescription(
|
| 46 |
+
key="setpoint",
|
| 47 |
+
translation_key="setpoint",
|
| 48 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 49 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 50 |
state_class=SensorStateClass.MEASUREMENT,
|
| 51 |
),
|
| 52 |
PlugwiseSensorEntityDescription(
|
| 53 |
+
key="setpoint_high",
|
| 54 |
translation_key="cooling_setpoint",
|
| 55 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 56 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 57 |
state_class=SensorStateClass.MEASUREMENT,
|
| 58 |
),
|
| 59 |
PlugwiseSensorEntityDescription(
|
| 60 |
+
key="setpoint_low",
|
| 61 |
translation_key="heating_setpoint",
|
| 62 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 63 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 64 |
state_class=SensorStateClass.MEASUREMENT,
|
| 65 |
),
|
| 66 |
PlugwiseSensorEntityDescription(
|
| 67 |
+
key="temperature",
|
| 68 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 69 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 70 |
state_class=SensorStateClass.MEASUREMENT,
|
| 71 |
),
|
| 72 |
PlugwiseSensorEntityDescription(
|
| 73 |
+
key="intended_boiler_temperature",
|
| 74 |
+
translation_key="intended_boiler_temperature",
|
| 75 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 76 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 77 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 78 |
state_class=SensorStateClass.MEASUREMENT,
|
| 79 |
),
|
| 80 |
PlugwiseSensorEntityDescription(
|
| 81 |
+
key="temperature_difference",
|
| 82 |
+
translation_key="temperature_difference",
|
| 83 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 84 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 85 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 86 |
state_class=SensorStateClass.MEASUREMENT,
|
| 87 |
),
|
| 88 |
PlugwiseSensorEntityDescription(
|
| 89 |
+
key="outdoor_temperature",
|
| 90 |
+
translation_key="outdoor_temperature",
|
| 91 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 92 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 93 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 94 |
state_class=SensorStateClass.MEASUREMENT,
|
|
|
|
| 95 |
),
|
| 96 |
PlugwiseSensorEntityDescription(
|
| 97 |
+
key="outdoor_air_temperature",
|
| 98 |
+
translation_key="outdoor_air_temperature",
|
| 99 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 100 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 101 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 102 |
state_class=SensorStateClass.MEASUREMENT,
|
| 103 |
),
|
| 104 |
PlugwiseSensorEntityDescription(
|
| 105 |
+
key="water_temperature",
|
| 106 |
+
translation_key="water_temperature",
|
| 107 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 108 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 109 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 110 |
state_class=SensorStateClass.MEASUREMENT,
|
| 111 |
),
|
| 112 |
PlugwiseSensorEntityDescription(
|
| 113 |
+
key="return_temperature",
|
| 114 |
+
translation_key="return_temperature",
|
| 115 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 116 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 117 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 118 |
state_class=SensorStateClass.MEASUREMENT,
|
| 119 |
),
|
| 120 |
PlugwiseSensorEntityDescription(
|
| 121 |
+
key="electricity_consumed",
|
| 122 |
+
translation_key="electricity_consumed",
|
| 123 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 124 |
device_class=SensorDeviceClass.POWER,
|
| 125 |
state_class=SensorStateClass.MEASUREMENT,
|
| 126 |
),
|
| 127 |
PlugwiseSensorEntityDescription(
|
| 128 |
+
key="electricity_produced",
|
| 129 |
+
translation_key="electricity_produced",
|
| 130 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 131 |
device_class=SensorDeviceClass.POWER,
|
| 132 |
state_class=SensorStateClass.MEASUREMENT,
|
| 133 |
entity_registry_enabled_default=False,
|
| 134 |
),
|
| 135 |
PlugwiseSensorEntityDescription(
|
| 136 |
+
key="electricity_consumed_interval",
|
| 137 |
+
translation_key="electricity_consumed_interval",
|
| 138 |
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
| 139 |
device_class=SensorDeviceClass.ENERGY,
|
| 140 |
state_class=SensorStateClass.TOTAL,
|
| 141 |
),
|
| 142 |
PlugwiseSensorEntityDescription(
|
| 143 |
+
key="electricity_consumed_peak_interval",
|
| 144 |
+
translation_key="electricity_consumed_peak_interval",
|
| 145 |
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
| 146 |
device_class=SensorDeviceClass.ENERGY,
|
| 147 |
state_class=SensorStateClass.TOTAL,
|
| 148 |
),
|
| 149 |
PlugwiseSensorEntityDescription(
|
| 150 |
+
key="electricity_consumed_off_peak_interval",
|
| 151 |
+
translation_key="electricity_consumed_off_peak_interval",
|
| 152 |
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
| 153 |
device_class=SensorDeviceClass.ENERGY,
|
| 154 |
state_class=SensorStateClass.TOTAL,
|
| 155 |
),
|
| 156 |
PlugwiseSensorEntityDescription(
|
| 157 |
+
key="electricity_produced_interval",
|
| 158 |
+
translation_key="electricity_produced_interval",
|
| 159 |
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
| 160 |
device_class=SensorDeviceClass.ENERGY,
|
| 161 |
state_class=SensorStateClass.TOTAL,
|
| 162 |
entity_registry_enabled_default=False,
|
| 163 |
),
|
| 164 |
PlugwiseSensorEntityDescription(
|
| 165 |
+
key="electricity_produced_peak_interval",
|
| 166 |
+
translation_key="electricity_produced_peak_interval",
|
| 167 |
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
| 168 |
device_class=SensorDeviceClass.ENERGY,
|
| 169 |
state_class=SensorStateClass.TOTAL,
|
| 170 |
),
|
| 171 |
PlugwiseSensorEntityDescription(
|
| 172 |
+
key="electricity_produced_off_peak_interval",
|
| 173 |
+
translation_key="electricity_produced_off_peak_interval",
|
| 174 |
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
| 175 |
device_class=SensorDeviceClass.ENERGY,
|
| 176 |
state_class=SensorStateClass.TOTAL,
|
| 177 |
),
|
| 178 |
PlugwiseSensorEntityDescription(
|
| 179 |
+
key="electricity_consumed_point",
|
| 180 |
+
translation_key="electricity_consumed_point",
|
| 181 |
device_class=SensorDeviceClass.POWER,
|
| 182 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 183 |
state_class=SensorStateClass.MEASUREMENT,
|
| 184 |
),
|
| 185 |
PlugwiseSensorEntityDescription(
|
| 186 |
+
key="electricity_consumed_off_peak_point",
|
| 187 |
+
translation_key="electricity_consumed_off_peak_point",
|
| 188 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 189 |
device_class=SensorDeviceClass.POWER,
|
| 190 |
state_class=SensorStateClass.MEASUREMENT,
|
| 191 |
),
|
| 192 |
PlugwiseSensorEntityDescription(
|
| 193 |
+
key="electricity_consumed_peak_point",
|
| 194 |
+
translation_key="electricity_consumed_peak_point",
|
| 195 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 196 |
device_class=SensorDeviceClass.POWER,
|
| 197 |
state_class=SensorStateClass.MEASUREMENT,
|
| 198 |
),
|
| 199 |
PlugwiseSensorEntityDescription(
|
| 200 |
+
key="electricity_consumed_off_peak_cumulative",
|
| 201 |
+
translation_key="electricity_consumed_off_peak_cumulative",
|
| 202 |
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
| 203 |
device_class=SensorDeviceClass.ENERGY,
|
| 204 |
state_class=SensorStateClass.TOTAL_INCREASING,
|
| 205 |
),
|
| 206 |
PlugwiseSensorEntityDescription(
|
| 207 |
+
key="electricity_consumed_peak_cumulative",
|
| 208 |
+
translation_key="electricity_consumed_peak_cumulative",
|
| 209 |
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
| 210 |
device_class=SensorDeviceClass.ENERGY,
|
| 211 |
state_class=SensorStateClass.TOTAL_INCREASING,
|
| 212 |
),
|
| 213 |
PlugwiseSensorEntityDescription(
|
| 214 |
+
key="electricity_produced_point",
|
| 215 |
+
translation_key="electricity_produced_point",
|
| 216 |
device_class=SensorDeviceClass.POWER,
|
| 217 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 218 |
state_class=SensorStateClass.MEASUREMENT,
|
| 219 |
),
|
| 220 |
PlugwiseSensorEntityDescription(
|
| 221 |
+
key="electricity_produced_off_peak_point",
|
| 222 |
+
translation_key="electricity_produced_off_peak_point",
|
| 223 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 224 |
device_class=SensorDeviceClass.POWER,
|
| 225 |
state_class=SensorStateClass.MEASUREMENT,
|
| 226 |
),
|
| 227 |
PlugwiseSensorEntityDescription(
|
| 228 |
+
key="electricity_produced_peak_point",
|
| 229 |
+
translation_key="electricity_produced_peak_point",
|
| 230 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 231 |
device_class=SensorDeviceClass.POWER,
|
| 232 |
state_class=SensorStateClass.MEASUREMENT,
|
| 233 |
),
|
| 234 |
PlugwiseSensorEntityDescription(
|
| 235 |
+
key="electricity_produced_off_peak_cumulative",
|
| 236 |
+
translation_key="electricity_produced_off_peak_cumulative",
|
| 237 |
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
| 238 |
device_class=SensorDeviceClass.ENERGY,
|
| 239 |
state_class=SensorStateClass.TOTAL_INCREASING,
|
| 240 |
),
|
| 241 |
PlugwiseSensorEntityDescription(
|
| 242 |
+
key="electricity_produced_peak_cumulative",
|
| 243 |
+
translation_key="electricity_produced_peak_cumulative",
|
| 244 |
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
| 245 |
device_class=SensorDeviceClass.ENERGY,
|
| 246 |
state_class=SensorStateClass.TOTAL_INCREASING,
|
| 247 |
),
|
| 248 |
PlugwiseSensorEntityDescription(
|
| 249 |
+
key="electricity_phase_one_consumed",
|
| 250 |
+
translation_key="electricity_phase_one_consumed",
|
| 251 |
device_class=SensorDeviceClass.POWER,
|
| 252 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 253 |
state_class=SensorStateClass.MEASUREMENT,
|
| 254 |
),
|
| 255 |
PlugwiseSensorEntityDescription(
|
| 256 |
+
key="electricity_phase_two_consumed",
|
| 257 |
+
translation_key="electricity_phase_two_consumed",
|
| 258 |
device_class=SensorDeviceClass.POWER,
|
| 259 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 260 |
state_class=SensorStateClass.MEASUREMENT,
|
| 261 |
),
|
| 262 |
PlugwiseSensorEntityDescription(
|
| 263 |
+
key="electricity_phase_three_consumed",
|
| 264 |
+
translation_key="electricity_phase_three_consumed",
|
| 265 |
device_class=SensorDeviceClass.POWER,
|
| 266 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 267 |
state_class=SensorStateClass.MEASUREMENT,
|
| 268 |
),
|
| 269 |
PlugwiseSensorEntityDescription(
|
| 270 |
+
key="electricity_phase_one_produced",
|
| 271 |
+
translation_key="electricity_phase_one_produced",
|
| 272 |
device_class=SensorDeviceClass.POWER,
|
| 273 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 274 |
state_class=SensorStateClass.MEASUREMENT,
|
| 275 |
),
|
| 276 |
PlugwiseSensorEntityDescription(
|
| 277 |
+
key="electricity_phase_two_produced",
|
| 278 |
+
translation_key="electricity_phase_two_produced",
|
| 279 |
device_class=SensorDeviceClass.POWER,
|
| 280 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 281 |
state_class=SensorStateClass.MEASUREMENT,
|
| 282 |
),
|
| 283 |
PlugwiseSensorEntityDescription(
|
| 284 |
+
key="electricity_phase_three_produced",
|
| 285 |
+
translation_key="electricity_phase_three_produced",
|
| 286 |
device_class=SensorDeviceClass.POWER,
|
| 287 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 288 |
state_class=SensorStateClass.MEASUREMENT,
|
| 289 |
),
|
| 290 |
PlugwiseSensorEntityDescription(
|
| 291 |
+
key="voltage_phase_one",
|
| 292 |
+
translation_key="voltage_phase_one",
|
| 293 |
device_class=SensorDeviceClass.VOLTAGE,
|
| 294 |
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
| 295 |
state_class=SensorStateClass.MEASUREMENT,
|
| 296 |
entity_registry_enabled_default=False,
|
| 297 |
),
|
| 298 |
PlugwiseSensorEntityDescription(
|
| 299 |
+
key="voltage_phase_two",
|
| 300 |
+
translation_key="voltage_phase_two",
|
| 301 |
device_class=SensorDeviceClass.VOLTAGE,
|
| 302 |
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
| 303 |
state_class=SensorStateClass.MEASUREMENT,
|
| 304 |
entity_registry_enabled_default=False,
|
| 305 |
),
|
| 306 |
PlugwiseSensorEntityDescription(
|
| 307 |
+
key="voltage_phase_three",
|
| 308 |
+
translation_key="voltage_phase_three",
|
| 309 |
device_class=SensorDeviceClass.VOLTAGE,
|
| 310 |
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
| 311 |
state_class=SensorStateClass.MEASUREMENT,
|
| 312 |
entity_registry_enabled_default=False,
|
| 313 |
),
|
| 314 |
PlugwiseSensorEntityDescription(
|
| 315 |
+
key="gas_consumed_interval",
|
| 316 |
+
translation_key="gas_consumed_interval",
|
| 317 |
native_unit_of_measurement=UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR,
|
| 318 |
state_class=SensorStateClass.MEASUREMENT,
|
| 319 |
),
|
| 320 |
PlugwiseSensorEntityDescription(
|
| 321 |
+
key="gas_consumed_cumulative",
|
| 322 |
+
translation_key="gas_consumed_cumulative",
|
| 323 |
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
| 324 |
device_class=SensorDeviceClass.GAS,
|
| 325 |
state_class=SensorStateClass.TOTAL,
|
| 326 |
),
|
| 327 |
PlugwiseSensorEntityDescription(
|
| 328 |
+
key="net_electricity_point",
|
| 329 |
+
translation_key="net_electricity_point",
|
| 330 |
native_unit_of_measurement=UnitOfPower.WATT,
|
| 331 |
device_class=SensorDeviceClass.POWER,
|
| 332 |
state_class=SensorStateClass.MEASUREMENT,
|
| 333 |
),
|
| 334 |
PlugwiseSensorEntityDescription(
|
| 335 |
+
key="net_electricity_cumulative",
|
| 336 |
+
translation_key="net_electricity_cumulative",
|
| 337 |
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
| 338 |
device_class=SensorDeviceClass.ENERGY,
|
| 339 |
state_class=SensorStateClass.TOTAL,
|
|
|
|
| 353 |
state_class=SensorStateClass.MEASUREMENT,
|
| 354 |
),
|
| 355 |
PlugwiseSensorEntityDescription(
|
| 356 |
+
key="modulation_level",
|
| 357 |
+
translation_key="modulation_level",
|
| 358 |
native_unit_of_measurement=PERCENTAGE,
|
| 359 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 360 |
state_class=SensorStateClass.MEASUREMENT,
|
| 361 |
),
|
| 362 |
PlugwiseSensorEntityDescription(
|
| 363 |
+
key="valve_position",
|
| 364 |
+
translation_key="valve_position",
|
| 365 |
native_unit_of_measurement=PERCENTAGE,
|
| 366 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 367 |
state_class=SensorStateClass.MEASUREMENT,
|
| 368 |
),
|
| 369 |
PlugwiseSensorEntityDescription(
|
| 370 |
+
key="water_pressure",
|
| 371 |
+
translation_key="water_pressure",
|
| 372 |
native_unit_of_measurement=UnitOfPressure.BAR,
|
| 373 |
device_class=SensorDeviceClass.PRESSURE,
|
| 374 |
entity_category=EntityCategory.DIAGNOSTIC,
|
|
|
|
| 381 |
state_class=SensorStateClass.MEASUREMENT,
|
| 382 |
),
|
| 383 |
PlugwiseSensorEntityDescription(
|
| 384 |
+
key="dhw_temperature",
|
| 385 |
+
translation_key="dhw_temperature",
|
| 386 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 387 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 388 |
entity_category=EntityCategory.DIAGNOSTIC,
|
| 389 |
state_class=SensorStateClass.MEASUREMENT,
|
| 390 |
),
|
| 391 |
PlugwiseSensorEntityDescription(
|
| 392 |
+
key="domestic_hot_water_setpoint",
|
| 393 |
+
translation_key="domestic_hot_water_setpoint",
|
| 394 |
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
| 395 |
device_class=SensorDeviceClass.TEMPERATURE,
|
| 396 |
entity_category=EntityCategory.DIAGNOSTIC,
|
|
|
|
| 404 |
entry: PlugwiseConfigEntry,
|
| 405 |
async_add_entities: AddConfigEntryEntitiesCallback,
|
| 406 |
) -> None:
|
| 407 |
+
"""Set up the Smile sensors from a config entry."""
|
|
|
|
| 408 |
coordinator = entry.runtime_data
|
| 409 |
|
| 410 |
@callback
|
|
|
|
| 413 |
if not coordinator.new_devices:
|
| 414 |
return
|
| 415 |
|
| 416 |
+
async_add_entities(
|
| 417 |
+
PlugwiseSensorEntity(coordinator, device_id, description)
|
| 418 |
+
for device_id in coordinator.new_devices
|
| 419 |
+
if (sensors := coordinator.data[device_id].get("sensors"))
|
| 420 |
+
for description in SENSORS
|
| 421 |
+
if description.key in sensors
|
| 422 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 423 |
|
| 424 |
_add_entities()
|
| 425 |
entry.async_on_unload(coordinator.async_add_listener(_add_entities))
|
|
|
|
| 438 |
) -> None:
|
| 439 |
"""Initialise the sensor."""
|
| 440 |
super().__init__(coordinator, device_id)
|
|
|
|
| 441 |
self._attr_unique_id = f"{device_id}-{description.key}"
|
| 442 |
+
self.entity_description = description
|
| 443 |
|
| 444 |
@property
|
| 445 |
+
def native_value(self) -> int | float:
|
| 446 |
"""Return the value reported by the sensor."""
|
| 447 |
+
return self.device["sensors"][self.entity_description.key]
|
|
@@ -1,57 +1,47 @@
|
|
| 1 |
{
|
| 2 |
-
"options": {
|
| 3 |
-
"step": {
|
| 4 |
-
"none": {
|
| 5 |
-
"title": "No Options available",
|
| 6 |
-
"description": "This Integration does not provide any Options"
|
| 7 |
-
},
|
| 8 |
-
"init": {
|
| 9 |
-
"description": "Adjust Smile/Stretch Options",
|
| 10 |
-
"data": {
|
| 11 |
-
"cooling_on": "Anna: cooling-mode is on",
|
| 12 |
-
"scan_interval": "Scan Interval (seconds) *) beta-only option",
|
| 13 |
-
"homekit_emulation": "Homekit emulation (i.e. on hvac_off => Away) *) beta-only option",
|
| 14 |
-
"refresh_interval": "Frontend refresh-time (1.5 - 5 seconds) *) beta-only option"
|
| 15 |
-
}
|
| 16 |
-
}
|
| 17 |
-
}
|
| 18 |
-
},
|
| 19 |
"config": {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
"step": {
|
| 21 |
"reconfigure": {
|
| 22 |
-
"description": "Update configuration for {title}.",
|
| 23 |
"data": {
|
| 24 |
-
"host": "
|
| 25 |
-
"port": "
|
| 26 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
},
|
| 28 |
"user": {
|
| 29 |
-
"title": "Set up Plugwise Adam/Smile/Stretch",
|
| 30 |
-
"description": "Enter your Plugwise device: (setup can take up to 90s)",
|
| 31 |
"data": {
|
| 32 |
-
"
|
| 33 |
-
"
|
| 34 |
-
"
|
| 35 |
-
"
|
| 36 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
}
|
| 38 |
-
},
|
| 39 |
-
"error": {
|
| 40 |
-
"cannot_connect": "Failed to connect",
|
| 41 |
-
"invalid_auth": "Authentication failed",
|
| 42 |
-
"invalid_setup": "Add your Adam instead of your Anna, see the documentation",
|
| 43 |
-
"network_down": "Plugwise Zigbee network is down",
|
| 44 |
-
"network_timeout": "Network communication timeout",
|
| 45 |
-
"response_error": "Invalid XML data, or error indication received",
|
| 46 |
-
"stick_init": "Initialization of Plugwise USB-stick failed",
|
| 47 |
-
"unknown": "Unknown error!",
|
| 48 |
-
"unsupported": "Device with unsupported firmware"
|
| 49 |
-
},
|
| 50 |
-
"abort": {
|
| 51 |
-
"already_configured": "This device is already configured",
|
| 52 |
-
"anna_with_adam": "Both Anna and Adam detected. Add your Adam instead of your Anna",
|
| 53 |
-
"not_the_same_smile": "The configured Smile ID does not match the Smile ID on the requested IP address.",
|
| 54 |
-
"reconfigure_successful": "Reconfiguration successful"
|
| 55 |
}
|
| 56 |
},
|
| 57 |
"entity": {
|
|
@@ -62,6 +52,9 @@
|
|
| 62 |
"cooling_enabled": {
|
| 63 |
"name": "Cooling enabled"
|
| 64 |
},
|
|
|
|
|
|
|
|
|
|
| 65 |
"dhw_state": {
|
| 66 |
"name": "DHW state"
|
| 67 |
},
|
|
@@ -69,16 +62,13 @@
|
|
| 69 |
"name": "Flame state"
|
| 70 |
},
|
| 71 |
"heating_state": {
|
| 72 |
-
"name": "
|
| 73 |
},
|
| 74 |
-
"
|
| 75 |
-
"name": "
|
| 76 |
},
|
| 77 |
"secondary_boiler_state": {
|
| 78 |
"name": "Secondary boiler state"
|
| 79 |
-
},
|
| 80 |
-
"plugwise_notification": {
|
| 81 |
-
"name": "Plugwise notification"
|
| 82 |
}
|
| 83 |
},
|
| 84 |
"button": {
|
|
@@ -89,25 +79,31 @@
|
|
| 89 |
"climate": {
|
| 90 |
"plugwise": {
|
| 91 |
"state_attributes": {
|
|
|
|
|
|
|
|
|
|
| 92 |
"preset_mode": {
|
| 93 |
"state": {
|
| 94 |
"asleep": "Night",
|
| 95 |
-
"away": "
|
| 96 |
-
"home": "
|
| 97 |
"no_frost": "Anti-frost",
|
| 98 |
"vacation": "Vacation"
|
| 99 |
}
|
|
|
|
|
|
|
|
|
|
| 100 |
}
|
| 101 |
}
|
| 102 |
}
|
| 103 |
},
|
| 104 |
"number": {
|
| 105 |
-
"maximum_boiler_temperature": {
|
| 106 |
-
"name": "Maximum boiler temperature setpoint"
|
| 107 |
-
},
|
| 108 |
"max_dhw_temperature": {
|
| 109 |
"name": "Domestic hot water setpoint"
|
| 110 |
},
|
|
|
|
|
|
|
|
|
|
| 111 |
"temperature_offset": {
|
| 112 |
"name": "Temperature offset"
|
| 113 |
}
|
|
@@ -116,194 +112,194 @@
|
|
| 116 |
"select_dhw_mode": {
|
| 117 |
"name": "DHW mode",
|
| 118 |
"state": {
|
| 119 |
-
"auto": "
|
| 120 |
-
"boost": "
|
| 121 |
-
"comfort": "
|
| 122 |
-
"off": "
|
| 123 |
-
}
|
| 124 |
-
},
|
| 125 |
-
"select_regulation_mode": {
|
| 126 |
-
"name": "Regulation mode",
|
| 127 |
-
"state": {
|
| 128 |
-
"bleeding_cold": "Bleeding cold",
|
| 129 |
-
"bleeding_hot": "Bleeding hot",
|
| 130 |
-
"cooling": "Cooling",
|
| 131 |
-
"heating": "Heating",
|
| 132 |
-
"off": "Off"
|
| 133 |
}
|
| 134 |
},
|
| 135 |
"select_gateway_mode": {
|
| 136 |
"name": "Gateway mode",
|
| 137 |
"state": {
|
| 138 |
"away": "Pause",
|
| 139 |
-
"full": "
|
| 140 |
"vacation": "Vacation"
|
| 141 |
}
|
| 142 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
"select_schedule": {
|
| 144 |
"name": "Thermostat schedule",
|
| 145 |
"state": {
|
| 146 |
-
"off": "
|
| 147 |
}
|
| 148 |
},
|
| 149 |
"select_zone_profile": {
|
| 150 |
"name": "Zone profile",
|
| 151 |
"state": {
|
| 152 |
-
"active": "
|
| 153 |
-
"off": "
|
| 154 |
"passive": "Passive"
|
| 155 |
}
|
| 156 |
}
|
| 157 |
},
|
| 158 |
"sensor": {
|
| 159 |
-
"setpoint": {
|
| 160 |
-
"name": "Setpoint"
|
| 161 |
-
},
|
| 162 |
"cooling_setpoint": {
|
| 163 |
"name": "Cooling setpoint"
|
| 164 |
},
|
| 165 |
-
"
|
| 166 |
-
"name": "
|
| 167 |
-
},
|
| 168 |
-
"intended_boiler_temperature": {
|
| 169 |
-
"name": "Intended boiler temperature"
|
| 170 |
-
},
|
| 171 |
-
"temperature_difference": {
|
| 172 |
-
"name": "Temperature difference"
|
| 173 |
-
},
|
| 174 |
-
"outdoor_temperature": {
|
| 175 |
-
"name": "Outdoor temperature"
|
| 176 |
-
},
|
| 177 |
-
"outdoor_air_temperature": {
|
| 178 |
-
"name": "Outdoor air temperature"
|
| 179 |
-
},
|
| 180 |
-
"water_temperature": {
|
| 181 |
-
"name": "Water temperature"
|
| 182 |
},
|
| 183 |
-
"
|
| 184 |
-
"name": "
|
| 185 |
},
|
| 186 |
"electricity_consumed": {
|
| 187 |
"name": "Electricity consumed"
|
| 188 |
},
|
| 189 |
-
"electricity_produced": {
|
| 190 |
-
"name": "Electricity produced"
|
| 191 |
-
},
|
| 192 |
-
"electricity_consumed_point": {
|
| 193 |
-
"name": "Electricity consumed point"
|
| 194 |
-
},
|
| 195 |
-
"electricity_produced_point": {
|
| 196 |
-
"name": "Electricity produced point"
|
| 197 |
-
},
|
| 198 |
"electricity_consumed_interval": {
|
| 199 |
"name": "Electricity consumed interval"
|
| 200 |
},
|
| 201 |
-
"
|
| 202 |
-
"name": "Electricity consumed peak
|
| 203 |
},
|
| 204 |
"electricity_consumed_off_peak_interval": {
|
| 205 |
"name": "Electricity consumed off-peak interval"
|
| 206 |
},
|
| 207 |
-
"electricity_produced_interval": {
|
| 208 |
-
"name": "Electricity produced interval"
|
| 209 |
-
},
|
| 210 |
-
"electricity_produced_peak_interval": {
|
| 211 |
-
"name": "Electricity produced peak interval"
|
| 212 |
-
},
|
| 213 |
-
"electricity_produced_off_peak_interval": {
|
| 214 |
-
"name": "Electricity produced off-peak interval"
|
| 215 |
-
},
|
| 216 |
"electricity_consumed_off_peak_point": {
|
| 217 |
"name": "Electricity consumed off-peak point"
|
| 218 |
},
|
| 219 |
-
"electricity_consumed_peak_point": {
|
| 220 |
-
"name": "Electricity consumed peak point"
|
| 221 |
-
},
|
| 222 |
-
"electricity_consumed_off_peak_cumulative": {
|
| 223 |
-
"name": "Electricity consumed off-peak cumulative"
|
| 224 |
-
},
|
| 225 |
"electricity_consumed_peak_cumulative": {
|
| 226 |
"name": "Electricity consumed peak cumulative"
|
| 227 |
},
|
| 228 |
-
"
|
| 229 |
-
"name": "Electricity
|
| 230 |
-
},
|
| 231 |
-
"electricity_produced_peak_point": {
|
| 232 |
-
"name": "Electricity produced peak point"
|
| 233 |
},
|
| 234 |
-
"
|
| 235 |
-
"name": "Electricity
|
| 236 |
},
|
| 237 |
-
"
|
| 238 |
-
"name": "Electricity
|
| 239 |
},
|
| 240 |
"electricity_phase_one_consumed": {
|
| 241 |
"name": "Electricity phase one consumed"
|
| 242 |
},
|
| 243 |
-
"
|
| 244 |
-
"name": "Electricity phase
|
| 245 |
},
|
| 246 |
"electricity_phase_three_consumed": {
|
| 247 |
"name": "Electricity phase three consumed"
|
| 248 |
},
|
| 249 |
-
"
|
| 250 |
-
"name": "Electricity phase
|
|
|
|
|
|
|
|
|
|
| 251 |
},
|
| 252 |
"electricity_phase_two_produced": {
|
| 253 |
"name": "Electricity phase two produced"
|
| 254 |
},
|
| 255 |
-
"
|
| 256 |
-
"name": "Electricity
|
| 257 |
},
|
| 258 |
-
"
|
| 259 |
-
"name": "
|
| 260 |
},
|
| 261 |
-
"
|
| 262 |
-
"name": "
|
| 263 |
},
|
| 264 |
-
"
|
| 265 |
-
"name": "
|
| 266 |
},
|
| 267 |
-
"
|
| 268 |
-
"name": "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
},
|
| 270 |
"gas_consumed_cumulative": {
|
| 271 |
"name": "Gas consumed cumulative"
|
| 272 |
},
|
| 273 |
-
"
|
| 274 |
-
"name": "
|
| 275 |
},
|
| 276 |
-
"
|
| 277 |
-
"name": "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
},
|
| 279 |
"modulation_level": {
|
| 280 |
"name": "Modulation level"
|
| 281 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
"valve_position": {
|
| 283 |
"name": "Valve position"
|
| 284 |
},
|
| 285 |
-
"
|
| 286 |
-
"name": "
|
| 287 |
},
|
| 288 |
-
"
|
| 289 |
-
"name": "
|
| 290 |
},
|
| 291 |
-
"
|
| 292 |
-
"name": "
|
| 293 |
},
|
| 294 |
-
"
|
| 295 |
-
"name": "
|
|
|
|
|
|
|
|
|
|
| 296 |
}
|
| 297 |
},
|
| 298 |
"switch": {
|
| 299 |
"cooling_ena_switch": {
|
| 300 |
-
"name": "
|
| 301 |
},
|
| 302 |
"dhw_cm_switch": {
|
| 303 |
"name": "DHW comfort mode"
|
| 304 |
},
|
| 305 |
"lock": {
|
| 306 |
-
"name": "
|
| 307 |
},
|
| 308 |
"relay": {
|
| 309 |
"name": "Relay"
|
|
@@ -312,7 +308,7 @@
|
|
| 312 |
},
|
| 313 |
"exceptions": {
|
| 314 |
"authentication_failed": {
|
| 315 |
-
"message": "
|
| 316 |
},
|
| 317 |
"data_incomplete_or_missing": {
|
| 318 |
"message": "Data incomplete or missing."
|
|
@@ -321,22 +317,16 @@
|
|
| 321 |
"message": "Error communicating with API: {error}."
|
| 322 |
},
|
| 323 |
"failed_to_connect": {
|
| 324 |
-
"message": "
|
| 325 |
},
|
| 326 |
"invalid_xml_data": {
|
| 327 |
-
"message": "
|
| 328 |
},
|
| 329 |
"set_schedule_first": {
|
| 330 |
"message": "Failed setting HVACMode, set a schedule first."
|
| 331 |
},
|
| 332 |
"unsupported_firmware": {
|
| 333 |
-
"message": "
|
| 334 |
-
}
|
| 335 |
-
},
|
| 336 |
-
"services": {
|
| 337 |
-
"delete_notification": {
|
| 338 |
-
"name": "Delete Plugwise notification",
|
| 339 |
-
"description": "Deletes a Plugwise Notification"
|
| 340 |
}
|
| 341 |
}
|
| 342 |
}
|
|
|
|
| 1 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
"config": {
|
| 3 |
+
"abort": {
|
| 4 |
+
"already_configured": "[%key:common::config_flow::abort::already_configured_service%]",
|
| 5 |
+
"anna_with_adam": "Both Anna and Adam detected. Add your Adam instead of your Anna",
|
| 6 |
+
"not_the_same_smile": "The configured Smile ID does not match the Smile ID on the requested IP address.",
|
| 7 |
+
"reconfigure_successful": "[%key:common::config_flow::abort::reconfigure_successful%]"
|
| 8 |
+
},
|
| 9 |
+
"error": {
|
| 10 |
+
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
| 11 |
+
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
| 12 |
+
"invalid_setup": "Add your Adam instead of your Anna, see the documentation",
|
| 13 |
+
"response_error": "Invalid XML data, or error indication received",
|
| 14 |
+
"unknown": "[%key:common::config_flow::error::unknown%]",
|
| 15 |
+
"unsupported": "Device with unsupported firmware"
|
| 16 |
+
},
|
| 17 |
"step": {
|
| 18 |
"reconfigure": {
|
|
|
|
| 19 |
"data": {
|
| 20 |
+
"host": "[%key:common::config_flow::data::ip%]",
|
| 21 |
+
"port": "[%key:common::config_flow::data::port%]"
|
| 22 |
+
},
|
| 23 |
+
"data_description": {
|
| 24 |
+
"host": "[%key:component::plugwise::config::step::user::data_description::host%]",
|
| 25 |
+
"port": "[%key:component::plugwise::config::step::user::data_description::port%]"
|
| 26 |
+
},
|
| 27 |
+
"description": "Update configuration for {title}."
|
| 28 |
},
|
| 29 |
"user": {
|
|
|
|
|
|
|
| 30 |
"data": {
|
| 31 |
+
"host": "[%key:common::config_flow::data::ip%]",
|
| 32 |
+
"password": "Smile ID",
|
| 33 |
+
"port": "[%key:common::config_flow::data::port%]",
|
| 34 |
+
"username": "Smile username"
|
| 35 |
+
},
|
| 36 |
+
"data_description": {
|
| 37 |
+
"host": "The hostname or IP address of your Smile. You can find it in your router or the Plugwise app.",
|
| 38 |
+
"password": "The Smile ID printed on the label on the back of your Adam, Smile-T, or P1.",
|
| 39 |
+
"port": "By default your Smile uses port 80, normally you should not have to change this.",
|
| 40 |
+
"username": "Default is `smile`, or `stretch` for the legacy Stretch."
|
| 41 |
+
},
|
| 42 |
+
"description": "Please enter",
|
| 43 |
+
"title": "Connect to the Smile"
|
| 44 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
}
|
| 46 |
},
|
| 47 |
"entity": {
|
|
|
|
| 52 |
"cooling_enabled": {
|
| 53 |
"name": "Cooling enabled"
|
| 54 |
},
|
| 55 |
+
"cooling_state": {
|
| 56 |
+
"name": "[%key:component::climate::entity_component::_::state_attributes::hvac_action::state::cooling%]"
|
| 57 |
+
},
|
| 58 |
"dhw_state": {
|
| 59 |
"name": "DHW state"
|
| 60 |
},
|
|
|
|
| 62 |
"name": "Flame state"
|
| 63 |
},
|
| 64 |
"heating_state": {
|
| 65 |
+
"name": "[%key:component::climate::entity_component::_::state_attributes::hvac_action::state::heating%]"
|
| 66 |
},
|
| 67 |
+
"plugwise_notification": {
|
| 68 |
+
"name": "Plugwise notification"
|
| 69 |
},
|
| 70 |
"secondary_boiler_state": {
|
| 71 |
"name": "Secondary boiler state"
|
|
|
|
|
|
|
|
|
|
| 72 |
}
|
| 73 |
},
|
| 74 |
"button": {
|
|
|
|
| 79 |
"climate": {
|
| 80 |
"plugwise": {
|
| 81 |
"state_attributes": {
|
| 82 |
+
"available_schemas": {
|
| 83 |
+
"name": "Available schemas"
|
| 84 |
+
},
|
| 85 |
"preset_mode": {
|
| 86 |
"state": {
|
| 87 |
"asleep": "Night",
|
| 88 |
+
"away": "[%key:common::state::not_home%]",
|
| 89 |
+
"home": "[%key:common::state::home%]",
|
| 90 |
"no_frost": "Anti-frost",
|
| 91 |
"vacation": "Vacation"
|
| 92 |
}
|
| 93 |
+
},
|
| 94 |
+
"selected_schema": {
|
| 95 |
+
"name": "Selected schema"
|
| 96 |
}
|
| 97 |
}
|
| 98 |
}
|
| 99 |
},
|
| 100 |
"number": {
|
|
|
|
|
|
|
|
|
|
| 101 |
"max_dhw_temperature": {
|
| 102 |
"name": "Domestic hot water setpoint"
|
| 103 |
},
|
| 104 |
+
"maximum_boiler_temperature": {
|
| 105 |
+
"name": "Maximum boiler temperature setpoint"
|
| 106 |
+
},
|
| 107 |
"temperature_offset": {
|
| 108 |
"name": "Temperature offset"
|
| 109 |
}
|
|
|
|
| 112 |
"select_dhw_mode": {
|
| 113 |
"name": "DHW mode",
|
| 114 |
"state": {
|
| 115 |
+
"auto": "[%key:common::state::auto%]",
|
| 116 |
+
"boost": "[%key:component::climate::entity_component::_::state_attributes::preset_mode::state::boost%]",
|
| 117 |
+
"comfort": "[%key:component::climate::entity_component::_::state_attributes::preset_mode::state::comfort%]",
|
| 118 |
+
"off": "[%key:common::state::off%]"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
}
|
| 120 |
},
|
| 121 |
"select_gateway_mode": {
|
| 122 |
"name": "Gateway mode",
|
| 123 |
"state": {
|
| 124 |
"away": "Pause",
|
| 125 |
+
"full": "[%key:common::state::normal%]",
|
| 126 |
"vacation": "Vacation"
|
| 127 |
}
|
| 128 |
},
|
| 129 |
+
"select_regulation_mode": {
|
| 130 |
+
"name": "Regulation mode",
|
| 131 |
+
"state": {
|
| 132 |
+
"bleeding_cold": "Bleeding cold",
|
| 133 |
+
"bleeding_hot": "Bleeding hot",
|
| 134 |
+
"cooling": "[%key:component::climate::entity_component::_::state_attributes::hvac_action::state::cooling%]",
|
| 135 |
+
"heating": "[%key:component::climate::entity_component::_::state_attributes::hvac_action::state::heating%]",
|
| 136 |
+
"off": "[%key:common::state::off%]"
|
| 137 |
+
}
|
| 138 |
+
},
|
| 139 |
"select_schedule": {
|
| 140 |
"name": "Thermostat schedule",
|
| 141 |
"state": {
|
| 142 |
+
"off": "[%key:common::state::off%]"
|
| 143 |
}
|
| 144 |
},
|
| 145 |
"select_zone_profile": {
|
| 146 |
"name": "Zone profile",
|
| 147 |
"state": {
|
| 148 |
+
"active": "[%key:common::state::active%]",
|
| 149 |
+
"off": "[%key:common::state::off%]",
|
| 150 |
"passive": "Passive"
|
| 151 |
}
|
| 152 |
}
|
| 153 |
},
|
| 154 |
"sensor": {
|
|
|
|
|
|
|
|
|
|
| 155 |
"cooling_setpoint": {
|
| 156 |
"name": "Cooling setpoint"
|
| 157 |
},
|
| 158 |
+
"dhw_temperature": {
|
| 159 |
+
"name": "DHW temperature"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
},
|
| 161 |
+
"domestic_hot_water_setpoint": {
|
| 162 |
+
"name": "DHW setpoint"
|
| 163 |
},
|
| 164 |
"electricity_consumed": {
|
| 165 |
"name": "Electricity consumed"
|
| 166 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
"electricity_consumed_interval": {
|
| 168 |
"name": "Electricity consumed interval"
|
| 169 |
},
|
| 170 |
+
"electricity_consumed_off_peak_cumulative": {
|
| 171 |
+
"name": "Electricity consumed off-peak cumulative"
|
| 172 |
},
|
| 173 |
"electricity_consumed_off_peak_interval": {
|
| 174 |
"name": "Electricity consumed off-peak interval"
|
| 175 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
"electricity_consumed_off_peak_point": {
|
| 177 |
"name": "Electricity consumed off-peak point"
|
| 178 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
"electricity_consumed_peak_cumulative": {
|
| 180 |
"name": "Electricity consumed peak cumulative"
|
| 181 |
},
|
| 182 |
+
"electricity_consumed_peak_interval": {
|
| 183 |
+
"name": "Electricity consumed peak interval"
|
|
|
|
|
|
|
|
|
|
| 184 |
},
|
| 185 |
+
"electricity_consumed_peak_point": {
|
| 186 |
+
"name": "Electricity consumed peak point"
|
| 187 |
},
|
| 188 |
+
"electricity_consumed_point": {
|
| 189 |
+
"name": "Electricity consumed point"
|
| 190 |
},
|
| 191 |
"electricity_phase_one_consumed": {
|
| 192 |
"name": "Electricity phase one consumed"
|
| 193 |
},
|
| 194 |
+
"electricity_phase_one_produced": {
|
| 195 |
+
"name": "Electricity phase one produced"
|
| 196 |
},
|
| 197 |
"electricity_phase_three_consumed": {
|
| 198 |
"name": "Electricity phase three consumed"
|
| 199 |
},
|
| 200 |
+
"electricity_phase_three_produced": {
|
| 201 |
+
"name": "Electricity phase three produced"
|
| 202 |
+
},
|
| 203 |
+
"electricity_phase_two_consumed": {
|
| 204 |
+
"name": "Electricity phase two consumed"
|
| 205 |
},
|
| 206 |
"electricity_phase_two_produced": {
|
| 207 |
"name": "Electricity phase two produced"
|
| 208 |
},
|
| 209 |
+
"electricity_produced": {
|
| 210 |
+
"name": "Electricity produced"
|
| 211 |
},
|
| 212 |
+
"electricity_produced_interval": {
|
| 213 |
+
"name": "Electricity produced interval"
|
| 214 |
},
|
| 215 |
+
"electricity_produced_off_peak_cumulative": {
|
| 216 |
+
"name": "Electricity produced off-peak cumulative"
|
| 217 |
},
|
| 218 |
+
"electricity_produced_off_peak_interval": {
|
| 219 |
+
"name": "Electricity produced off-peak interval"
|
| 220 |
},
|
| 221 |
+
"electricity_produced_off_peak_point": {
|
| 222 |
+
"name": "Electricity produced off-peak point"
|
| 223 |
+
},
|
| 224 |
+
"electricity_produced_peak_cumulative": {
|
| 225 |
+
"name": "Electricity produced peak cumulative"
|
| 226 |
+
},
|
| 227 |
+
"electricity_produced_peak_interval": {
|
| 228 |
+
"name": "Electricity produced peak interval"
|
| 229 |
+
},
|
| 230 |
+
"electricity_produced_peak_point": {
|
| 231 |
+
"name": "Electricity produced peak point"
|
| 232 |
+
},
|
| 233 |
+
"electricity_produced_point": {
|
| 234 |
+
"name": "Electricity produced point"
|
| 235 |
},
|
| 236 |
"gas_consumed_cumulative": {
|
| 237 |
"name": "Gas consumed cumulative"
|
| 238 |
},
|
| 239 |
+
"gas_consumed_interval": {
|
| 240 |
+
"name": "Gas consumed interval"
|
| 241 |
},
|
| 242 |
+
"heating_setpoint": {
|
| 243 |
+
"name": "Heating setpoint"
|
| 244 |
+
},
|
| 245 |
+
"intended_boiler_temperature": {
|
| 246 |
+
"name": "Intended boiler temperature"
|
| 247 |
+
},
|
| 248 |
+
"maximum_boiler_temperature": {
|
| 249 |
+
"name": "Maximum boiler temperature"
|
| 250 |
},
|
| 251 |
"modulation_level": {
|
| 252 |
"name": "Modulation level"
|
| 253 |
},
|
| 254 |
+
"net_electricity_cumulative": {
|
| 255 |
+
"name": "Net electricity cumulative"
|
| 256 |
+
},
|
| 257 |
+
"net_electricity_point": {
|
| 258 |
+
"name": "Net electricity point"
|
| 259 |
+
},
|
| 260 |
+
"outdoor_air_temperature": {
|
| 261 |
+
"name": "Outdoor air temperature"
|
| 262 |
+
},
|
| 263 |
+
"outdoor_temperature": {
|
| 264 |
+
"name": "Outdoor temperature"
|
| 265 |
+
},
|
| 266 |
+
"return_temperature": {
|
| 267 |
+
"name": "Return temperature"
|
| 268 |
+
},
|
| 269 |
+
"setpoint": {
|
| 270 |
+
"name": "Setpoint"
|
| 271 |
+
},
|
| 272 |
+
"temperature_difference": {
|
| 273 |
+
"name": "Temperature difference"
|
| 274 |
+
},
|
| 275 |
"valve_position": {
|
| 276 |
"name": "Valve position"
|
| 277 |
},
|
| 278 |
+
"voltage_phase_one": {
|
| 279 |
+
"name": "Voltage phase one"
|
| 280 |
},
|
| 281 |
+
"voltage_phase_three": {
|
| 282 |
+
"name": "Voltage phase three"
|
| 283 |
},
|
| 284 |
+
"voltage_phase_two": {
|
| 285 |
+
"name": "Voltage phase two"
|
| 286 |
},
|
| 287 |
+
"water_pressure": {
|
| 288 |
+
"name": "Water pressure"
|
| 289 |
+
},
|
| 290 |
+
"water_temperature": {
|
| 291 |
+
"name": "Water temperature"
|
| 292 |
}
|
| 293 |
},
|
| 294 |
"switch": {
|
| 295 |
"cooling_ena_switch": {
|
| 296 |
+
"name": "[%key:component::climate::entity_component::_::state_attributes::hvac_action::state::cooling%]"
|
| 297 |
},
|
| 298 |
"dhw_cm_switch": {
|
| 299 |
"name": "DHW comfort mode"
|
| 300 |
},
|
| 301 |
"lock": {
|
| 302 |
+
"name": "[%key:component::lock::title%]"
|
| 303 |
},
|
| 304 |
"relay": {
|
| 305 |
"name": "Relay"
|
|
|
|
| 308 |
},
|
| 309 |
"exceptions": {
|
| 310 |
"authentication_failed": {
|
| 311 |
+
"message": "[%key:common::config_flow::error::invalid_auth%]"
|
| 312 |
},
|
| 313 |
"data_incomplete_or_missing": {
|
| 314 |
"message": "Data incomplete or missing."
|
|
|
|
| 317 |
"message": "Error communicating with API: {error}."
|
| 318 |
},
|
| 319 |
"failed_to_connect": {
|
| 320 |
+
"message": "[%key:common::config_flow::error::cannot_connect%]"
|
| 321 |
},
|
| 322 |
"invalid_xml_data": {
|
| 323 |
+
"message": "[%key:component::plugwise::config::error::response_error%]"
|
| 324 |
},
|
| 325 |
"set_schedule_first": {
|
| 326 |
"message": "Failed setting HVACMode, set a schedule first."
|
| 327 |
},
|
| 328 |
"unsupported_firmware": {
|
| 329 |
+
"message": "[%key:component::plugwise::config::error::unsupported%]"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
}
|
| 331 |
}
|
| 332 |
}
|
|
@@ -16,17 +16,6 @@
|
|
| 16 |
from homeassistant.core import HomeAssistant, callback
|
| 17 |
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
| 18 |
|
| 19 |
-
from .const import (
|
| 20 |
-
COOLING_ENA_SWITCH,
|
| 21 |
-
DHW_CM_SWITCH,
|
| 22 |
-
LOCK,
|
| 23 |
-
LOGGER, # pw-beta
|
| 24 |
-
MEMBERS,
|
| 25 |
-
RELAY,
|
| 26 |
-
SWITCHES,
|
| 27 |
-
)
|
| 28 |
-
|
| 29 |
-
# Upstream consts
|
| 30 |
from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator
|
| 31 |
from .entity import PlugwiseEntity
|
| 32 |
from .util import plugwise_command
|
|
@@ -41,29 +30,25 @@
|
|
| 41 |
key: SwitchType
|
| 42 |
|
| 43 |
|
| 44 |
-
|
| 45 |
-
PLUGWISE_SWITCHES: tuple[PlugwiseSwitchEntityDescription, ...] = (
|
| 46 |
PlugwiseSwitchEntityDescription(
|
| 47 |
-
key=
|
| 48 |
-
translation_key=
|
| 49 |
-
device_class=SwitchDeviceClass.SWITCH,
|
| 50 |
entity_category=EntityCategory.CONFIG,
|
| 51 |
),
|
| 52 |
PlugwiseSwitchEntityDescription(
|
| 53 |
-
key=
|
| 54 |
-
translation_key=
|
| 55 |
-
device_class=SwitchDeviceClass.SWITCH,
|
| 56 |
entity_category=EntityCategory.CONFIG,
|
| 57 |
),
|
| 58 |
PlugwiseSwitchEntityDescription(
|
| 59 |
-
key=
|
| 60 |
-
translation_key=
|
| 61 |
device_class=SwitchDeviceClass.SWITCH,
|
| 62 |
),
|
| 63 |
PlugwiseSwitchEntityDescription(
|
| 64 |
-
key=
|
| 65 |
-
translation_key=
|
| 66 |
-
device_class=SwitchDeviceClass.SWITCH,
|
| 67 |
entity_category=EntityCategory.CONFIG,
|
| 68 |
),
|
| 69 |
)
|
|
@@ -74,7 +59,7 @@
|
|
| 74 |
entry: PlugwiseConfigEntry,
|
| 75 |
async_add_entities: AddConfigEntryEntitiesCallback,
|
| 76 |
) -> None:
|
| 77 |
-
"""Set up
|
| 78 |
coordinator = entry.runtime_data
|
| 79 |
|
| 80 |
@callback
|
|
@@ -83,28 +68,13 @@
|
|
| 83 |
if not coordinator.new_devices:
|
| 84 |
return
|
| 85 |
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
# )
|
| 94 |
-
# pw-beta alternative for debugging
|
| 95 |
-
entities: list[PlugwiseSwitchEntity] = []
|
| 96 |
-
for device_id in coordinator.new_devices:
|
| 97 |
-
device = coordinator.data[device_id]
|
| 98 |
-
if not (switches := device.get(SWITCHES)):
|
| 99 |
-
continue
|
| 100 |
-
for description in PLUGWISE_SWITCHES:
|
| 101 |
-
if description.key not in switches:
|
| 102 |
-
continue
|
| 103 |
-
entities.append(PlugwiseSwitchEntity(coordinator, device_id, description))
|
| 104 |
-
LOGGER.debug(
|
| 105 |
-
"Add %s %s switch", device["name"], description.translation_key
|
| 106 |
-
)
|
| 107 |
-
async_add_entities(entities)
|
| 108 |
|
| 109 |
_add_entities()
|
| 110 |
entry.async_on_unload(coordinator.async_add_listener(_add_entities))
|
|
@@ -123,30 +93,30 @@
|
|
| 123 |
) -> None:
|
| 124 |
"""Set up the Plugwise API."""
|
| 125 |
super().__init__(coordinator, device_id)
|
| 126 |
-
self.entity_description = description
|
| 127 |
self._attr_unique_id = f"{device_id}-{description.key}"
|
|
|
|
| 128 |
|
| 129 |
@property
|
| 130 |
-
def is_on(self) -> bool
|
| 131 |
"""Return True if entity is on."""
|
| 132 |
-
return self.device
|
| 133 |
|
| 134 |
@plugwise_command
|
| 135 |
async def async_turn_on(self, **kwargs: Any) -> None:
|
| 136 |
"""Turn the device on."""
|
| 137 |
await self.coordinator.api.set_switch_state(
|
| 138 |
self._dev_id,
|
| 139 |
-
self.device.get(
|
| 140 |
self.entity_description.key,
|
| 141 |
"on",
|
| 142 |
-
)
|
| 143 |
|
| 144 |
@plugwise_command
|
| 145 |
async def async_turn_off(self, **kwargs: Any) -> None:
|
| 146 |
"""Turn the device off."""
|
| 147 |
await self.coordinator.api.set_switch_state(
|
| 148 |
self._dev_id,
|
| 149 |
-
self.device.get(
|
| 150 |
self.entity_description.key,
|
| 151 |
"off",
|
| 152 |
-
)
|
|
|
|
| 16 |
from homeassistant.core import HomeAssistant, callback
|
| 17 |
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
from .coordinator import PlugwiseConfigEntry, PlugwiseDataUpdateCoordinator
|
| 20 |
from .entity import PlugwiseEntity
|
| 21 |
from .util import plugwise_command
|
|
|
|
| 30 |
key: SwitchType
|
| 31 |
|
| 32 |
|
| 33 |
+
SWITCHES: tuple[PlugwiseSwitchEntityDescription, ...] = (
|
|
|
|
| 34 |
PlugwiseSwitchEntityDescription(
|
| 35 |
+
key="dhw_cm_switch",
|
| 36 |
+
translation_key="dhw_cm_switch",
|
|
|
|
| 37 |
entity_category=EntityCategory.CONFIG,
|
| 38 |
),
|
| 39 |
PlugwiseSwitchEntityDescription(
|
| 40 |
+
key="lock",
|
| 41 |
+
translation_key="lock",
|
|
|
|
| 42 |
entity_category=EntityCategory.CONFIG,
|
| 43 |
),
|
| 44 |
PlugwiseSwitchEntityDescription(
|
| 45 |
+
key="relay",
|
| 46 |
+
translation_key="relay",
|
| 47 |
device_class=SwitchDeviceClass.SWITCH,
|
| 48 |
),
|
| 49 |
PlugwiseSwitchEntityDescription(
|
| 50 |
+
key="cooling_ena_switch",
|
| 51 |
+
translation_key="cooling_ena_switch",
|
|
|
|
| 52 |
entity_category=EntityCategory.CONFIG,
|
| 53 |
),
|
| 54 |
)
|
|
|
|
| 59 |
entry: PlugwiseConfigEntry,
|
| 60 |
async_add_entities: AddConfigEntryEntitiesCallback,
|
| 61 |
) -> None:
|
| 62 |
+
"""Set up the Smile switches from a config entry."""
|
| 63 |
coordinator = entry.runtime_data
|
| 64 |
|
| 65 |
@callback
|
|
|
|
| 68 |
if not coordinator.new_devices:
|
| 69 |
return
|
| 70 |
|
| 71 |
+
async_add_entities(
|
| 72 |
+
PlugwiseSwitchEntity(coordinator, device_id, description)
|
| 73 |
+
for device_id in coordinator.new_devices
|
| 74 |
+
if (switches := coordinator.data[device_id].get("switches"))
|
| 75 |
+
for description in SWITCHES
|
| 76 |
+
if description.key in switches
|
| 77 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
_add_entities()
|
| 80 |
entry.async_on_unload(coordinator.async_add_listener(_add_entities))
|
|
|
|
| 93 |
) -> None:
|
| 94 |
"""Set up the Plugwise API."""
|
| 95 |
super().__init__(coordinator, device_id)
|
|
|
|
| 96 |
self._attr_unique_id = f"{device_id}-{description.key}"
|
| 97 |
+
self.entity_description = description
|
| 98 |
|
| 99 |
@property
|
| 100 |
+
def is_on(self) -> bool:
|
| 101 |
"""Return True if entity is on."""
|
| 102 |
+
return self.device["switches"][self.entity_description.key]
|
| 103 |
|
| 104 |
@plugwise_command
|
| 105 |
async def async_turn_on(self, **kwargs: Any) -> None:
|
| 106 |
"""Turn the device on."""
|
| 107 |
await self.coordinator.api.set_switch_state(
|
| 108 |
self._dev_id,
|
| 109 |
+
self.device.get("members"),
|
| 110 |
self.entity_description.key,
|
| 111 |
"on",
|
| 112 |
+
)
|
| 113 |
|
| 114 |
@plugwise_command
|
| 115 |
async def async_turn_off(self, **kwargs: Any) -> None:
|
| 116 |
"""Turn the device off."""
|
| 117 |
await self.coordinator.api.set_switch_state(
|
| 118 |
self._dev_id,
|
| 119 |
+
self.device.get("members"),
|
| 120 |
self.entity_description.key,
|
| 121 |
"off",
|
| 122 |
+
)
|
|
@@ -1,7 +1,5 @@
|
|
| 1 |
"""Utilities for Plugwise."""
|
| 2 |
|
| 3 |
-
from __future__ import annotations
|
| 4 |
-
|
| 5 |
from collections.abc import Awaitable, Callable, Coroutine
|
| 6 |
from typing import Any, Concatenate
|
| 7 |
|
|
@@ -12,15 +10,10 @@
|
|
| 12 |
from .const import DOMAIN
|
| 13 |
from .entity import PlugwiseEntity
|
| 14 |
|
| 15 |
-
# For reference:
|
| 16 |
-
# PlugwiseEntityT = TypeVar("PlugwiseEntityT", bound=PlugwiseEntity)
|
| 17 |
-
# R = TypeVar("_R")
|
| 18 |
-
# P = ParamSpec("_P")
|
| 19 |
-
|
| 20 |
|
| 21 |
-
def plugwise_command[
|
| 22 |
-
func: Callable[Concatenate[
|
| 23 |
-
) -> Callable[Concatenate[
|
| 24 |
"""Decorate Plugwise calls that send commands/make changes to the device.
|
| 25 |
|
| 26 |
A decorator that wraps the passed in function, catches Plugwise errors,
|
|
@@ -28,8 +21,8 @@
|
|
| 28 |
"""
|
| 29 |
|
| 30 |
async def handler(
|
| 31 |
-
self:
|
| 32 |
-
) ->
|
| 33 |
try:
|
| 34 |
return await func(self, *args, **kwargs)
|
| 35 |
except PlugwiseException as err:
|
|
|
|
| 1 |
"""Utilities for Plugwise."""
|
| 2 |
|
|
|
|
|
|
|
| 3 |
from collections.abc import Awaitable, Callable, Coroutine
|
| 4 |
from typing import Any, Concatenate
|
| 5 |
|
|
|
|
| 10 |
from .const import DOMAIN
|
| 11 |
from .entity import PlugwiseEntity
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
def plugwise_command[_PlugwiseEntityT: PlugwiseEntity, **_P, _R](
|
| 15 |
+
func: Callable[Concatenate[_PlugwiseEntityT, _P], Awaitable[_R]],
|
| 16 |
+
) -> Callable[Concatenate[_PlugwiseEntityT, _P], Coroutine[Any, Any, _R]]:
|
| 17 |
"""Decorate Plugwise calls that send commands/make changes to the device.
|
| 18 |
|
| 19 |
A decorator that wraps the passed in function, catches Plugwise errors,
|
|
|
|
| 21 |
"""
|
| 22 |
|
| 23 |
async def handler(
|
| 24 |
+
self: _PlugwiseEntityT, *args: _P.args, **kwargs: _P.kwargs
|
| 25 |
+
) -> _R:
|
| 26 |
try:
|
| 27 |
return await func(self, *args, **kwargs)
|
| 28 |
except PlugwiseException as err:
|