Diff to HTML by rtfpessoa

Files changed (16) hide show
  1. /home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/__init__.py +22 -103
  2. /home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/binary_sensor.py +35 -94
  3. /home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/button.py +7 -17
  4. /home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/climate.py +78 -153
  5. /home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/config_flow.py +27 -130
  6. /home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/const.py +38 -154
  7. /home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/coordinator.py +29 -60
  8. /home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/entity.py +10 -27
  9. /home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/icons.json +6 -9
  10. /home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/manifest.json +4 -4
  11. /home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/number.py +24 -55
  12. /home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/select.py +16 -46
  13. /home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/sensor.py +101 -172
  14. /home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/strings.json +159 -169
  15. /home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/switch.py +24 -54
  16. /home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/util.py +5 -12
/home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/__init__.py RENAMED
@@ -4,44 +4,21 @@
4
 
5
  from typing import Any
6
 
7
- from plugwise.exceptions import PlugwiseError
8
- import voluptuous as vol # pw-beta delete_notification
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
- cooldown = 1.5 # pw-beta frontend refresh-interval
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,63 +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, config_entry: PlugwiseConfigEntry
89
- ) -> None: # pragma: no cover # pw-beta
90
- """Handle options update."""
91
- await hass.config_entries.async_reload(config_entry.entry_id)
92
-
93
- async def async_unload_entry(hass: HomeAssistant, config_entry: PlugwiseConfigEntry) -> bool:
94
- """Unload Plugwise."""
95
- return await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS)
96
-
97
- async def async_remove_config_entry_device(
98
- _hass: HomeAssistant, config_entry: PlugwiseConfigEntry, device_entry: dr.DeviceEntry
99
- ) -> bool:
100
- """Enable manual removal (button) for Plugwise devices."""
101
- coordinator = config_entry.runtime_data
102
- return not any(
103
- identifier
104
- for identifier in device_entry.identifiers
105
- if identifier[0] == DOMAIN and (
106
- identifier[1] != coordinator.api.gateway_id
107
- and identifier[1] in coordinator.data
108
- )
109
- )
110
 
111
  @callback
112
  def async_migrate_entity_entry(entry: er.RegistryEntry) -> dict[str, Any] | None:
113
  """Migrate Plugwise entity entries.
114
 
115
- - Migrates old unique ID's from old binary_sensors and switches to the new unique ID's
116
  """
117
  if entry.domain == Platform.BINARY_SENSOR and entry.unique_id.endswith(
118
  "-slave_boiler_state"
@@ -134,17 +69,18 @@
134
  # No migration needed
135
  return None
136
 
137
- async def async_migrate_sensor_entities(
 
138
  hass: HomeAssistant,
139
  coordinator: PlugwiseDataUpdateCoordinator,
140
  ) -> None:
141
  """Migrate Sensors if needed."""
142
  ent_reg = er.async_get(hass)
143
 
144
- # Migrate opentherm_outdoor_temperature
145
  # to opentherm_outdoor_air_temperature sensor
146
  for device_id, device in coordinator.data.items():
147
- if device["dev_class"] != "heater_central":
148
  continue
149
 
150
  old_unique_id = f"{device_id}-outdoor_temperature"
@@ -152,27 +88,10 @@
152
  Platform.SENSOR, DOMAIN, old_unique_id
153
  ):
154
  new_unique_id = f"{device_id}-outdoor_air_temperature"
155
- # Upstream remove LOGGER debug
 
 
 
 
 
156
  ent_reg.async_update_entity(entity_id, new_unique_id=new_unique_id)
157
-
158
- # pw-beta only - revert adding CONF_TIMEOUT to config_entry in v0.53.3
159
- async def async_migrate_entry(hass: HomeAssistant, entry: PlugwiseConfigEntry) -> bool:
160
- """Migrate back to v1.1 config entry."""
161
- if entry.version > 1:
162
- # This means the user has downgraded from a future version
163
- return False #pragma: no cover
164
-
165
- if entry.version == 1 and entry.minor_version == 2:
166
- new_data = {**entry.data}
167
- new_data.pop(CONF_TIMEOUT)
168
- hass.config_entries.async_update_entry(
169
- entry, data=new_data, minor_version=1, version=1
170
- )
171
-
172
- LOGGER.debug(
173
- "Migration to version %s.%s successful",
174
- entry.version,
175
- entry.minor_version,
176
- )
177
-
178
- 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)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/binary_sensor.py RENAMED
@@ -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
- # Upstream PLUGWISE_BINARY_SENSORS
55
- PLUGWISE_BINARY_SENSORS: tuple[PlugwiseBinarySensorEntityDescription, ...] = (
56
  PlugwiseBinarySensorEntityDescription(
57
- key=BATTERY_STATE,
58
  device_class=BinarySensorDeviceClass.BATTERY,
59
  entity_category=EntityCategory.DIAGNOSTIC,
60
  ),
61
  PlugwiseBinarySensorEntityDescription(
62
- key=COMPRESSOR_STATE,
63
- translation_key=COMPRESSOR_STATE,
64
  entity_category=EntityCategory.DIAGNOSTIC,
65
  ),
66
  PlugwiseBinarySensorEntityDescription(
67
- key=COOLING_ENABLED,
68
- translation_key=COOLING_ENABLED,
69
  entity_category=EntityCategory.DIAGNOSTIC,
70
  ),
71
  PlugwiseBinarySensorEntityDescription(
72
- key=DHW_STATE,
73
- translation_key=DHW_STATE,
74
  entity_category=EntityCategory.DIAGNOSTIC,
75
  ),
76
  PlugwiseBinarySensorEntityDescription(
77
- key=FLAME_STATE,
78
- translation_key=FLAME_STATE,
79
  entity_category=EntityCategory.DIAGNOSTIC,
80
  ),
81
  PlugwiseBinarySensorEntityDescription(
82
- key=HEATING_STATE,
83
- translation_key=HEATING_STATE,
84
  entity_category=EntityCategory.DIAGNOSTIC,
85
  ),
86
  PlugwiseBinarySensorEntityDescription(
87
- key=COOLING_STATE,
88
- translation_key=COOLING_STATE,
89
  entity_category=EntityCategory.DIAGNOSTIC,
90
  ),
91
  PlugwiseBinarySensorEntityDescription(
92
- key=SECONDARY_BOILER_STATE,
93
- translation_key=SECONDARY_BOILER_STATE,
94
  entity_category=EntityCategory.DIAGNOSTIC,
95
  ),
96
  PlugwiseBinarySensorEntityDescription(
97
- key=PLUGWISE_NOTIFICATION,
98
- translation_key=PLUGWISE_NOTIFICATION,
99
  entity_category=EntityCategory.DIAGNOSTIC,
100
  ),
101
  )
