Skip to content

Commit f32a838

Browse files
authored
Merge pull request #988 from plugwise/follow-core
Implement recent Core updates, fix logger
2 parents b4f3b36 + 339e49f commit f32a838

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Versions from 0.40 and up
44

5+
## Ongoing
6+
7+
- Implement Core PR's [#158901](https://github.com/home-assistant/core/pull/158901) and [#158094](https://github.com/home-assistant/core/pull/158094)
8+
59
## v0.62.0
610

711
- Improve automatic deletion of device(s) removed from the backend output, via PR [$982](https://github.com/plugwise/plugwise-beta/pull/982)

custom_components/plugwise/binary_sensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def _add_entities() -> None:
139139
continue
140140
entities.append(PlugwiseBinarySensorEntity(coordinator, device_id, description))
141141
LOGGER.debug(
142-
"Add %s %s binary sensor", device["name"], description.translation_key
142+
"Add %s %s binary sensor", device["name"], description.translation_key or description.key
143143
)
144144
async_add_entities(entities)
145145

custom_components/plugwise/entity.py

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,40 +42,43 @@ def __init__(
4242
super().__init__(coordinator)
4343
self._dev_id = device_id
4444

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]
45+
api = coordinator.api
46+
gateway_id = api.gateway_id
47+
entry = coordinator.config_entry
48+
49+
# Link configuration-URL for the gateway device
50+
configuration_url = (
51+
f"http://{entry.data[CONF_HOST]}"
52+
if device_id == gateway_id and entry
53+
else None
54+
)
55+
56+
# Build connections set
5357
connections = set()
54-
if mac := data.get(MAC_ADDRESS):
58+
if mac := self.device.get(MAC_ADDRESS):
5559
connections.add((CONNECTION_NETWORK_MAC, mac))
56-
if mac := data.get(ZIGBEE_MAC_ADDRESS):
57-
connections.add((CONNECTION_ZIGBEE, mac))
60+
if zigbee_mac := self.device.get(ZIGBEE_MAC_ADDRESS):
61+
connections.add((CONNECTION_ZIGBEE, zigbee_mac))
5862

63+
# Set base device info
5964
self._attr_device_info = DeviceInfo(
6065
configuration_url=configuration_url,
6166
identifiers={(DOMAIN, device_id)},
6267
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),
68+
manufacturer=self.device.get(VENDOR),
69+
model=self.device.get(MODEL),
70+
model_id=self.device.get(MODEL_ID),
71+
name=api.smile.name,
72+
sw_version=self.device.get(FIRMWARE),
73+
hw_version=self.device.get(HARDWARE),
6974
)
7075

71-
if device_id != coordinator.api.gateway_id:
76+
# Add extra info if not the gateway device
77+
if device_id != gateway_id:
7278
self._attr_device_info.update(
7379
{
74-
ATTR_NAME: data.get(ATTR_NAME),
75-
ATTR_VIA_DEVICE: (
76-
DOMAIN,
77-
str(self.coordinator.api.gateway_id),
78-
),
80+
ATTR_NAME: self.device.get(ATTR_NAME),
81+
ATTR_VIA_DEVICE: (DOMAIN, gateway_id),
7982
}
8083
)
8184

custom_components/plugwise/select.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class PlugwiseSelectEntityDescription(SelectEntityDescription):
4747
PlugwiseSelectEntityDescription(
4848
key=SELECT_SCHEDULE,
4949
translation_key=SELECT_SCHEDULE,
50-
entity_category=EntityCategory.CONFIG,
5150
options_key=AVAILABLE_SCHEDULES,
5251
),
5352
PlugwiseSelectEntityDescription(

0 commit comments

Comments
 (0)