@@ -106,7 +87,7 @@
106
  entry: PlugwiseConfigEntry,
107
  async_add_entities: AddConfigEntryEntitiesCallback,
108
  ) -> None:
109
- """Set up Plugwise binary_sensors from a config entry."""
110
  coordinator = entry.runtime_data
111
 
112
  @callback
@@ -115,40 +96,20 @@
115
  if not coordinator.new_devices:
116
  return
117
 
118
- # Upstream consts to HA
119
- # async_add_entities(
120
- # PlugwiseBinarySensorEntity(coordinator, device_id, description)
121
- # for device_id in coordinator.new_devices
122
- # if (
123
- # binary_sensors := coordinator.data.devices[device_id].get(
124
- # BINARY_SENSORS
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
- """Set up Plugwise binary_sensors from a config entry."""
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 | None:
169
  """Return true if the binary sensor is on."""
170
- # pw-beta: show Plugwise notifications as HA persistent notifications
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 != PLUGWISE_NOTIFICATION: # Upstream const
183
  return None
184
 
185
- # pw-beta adjustment with attrs is to only represent severities *with* content
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 notify_id, details in notify.items(): # pw-beta uses notify_id
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" # pragma: no cover
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
/home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/button.py RENAMED
@@ -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 config entry."""
27
  coordinator = entry.runtime_data
28
 
29
- # async_add_entities(
30
- # PlugwiseButtonEntity(coordinator, device_id)
31
- # for device_id in coordinator.data.devices
32
- # if device_id == gateway[GATEWAY_ID] and REBOOT in gateway
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):
/home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/climate.py RENAMED
@@ -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 # Upstream
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(LOCATION)) is not None:
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", None): # can be NONE
189
  self._attr_supported_features |= ClimateEntityFeature.PRESET_MODE
190
- self._attr_preset_modes = presets
 
 
 
 
 
 
 
191
 
192
  @property
193
- def current_temperature(self) -> float | None:
194
  """Return the current temperature."""
195
- return self.device.get(SENSORS, {}).get(ATTR_TEMPERATURE)
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 | None:
207
  """Return the temperature we try to reach.
208
 
209
  Connected to the HVACMode combination of AUTO-HEAT.
210
  """
211
 
212
- return self.device.get(THERMOSTAT, {}).get(TARGET_TEMP)
213
 
214
  @property
215
- def target_temperature_high(self) -> float | None:
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.get(THERMOSTAT, {}).get(TARGET_TEMP_HIGH)
221
 
222
  @property
223
- def target_temperature_low(self) -> float | None:
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.get(THERMOSTAT, {}).get(TARGET_TEMP_LOW)
229
 
230
  @property
231
  def hvac_mode(self) -> HVACMode:
232
  """Return HVAC operation ie. auto, cool, heat, heat_cool, or off mode."""
233
- mode = self.device.get(CLIMATE_MODE)
234
- if mode is None:
235
- return HVACMode.HEAT # pragma: no cover
236
- try:
237
- hvac = HVACMode(mode)
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(AVAILABLE_SCHEDULES, []):
259
  hvac_modes.append(HVACMode.AUTO)
260
 
261
  if self.coordinator.api.cooling_present:
262
- if REGULATION_MODES in self._gateway_data:
263
- selected = self._gateway_data.get(SELECT_REGULATION_MODE)
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: # pw-beta add to Core
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
- REGULATION_MODES in self._gateway_data
282
- and HVACAction.COOLING.value in self._gateway_data[REGULATION_MODES]
283
  ):
284
- mode = self._gateway_data[SELECT_REGULATION_MODE]
285
  if mode in (HVACAction.COOLING.value, HVACAction.HEATING.value):
286
  self._previous_action_mode = mode
287
 
288
- if (action := self.device.get(CONTROL_STATE)) is not None:
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(ACTIVE_PRESET)
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[TARGET_TEMP] = kwargs.get(ATTR_TEMPERATURE)
304
  if ATTR_TARGET_TEMP_HIGH in kwargs:
305
- data[TARGET_TEMP_HIGH] = kwargs.get(ATTR_TARGET_TEMP_HIGH)
306
  if ATTR_TARGET_TEMP_LOW in kwargs:
307
- data[TARGET_TEMP_LOW] = kwargs.get(ATTR_TARGET_TEMP_LOW)
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 != HVACMode.OFF:
 
 
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
- await self._homekit_translate_or_not(hvac_mode) # pw-beta
346
-
347
- async def _homekit_translate_or_not(self, mode: HVACMode) -> None:
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:
/home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/config_flow.py RENAMED
@@ -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
- THERMOSTAT,
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(cf_input: ZeroconfServiceInfo | dict[str, Any] | None) -> vol.Schema:
85
  """Generate base schema for gateways."""
86
- if not cf_input: # no discovery- or user-input available
87
- return vol.Schema(
 
 
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
- if isinstance(cf_input, ZeroconfServiceInfo):
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 = "Unknown Smile"
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="anna_with_adam")
207
 
208
- _name = f"{ZEROCONF_MAP.get(_product, _product)} v{_version}"
209
  self.context.update(
210
  {
211
- TITLE_PLACEHOLDERS: {CONF_NAME: _name},
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, raise_on_progress=False
 
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(configure_input),
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
- # Redefine ingest existing username and password
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, raise_on_progress=False
 
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
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/const.py RENAMED
@@ -1,164 +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
- COORDINATOR: Final = "coordinator"
17
- CONF_HOMEKIT_EMULATION: Final = "homekit_emulation" # pw-beta options
18
- CONF_REFRESH_INTERVAL: Final = "refresh_interval" # pw-beta options
19
- CONF_MANUAL_PATH: Final = "Enter Manually"
 
20
  GATEWAY: Final = "gateway"
21
  LOCATION: Final = "location"
22
- MAC_ADDRESS: Final = "mac_address"
23
  REBOOT: Final = "reboot"
24
  SMILE: Final = "smile"
25
- STRETCH: Final = "stretch"
26
- STRETCH_USERNAME: Final = "stretch"
27
- SWITCH_GROUPS: Final[tuple[str, str]] = ("report", "switching")
28
- UNIQUE_IDS: Final = "unique_ids"
29
- ZIGBEE_MAC_ADDRESS: Final = "zigbee_mac_address"
30
-
31
- # Binary Sensor constants
32
- BINARY_SENSORS: Final = "binary_sensors"
33
- BATTERY_STATE: Final = "low_battery"
34
- COMPRESSOR_STATE: Final = "compressor_state"
35
- COOLING_ENABLED: Final = "cooling_enabled"
36
- COOLING_STATE: Final = "cooling_state"
37
- DHW_STATE: Final = "dhw_state"
38
- FLAME_STATE: Final = "flame_state"
39
- HEATING_STATE: Final = "heating_state"
40
- PLUGWISE_NOTIFICATION: Final = "plugwise_notification"
41
- SECONDARY_BOILER_STATE: Final = "secondary_boiler_state"
42
-
43
- # Climate constants
44
- ACTIVE_PRESET: Final = "active_preset"
45
- CLIMATE_MODE: Final = "climate_mode"
46
- CONTROL_STATE: Final = "control_state"
47
- COOLING_PRESENT: Final ="cooling_present"
48
- DEV_CLASS: Final = "dev_class"
49
- NONE : Final = "None"
50
- TARGET_TEMP: Final = "setpoint"
51
- TARGET_TEMP_HIGH: Final = "setpoint_high"
52
- TARGET_TEMP_LOW: Final = "setpoint_low"
53
- THERMOSTAT: Final = "thermostat"
54
-
55
- # Config_flow constants
56
- ANNA_WITH_ADAM: Final = "anna_with_adam"
57
- CONTEXT: Final = "context"
58
- FLOW_ID: Final = "flow_id"
59
- FLOW_NET: Final = "Network: Smile/Stretch"
60
- FLOW_SMILE: Final = "Smile (Adam/Anna/P1)"
61
- FLOW_STRETCH: Final = "Stretch (Stretch)"
62
- FLOW_TYPE: Final = "flow_type"
63
- INIT: Final = "init"
64
- PRODUCT: Final = "product"
65
  SMILE_OPEN_THERM: Final = "smile_open_therm"
66
  SMILE_THERMO: Final = "smile_thermo"
67
- TITLE_PLACEHOLDERS: Final = "title_placeholders"
68
- VERSION: Final = "version"
69
-
70
- # Entity constants
71
- AVAILABLE: Final = "available"
72
- FIRMWARE: Final = "firmware"
73
- HARDWARE: Final = "hardware"
74
- MODEL: Final = "model"
75
- MODEL_ID: Final = "model_id"
76
- VENDOR: Final = "vendor"
77
-
78
- # Number constants
79
- MAX_BOILER_TEMP: Final = "maximum_boiler_temperature"
80
- MAX_DHW_TEMP: Final = "max_dhw_temperature"
81
- LOWER_BOUND: Final = "lower_bound"
82
- RESOLUTION: Final = "resolution"
83
- TEMPERATURE_OFFSET: Final = "temperature_offset"
84
- UPPER_BOUND: Final = "upper_bound"
85
-
86
- # Sensor constants
87
- DHW_TEMP: Final = "dhw_temperature"
88
- DHW_SETPOINT: Final = "domestic_hot_water_setpoint"
89
- EL_CONSUMED: Final = "electricity_consumed"
90
- EL_CONS_INTERVAL: Final = "electricity_consumed_interval"
91
- EL_CONS_OP_CUMULATIVE: Final = "electricity_consumed_off_peak_cumulative"
92
- EL_CONS_OP_INTERVAL: Final = "electricity_consumed_off_peak_interval"
93
- EL_CONS_OP_POINT: Final = "electricity_consumed_off_peak_point"
94
- EL_CONS_P_CUMULATIVE: Final = "electricity_consumed_peak_cumulative"
95
- EL_CONS_P_INTERVAL: Final = "electricity_consumed_peak_interval"
96
- EL_CONS_P_POINT: Final = "electricity_consumed_peak_point"
97
- EL_CONS_POINT: Final = "electricity_consumed_point"
98
- EL_PH1_CONSUMED: Final = "electricity_phase_one_consumed"
99
- EL_PH2_CONSUMED: Final = "electricity_phase_two_consumed"
100
- EL_PH3_CONSUMED: Final = "electricity_phase_three_consumed"
101
- EL_PH1_PRODUCED: Final = "electricity_phase_one_produced"
102
- EL_PH2_PRODUCED: Final = "electricity_phase_two_produced"
103
- EL_PH3_PRODUCED: Final = "electricity_phase_three_produced"
104
- EL_PRODUCED: Final = "electricity_produced"
105
- EL_PROD_INTERVAL: Final = "electricity_produced_interval"
106
- EL_PROD_OP_CUMULATIVE: Final = "electricity_produced_off_peak_cumulative"
107
- EL_PROD_OP_INTERVAL: Final = "electricity_produced_off_peak_interval"
108
- EL_PROD_OP_POINT: Final = "electricity_produced_off_peak_point"
109
- EL_PROD_P_CUMULATIVE: Final = "electricity_produced_peak_cumulative"
110
- EL_PROD_P_INTERVAL: Final = "electricity_produced_peak_interval"
111
- EL_PROD_P_POINT: Final = "electricity_produced_peak_point"
112
- EL_PROD_POINT: Final = "electricity_produced_point"
113
- GAS_CONS_CUMULATIVE: Final = "gas_consumed_cumulative"
114
- GAS_CONS_INTERVAL: Final = "gas_consumed_interval"
115
- INTENDED_BOILER_TEMP: Final = "intended_boiler_temperature"
116
- MOD_LEVEL: Final = "modulation_level"
117
- NET_EL_POINT: Final = "net_electricity_point"
118
- NET_EL_CUMULATIVE: Final = "net_electricity_cumulative"
119
- OUTDOOR_AIR_TEMP: Final = "outdoor_air_temperature"
120
- OUTDOOR_TEMP: Final = "outdoor_temperature"
121
- RETURN_TEMP: Final = "return_temperature"
122
- SENSORS: Final = "sensors"
123
- TEMP_DIFF: Final = "temperature_difference"
124
- VALVE_POS: Final = "valve_position"
125
- VOLTAGE_PH1: Final = "voltage_phase_one"
126
- VOLTAGE_PH2: Final = "voltage_phase_two"
127
- VOLTAGE_PH3: Final = "voltage_phase_three"
128
- WATER_TEMP: Final = "water_temperature"
129
- WATER_PRESSURE: Final = "water_pressure"
130
-
131
- # Select constants
132
- AVAILABLE_SCHEDULES: Final = "available_schedules"
133
- DHW_MODES: Final = "dhw_modes"
134
- GATEWAY_MODES: Final = "gateway_modes"
135
- REGULATION_MODES: Final = "regulation_modes"
136
- ZONE_PROFILES: Final = "zone_profiles"
137
- SELECT_DHW_MODE: Final = "select_dhw_mode"
138
- SELECT_GATEWAY_MODE: Final = "select_gateway_mode"
139
- SELECT_REGULATION_MODE: Final = "select_regulation_mode"
140
- SELECT_SCHEDULE: Final = "select_schedule"
141
- SELECT_ZONE_PROFILE: Final = "select_zone_profile"
142
-
143
- # Switch constants
144
- DHW_CM_SWITCH: Final = "dhw_cm_switch"
145
- LOCK: Final = "lock"
146
- MEMBERS: Final ="members"
147
- RELAY: Final = "relay"
148
- COOLING_ENA_SWITCH: Final ="cooling_ena_switch"
149
- SWITCHES: Final = "switches"
150
-
151
- # Default directives
152
- DEFAULT_PORT: Final[int] = 80
153
- DEFAULT_SCAN_INTERVAL: Final[dict[str, timedelta]] = {
154
- "power": timedelta(seconds=10),
155
- "stretch": timedelta(seconds=60),
156
- "thermostat": timedelta(seconds=60),
157
- }
158
- DEFAULT_TIMEOUT: Final[int] = 30
159
- DEFAULT_USERNAME: Final = "smile"
160
 
161
- # --- Const for Plugwise Smile and Stretch
162
  PLATFORMS: Final[list[str]] = [
163
  Platform.BINARY_SENSOR,
164
  Platform.BUTTON,
@@ -168,18 +39,6 @@
168
  Platform.SENSOR,
169
  Platform.SWITCH,
170
  ]
171
- SERVICE_DELETE: Final = "delete_notification"
172
- SEVERITIES: Final[list[str]] = ["other", "info", "message", "warning", "error"]
173
-
174
- # Climate const:
175
- MASTER_THERMOSTATS: Final[list[str]] = [
176
- "thermostat",
177
- "zone_thermometer",
178
- "zone_thermostat",
179
- "thermostatic_radiator_valve",
180
- ]
181
-
182
- # Config_flow const:
183
  ZEROCONF_MAP: Final[dict[str, str]] = {
184
  "smile": "Smile P1",
185
  "smile_thermo": "Smile Anna",
@@ -198,7 +57,7 @@
198
  "select_gateway_mode",
199
  "select_regulation_mode",
200
  "select_schedule",
201
- "select_zone_profile"
202
  ]
203
  type SelectOptionsType = Literal[
204
  "available_schedules",
@@ -207,3 +66,28 @@
207
  "regulation_modes",
208
  "zone_profiles",
209
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"
/home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/coordinator.py RENAMED
@@ -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 DEFAULT_SCAN_INTERVAL, DEV_CLASS, DOMAIN, LOGGER, SWITCH_GROUPS
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
- # Core directly updates from const's DEFAULT_SCAN_INTERVAL
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=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[CONF_PORT],
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,50 +99,45 @@
125
  translation_key="unsupported_firmware",
126
  ) from err
127
 
128
- LOGGER.debug(f"{self.api.smile.name} data: %s", data)
129
- await self._async_add_remove_devices(data)
130
  return data
131
 
132
- async def _async_add_remove_devices(self, data: dict[str, GwEntityData]) -> None:
133
  """Add new Plugwise devices, remove non-existing devices."""
134
- # Block switch-groups, use HA group helper instead
135
- for device_id, device in data.copy().items():
136
- if device.get(DEV_CLASS) in SWITCH_GROUPS:
137
- data.pop(device_id)
138
  # Check for new or removed devices
139
  self.new_devices = set(data) - self._current_devices
140
  removed_devices = self._current_devices - set(data)
141
  self._current_devices = set(data)
142
 
143
  if removed_devices:
144
- await self._async_remove_devices(data)
145
 
146
- async def _async_remove_devices(self, data: dict[str, GwEntityData]) -> None:
147
  """Clean registries when removed devices found."""
148
  device_reg = dr.async_get(self.hass)
149
  device_list = dr.async_entries_for_config_entry(
150
  device_reg, self.config_entry.entry_id
151
  )
152
-
153
  # First find the Plugwise via_device
154
  gateway_device = device_reg.async_get_device({(DOMAIN, self.api.gateway_id)})
155
- if gateway_device is not None:
156
- via_device_id = gateway_device.id
157
 
158
  # Then remove the connected orphaned device(s)
159
  for device_entry in device_list:
160
  for identifier in device_entry.identifiers:
161
- if (
162
- identifier[0] == DOMAIN
163
- and device_entry.via_device_id == via_device_id
164
- and identifier[1] not in data
165
- ):
166
- device_reg.async_update_device(
167
- device_entry.id, remove_config_entry_id=self.config_entry.entry_id
168
- )
169
- LOGGER.debug(
170
- "Removed %s device/zone %s %s from device_registry",
171
- DOMAIN,
172
- device_entry.model,
173
- identifier[1],
174
- )
 
 
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
109
  removed_devices = self._current_devices - set(data)
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
+ )
/home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/entity.py RENAMED
@@ -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(MAC_ADDRESS):
55
  connections.add((CONNECTION_NETWORK_MAC, mac))
56
- if mac := data.get(ZIGBEE_MAC_ADDRESS):
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(VENDOR),
64
- model=data.get(MODEL),
65
- model_id=data.get(MODEL_ID),
66
  name=coordinator.api.smile.name,
67
- sw_version=data.get(FIRMWARE),
68
- hw_version=data.get(HARDWARE),
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.get(AVAILABLE, True) is True)
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
 
/home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/icons.json RENAMED
@@ -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
- "off": "mdi:circle-off-outline",
 
90
  "heating": "mdi:radiator",
91
- "cooling": "mdi:snowflake"
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
  }
/home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/manifest.json RENAMED
@@ -1,13 +1,13 @@
1
  {
2
  "domain": "plugwise",
3
- "name": "Plugwise Beta",
4
  "codeowners": ["@CoMPaTech", "@bouwew"],
5
  "config_flow": true,
6
- "documentation": "https://github.com/plugwise/plugwise-beta",
7
  "integration_type": "hub",
8
  "iot_class": "local_polling",
9
  "loggers": ["plugwise"],
10
- "requirements": ["plugwise==1.11.0"],
11
- "version": "0.62.0",
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
  }
/home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/number.py RENAMED
@@ -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=MAX_BOILER_TEMP,
47
- translation_key=MAX_BOILER_TEMP,
48
  device_class=NumberDeviceClass.TEMPERATURE,
49
  entity_category=EntityCategory.CONFIG,
50
  native_unit_of_measurement=UnitOfTemperature.CELSIUS,
51
  ),
52
  PlugwiseNumberEntityDescription(
53
- key=MAX_DHW_TEMP,
54
- translation_key=MAX_DHW_TEMP,
55
  device_class=NumberDeviceClass.TEMPERATURE,
56
  entity_category=EntityCategory.CONFIG,
57
  native_unit_of_measurement=UnitOfTemperature.CELSIUS,
58
  ),
59
  PlugwiseNumberEntityDescription(
60
- key=TEMPERATURE_OFFSET,
61
- translation_key=TEMPERATURE_OFFSET,
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 from a config entry."""
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
- # Upstream consts
85
- # async_add_entities(
86
- # PlugwiseNumberEntity(coordinator, device_id, description)
87
- # for device_id in coordinator.new_devices
88
- # for description in NUMBER_TYPES
89
- # if description.key in coordinator.data.devices[device_id]
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 = ctrl.get(RESOLUTION, 0.5) # Upstream const
133
- if description.key != TEMPERATURE_OFFSET: # Upstream const
134
  native_step = max(native_step, 0.5)
135
  self._attr_native_step = native_step
136
 
137
  @property
138
- def native_value(self) -> float | None:
139
  """Return the present setpoint value."""
140
- return self.device.get(self.entity_description.key, {}).get("setpoint")
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(self.device_id, self.entity_description.key, value)
146
- LOGGER.debug(
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
  )
/home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/select.py RENAMED
@@ -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=AVAILABLE_SCHEDULES,
52
  ),
53
  PlugwiseSelectEntityDescription(
54
  key=SELECT_REGULATION_MODE,
55
  translation_key=SELECT_REGULATION_MODE,
56
  entity_category=EntityCategory.CONFIG,
57
- options_key=REGULATION_MODES,
58
  ),
59
  PlugwiseSelectEntityDescription(
60
  key=SELECT_DHW_MODE,
61
  translation_key=SELECT_DHW_MODE,
62
  entity_category=EntityCategory.CONFIG,
63
- options_key=DHW_MODES,
64
  ),
65
  PlugwiseSelectEntityDescription(
66
  key=SELECT_GATEWAY_MODE,
67
  translation_key=SELECT_GATEWAY_MODE,
68
  entity_category=EntityCategory.CONFIG,
69
- options_key=GATEWAY_MODES,
70
  ),
71
  PlugwiseSelectEntityDescription(
72
  key=SELECT_ZONE_PROFILE,
73
  translation_key=SELECT_ZONE_PROFILE,
74
  entity_category=EntityCategory.CONFIG,
75
- options_key=ZONE_PROFILES,
76
  ),
77
  )
78
 
@@ -82,7 +72,7 @@
82
  entry: PlugwiseConfigEntry,
83
  async_add_entities: AddConfigEntryEntitiesCallback,
84
  ) -> None:
85
- """Set up Plugwise selector from a config entry."""
86
  coordinator = entry.runtime_data
87
 
88
  @callback
@@ -91,27 +81,12 @@
91
  if not coordinator.new_devices:
92
  return
93
 
94
- # Upstream consts
95
- # async_add_entities(
96
- # PlugwiseSelectEntity(coordinator, device_id, description)
97
- # for device_id in coordinator.new_devices
98
- # for description in SELECT_TYPES
99
- # if description.options_key in coordinator.data.devices[device_id]
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(LOCATION)) is not None:
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.get(self.entity_description.key)
144
 
145
  @property
146
  def options(self) -> list[str]:
147
  """Return the available select-options."""
148
- return self.device.get(self.entity_description.options_key, [])
149
 
150
  @plugwise_command
151
  async def async_select_option(self, option: str) -> None:
152
  """Change to the selected entity option.
153
 
154
- Location ID and STATE_ON are required for the thermostat-schedule select.
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
  )
 
 
 
 
 
/home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/sensor.py RENAMED
@@ -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
- # Upstream consts
97
- PLUGWISE_SENSORS: tuple[PlugwiseSensorEntityDescription, ...] = (
98
  PlugwiseSensorEntityDescription(
99
- key=TARGET_TEMP,
100
- translation_key=TARGET_TEMP,
101
  native_unit_of_measurement=UnitOfTemperature.CELSIUS,
102
  device_class=SensorDeviceClass.TEMPERATURE,
103
  state_class=SensorStateClass.MEASUREMENT,
104
  ),
105
  PlugwiseSensorEntityDescription(
106
- key=TARGET_TEMP_HIGH,
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=TARGET_TEMP_LOW,
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=ATTR_TEMPERATURE,
121
  native_unit_of_measurement=UnitOfTemperature.CELSIUS,
122
  device_class=SensorDeviceClass.TEMPERATURE,
123
  state_class=SensorStateClass.MEASUREMENT,
124
  ),
125
  PlugwiseSensorEntityDescription(
126
- key=INTENDED_BOILER_TEMP,
127
- translation_key=INTENDED_BOILER_TEMP,
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=TEMP_DIFF,
135
- translation_key=TEMP_DIFF,
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=OUTDOOR_TEMP,
143
- translation_key=OUTDOOR_TEMP,
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=OUTDOOR_AIR_TEMP,
152
- translation_key=OUTDOOR_AIR_TEMP,
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=WATER_TEMP,
160
- translation_key=WATER_TEMP,
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=RETURN_TEMP,
168
- translation_key=RETURN_TEMP,
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=EL_CONSUMED,
176
- translation_key=EL_CONSUMED,
177
  native_unit_of_measurement=UnitOfPower.WATT,
178
  device_class=SensorDeviceClass.POWER,
179
  state_class=SensorStateClass.MEASUREMENT,
180
  ),
181
  PlugwiseSensorEntityDescription(
182
- key=EL_PRODUCED,
183
- translation_key=EL_PRODUCED,
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=EL_CONS_INTERVAL,
191
- translation_key=EL_CONS_INTERVAL,
192
  native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
193
  device_class=SensorDeviceClass.ENERGY,
194
  state_class=SensorStateClass.TOTAL,
195
  ),
196
  PlugwiseSensorEntityDescription(
197
- key=EL_CONS_P_INTERVAL,
198
- translation_key=EL_CONS_P_INTERVAL,
199
  native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
200
  device_class=SensorDeviceClass.ENERGY,
201
  state_class=SensorStateClass.TOTAL,
202
  ),
203
  PlugwiseSensorEntityDescription(
204
- key=EL_CONS_OP_INTERVAL,
205
- translation_key=EL_CONS_OP_INTERVAL,
206
  native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
207
  device_class=SensorDeviceClass.ENERGY,
208
  state_class=SensorStateClass.TOTAL,
209
  ),
210
  PlugwiseSensorEntityDescription(
211
- key=EL_PROD_INTERVAL,
212
- translation_key=EL_PROD_INTERVAL,
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=EL_PROD_P_INTERVAL,
220
- translation_key=EL_PROD_P_INTERVAL,
221
  native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
222
  device_class=SensorDeviceClass.ENERGY,
223
  state_class=SensorStateClass.TOTAL,
224
  ),
225
  PlugwiseSensorEntityDescription(
226
- key=EL_PROD_OP_INTERVAL,
227
- translation_key=EL_PROD_OP_INTERVAL,
228
  native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
229
  device_class=SensorDeviceClass.ENERGY,
230
  state_class=SensorStateClass.TOTAL,
231
  ),
232
  PlugwiseSensorEntityDescription(
233
- key=EL_CONS_POINT,
234
- translation_key=EL_CONS_POINT,
235
  device_class=SensorDeviceClass.POWER,
236
  native_unit_of_measurement=UnitOfPower.WATT,
237
  state_class=SensorStateClass.MEASUREMENT,
238
  ),
239
  PlugwiseSensorEntityDescription(
240
- key=EL_CONS_OP_POINT,
241
- translation_key=EL_CONS_OP_POINT,
242
  native_unit_of_measurement=UnitOfPower.WATT,
243
  device_class=SensorDeviceClass.POWER,
244
  state_class=SensorStateClass.MEASUREMENT,
245
  ),
246
  PlugwiseSensorEntityDescription(
247
- key=EL_CONS_P_POINT,
248
- translation_key=EL_CONS_P_POINT,
249
  native_unit_of_measurement=UnitOfPower.WATT,
250
  device_class=SensorDeviceClass.POWER,
251
  state_class=SensorStateClass.MEASUREMENT,
252
  ),
253
  PlugwiseSensorEntityDescription(
254
- key=EL_CONS_OP_CUMULATIVE,
255
- translation_key=EL_CONS_OP_CUMULATIVE,
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=EL_CONS_P_CUMULATIVE,
262
- translation_key=EL_CONS_P_CUMULATIVE,
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=EL_PROD_POINT,
269
- translation_key=EL_PROD_POINT,
270
  device_class=SensorDeviceClass.POWER,
271
  native_unit_of_measurement=UnitOfPower.WATT,
272
  state_class=SensorStateClass.MEASUREMENT,
273
  ),
274
  PlugwiseSensorEntityDescription(
275
- key=EL_PROD_OP_POINT,
276
- translation_key=EL_PROD_OP_POINT,
277
  native_unit_of_measurement=UnitOfPower.WATT,
278
  device_class=SensorDeviceClass.POWER,
279
  state_class=SensorStateClass.MEASUREMENT,
280
  ),
281
  PlugwiseSensorEntityDescription(
282
- key=EL_PROD_P_POINT,
283
- translation_key=EL_PROD_P_POINT,
284
  native_unit_of_measurement=UnitOfPower.WATT,
285
  device_class=SensorDeviceClass.POWER,
286
  state_class=SensorStateClass.MEASUREMENT,
287
  ),
288
  PlugwiseSensorEntityDescription(
289
- key=EL_PROD_OP_CUMULATIVE,
290
- translation_key=EL_PROD_OP_CUMULATIVE,
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=EL_PROD_P_CUMULATIVE,
297
- translation_key=EL_PROD_P_CUMULATIVE,
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=EL_PH1_CONSUMED,
304
- translation_key=EL_PH1_CONSUMED,
305
  device_class=SensorDeviceClass.POWER,
306
  native_unit_of_measurement=UnitOfPower.WATT,
307
  state_class=SensorStateClass.MEASUREMENT,
308
  ),
309
  PlugwiseSensorEntityDescription(
310
- key=EL_PH2_CONSUMED,
311
- translation_key=EL_PH2_CONSUMED,
312
  device_class=SensorDeviceClass.POWER,
313
  native_unit_of_measurement=UnitOfPower.WATT,
314
  state_class=SensorStateClass.MEASUREMENT,
315
  ),
316
  PlugwiseSensorEntityDescription(
317
- key=EL_PH3_CONSUMED,
318
- translation_key=EL_PH3_CONSUMED,
319
  device_class=SensorDeviceClass.POWER,
320
  native_unit_of_measurement=UnitOfPower.WATT,
321
  state_class=SensorStateClass.MEASUREMENT,
322
  ),
323
  PlugwiseSensorEntityDescription(
324
- key=EL_PH1_PRODUCED,
325
- translation_key=EL_PH1_PRODUCED,
326
  device_class=SensorDeviceClass.POWER,
327
  native_unit_of_measurement=UnitOfPower.WATT,
328
  state_class=SensorStateClass.MEASUREMENT,
329
  ),
330
  PlugwiseSensorEntityDescription(
331
- key=EL_PH2_PRODUCED,
332
- translation_key=EL_PH2_PRODUCED,
333
  device_class=SensorDeviceClass.POWER,
334
  native_unit_of_measurement=UnitOfPower.WATT,
335
  state_class=SensorStateClass.MEASUREMENT,
336
  ),
337
  PlugwiseSensorEntityDescription(
338
- key=EL_PH3_PRODUCED,
339
- translation_key=EL_PH3_PRODUCED,
340
  device_class=SensorDeviceClass.POWER,
341
  native_unit_of_measurement=UnitOfPower.WATT,
342
  state_class=SensorStateClass.MEASUREMENT,
343
  ),
344
  PlugwiseSensorEntityDescription(
345
- key=VOLTAGE_PH1,
346
- translation_key=VOLTAGE_PH1,
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=VOLTAGE_PH2,
354
- translation_key=VOLTAGE_PH2,
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=VOLTAGE_PH3,
362
- translation_key=VOLTAGE_PH3,
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=GAS_CONS_INTERVAL,
370
- translation_key=GAS_CONS_INTERVAL,
371
  native_unit_of_measurement=UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR,
372
  state_class=SensorStateClass.MEASUREMENT,
373
  ),
374
  PlugwiseSensorEntityDescription(
375
- key=GAS_CONS_CUMULATIVE,
376
- translation_key=GAS_CONS_CUMULATIVE,
377
  native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
378
  device_class=SensorDeviceClass.GAS,
379
  state_class=SensorStateClass.TOTAL,
380
  ),
381
  PlugwiseSensorEntityDescription(
382
- key=NET_EL_POINT,
383
- translation_key=NET_EL_POINT,
384
  native_unit_of_measurement=UnitOfPower.WATT,
385
  device_class=SensorDeviceClass.POWER,
386
  state_class=SensorStateClass.MEASUREMENT,
387
  ),
388
  PlugwiseSensorEntityDescription(
389
- key=NET_EL_CUMULATIVE,
390
- translation_key=NET_EL_CUMULATIVE,
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=MOD_LEVEL,
411
- translation_key=MOD_LEVEL,
412
  native_unit_of_measurement=PERCENTAGE,
413
  entity_category=EntityCategory.DIAGNOSTIC,
414
  state_class=SensorStateClass.MEASUREMENT,
415
  ),
416
  PlugwiseSensorEntityDescription(
417
- key=VALVE_POS,
418
- translation_key=VALVE_POS,
419
  native_unit_of_measurement=PERCENTAGE,
420
  entity_category=EntityCategory.DIAGNOSTIC,
421
  state_class=SensorStateClass.MEASUREMENT,
422
  ),
423
  PlugwiseSensorEntityDescription(
424
- key=WATER_PRESSURE,
425
- translation_key=WATER_PRESSURE,
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=DHW_TEMP,
439
- translation_key=DHW_TEMP,
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=DHW_SETPOINT,
447
- translation_key=DHW_SETPOINT,
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 Plugwise sensors from a config entry."""
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
- # Upstream consts
472
- # async_add_entities(
473
- # PlugwiseSensorEntity(coordinator, device_id, description)
474
- # for device_id in coordinator.new_devices
475
- # if (sensors := coordinator.data.devices[device_id].get(SENSORS))
476
- # for description in PLUGWISE_SENSORS
477
- # if description.key in sensors
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 | None:
517
  """Return the value reported by the sensor."""
518
- return self.device.get(SENSORS, {}).get(self.entity_description.key) # Upstream consts
 
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]
/home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/strings.json RENAMED
@@ -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": "IP-address",
25
- "port": "Port number"
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
- "password": "ID",
33
- "username": "Username",
34
- "host": "IP-address",
35
- "port": "Port number"
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": "Heating"
73
  },
74
- "cooling_state": {
75
- "name": "Cooling"
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": "Away",
96
- "home": "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": "Auto",
120
- "boost": "Boost",
121
- "comfort": "Comfort",
122
- "off": "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": "Normal",
140
  "vacation": "Vacation"
141
  }
142
  },
 
 
 
 
 
 
 
 
 
 
143
  "select_schedule": {
144
  "name": "Thermostat schedule",
145
  "state": {
146
- "off": "Off"
147
  }
148
  },
149
  "select_zone_profile": {
150
  "name": "Zone profile",
151
  "state": {
152
- "active": "Active",
153
- "off": "Off",
154
  "passive": "Passive"
155
  }
156
  }
157
  },
158
  "sensor": {
159
- "setpoint": {
160
- "name": "Setpoint"
161
- },
162
  "cooling_setpoint": {
163
  "name": "Cooling setpoint"
164
  },
165
- "heating_setpoint": {
166
- "name": "Heating setpoint"
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
- "return_temperature": {
184
- "name": "Return temperature"
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
- "electricity_consumed_peak_interval": {
202
- "name": "Electricity consumed peak interval"
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
- "electricity_produced_off_peak_point": {
229
- "name": "Electricity produced off-peak point"
230
- },
231
- "electricity_produced_peak_point": {
232
- "name": "Electricity produced peak point"
233
  },
234
- "electricity_produced_off_peak_cumulative": {
235
- "name": "Electricity produced off-peak cumulative"
236
  },
237
- "electricity_produced_peak_cumulative": {
238
- "name": "Electricity produced peak cumulative"
239
  },
240
  "electricity_phase_one_consumed": {
241
  "name": "Electricity phase one consumed"
242
  },
243
- "electricity_phase_two_consumed": {
244
- "name": "Electricity phase two consumed"
245
  },
246
  "electricity_phase_three_consumed": {
247
  "name": "Electricity phase three consumed"
248
  },
249
- "electricity_phase_one_produced": {
250
- "name": "Electricity phase one produced"
 
 
 
251
  },
252
  "electricity_phase_two_produced": {
253
  "name": "Electricity phase two produced"
254
  },
255
- "electricity_phase_three_produced": {
256
- "name": "Electricity phase three produced"
257
  },
258
- "voltage_phase_one": {
259
- "name": "Voltage phase one"
260
  },
261
- "voltage_phase_two": {
262
- "name": "Voltage phase two"
263
  },
264
- "voltage_phase_three": {
265
- "name": "Voltage phase three"
266
  },
267
- "gas_consumed_interval": {
268
- "name": "Gas consumed interval"
 
 
 
 
 
 
 
 
 
 
 
 
269
  },
270
  "gas_consumed_cumulative": {
271
  "name": "Gas consumed cumulative"
272
  },
273
- "net_electricity_point": {
274
- "name": "Net electricity point"
275
  },
276
- "net_electricity_cumulative": {
277
- "name": "Net electricity cumulative"
 
 
 
 
 
 
278
  },
279
  "modulation_level": {
280
  "name": "Modulation level"
281
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  "valve_position": {
283
  "name": "Valve position"
284
  },
285
- "water_pressure": {
286
- "name": "Water pressure"
287
  },
288
- "dhw_temperature": {
289
- "name": "DHW temperature"
290
  },
291
- "domestic_hot_water_setpoint": {
292
- "name": "DHW setpoint"
293
  },
294
- "maximum_boiler_temperature": {
295
- "name": "Maximum boiler temperature setpoint"
 
 
 
296
  }
297
  },
298
  "switch": {
299
  "cooling_ena_switch": {
300
- "name": "Cooling"
301
  },
302
  "dhw_cm_switch": {
303
  "name": "DHW comfort mode"
304
  },
305
  "lock": {
306
- "name": "Lock"
307
  },
308
  "relay": {
309
  "name": "Relay"
@@ -312,7 +308,7 @@
312
  },
313
  "exceptions": {
314
  "authentication_failed": {
315
- "message": "Invalid authentication"
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": "Failed to connect"
325
  },
326
  "invalid_xml_data": {
327
- "message": "Invalid XML data, or error indication received from the Plugwise Adam/Smile/Stretch"
328
  },
329
  "set_schedule_first": {
330
  "message": "Failed setting HVACMode, set a schedule first."
331
  },
332
  "unsupported_firmware": {
333
- "message": "Device with unsupported firmware"
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
  }
/home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/switch.py RENAMED
@@ -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
- # Upstream consts
45
- PLUGWISE_SWITCHES: tuple[PlugwiseSwitchEntityDescription, ...] = (
46
  PlugwiseSwitchEntityDescription(
47
- key=DHW_CM_SWITCH,
48
- translation_key=DHW_CM_SWITCH,
49
- device_class=SwitchDeviceClass.SWITCH,
50
  entity_category=EntityCategory.CONFIG,
51
  ),
52
  PlugwiseSwitchEntityDescription(
53
- key=LOCK,
54
- translation_key=LOCK,
55
- device_class=SwitchDeviceClass.SWITCH,
56
  entity_category=EntityCategory.CONFIG,
57
  ),
58
  PlugwiseSwitchEntityDescription(
59
- key=RELAY,
60
- translation_key=RELAY,
61
  device_class=SwitchDeviceClass.SWITCH,
62
  ),
63
  PlugwiseSwitchEntityDescription(
64
- key=COOLING_ENA_SWITCH,
65
- translation_key=COOLING_ENA_SWITCH,
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 Plugwise switches from a config entry."""
78
  coordinator = entry.runtime_data
79
 
80
  @callback
@@ -83,28 +68,13 @@
83
  if not coordinator.new_devices:
84
  return
85
 
86
- # Upstream consts
87
- # async_add_entities(
88
- # PlugwiseSwitchEntity(coordinator, device_id, description)
89
- # for device_id in coordinator.new_devices
90
- # if (switches := coordinator.data.devices[device_id].get(SWITCHES))
91
- # for description in PLUGWISE_SWITCHES
92
- # if description.key in switches
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 | None:
131
  """Return True if entity is on."""
132
- return self.device.get(SWITCHES, {}).get(self.entity_description.key) # Upstream const
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(MEMBERS),
140
  self.entity_description.key,
141
  "on",
142
- ) # Upstream const
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(MEMBERS),
150
  self.entity_description.key,
151
  "off",
152
- ) # Upstream const
 
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
+ )
/home/runner/work/progress/progress/clones/beta/{beta/custom_components → ha-core/homeassistant/components}/plugwise/util.py RENAMED
@@ -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[PlugwiseEntityT: PlugwiseEntity, **P, R](
22
- func: Callable[Concatenate[PlugwiseEntityT, P], Awaitable[R]],
23
- ) -> Callable[Concatenate[PlugwiseEntityT, P], Coroutine[Any, Any, R]]:
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: PlugwiseEntityT, *args: P.args, **kwargs: P.kwargs
32
- ) -> R:
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: