Skip to content

Commit e41d356

Browse files
authored
Merge pull request #319 from plugwise/platform-logging
Improve platform logging, available logging, try fix button availability
2 parents 78c7a7d + 628f6a8 commit e41d356

12 files changed

Lines changed: 97 additions & 84 deletions

File tree

CHANGELOG.md

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

33
## Versions from 0.4x
44

5+
### v0.55.10 - 2025-08-29
6+
7+
- Final fix for unavailable buttons via plugwise_usb [v0.44.13](https://github.com/plugwise/python-plugwise-usb/releases/tag/v0.44.13)
8+
- Add debug-logging per platform and per entity
9+
510
### v0.55.9 - 2025-08-25
611

712
- Add select for Scan sensitivity
813
- Add button for Scan light calibration
914
- Fix disabled buttons for all non-plus devices
1015
- Shorten/correct logger-messages to use `node_duc.node.name`
16+
- Link to plugwise_usb [v0.44.12](https://github.com/plugwise/python-plugwise-usb/releases/tag/v0.44.12)
1117

1218
### v0.55.8 - 2025-08-15
1319

custom_components/plugwise_usb/binary_sensor.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,16 @@ async def async_add_binary_sensor(node_event: NodeEvent, mac: str) -> None:
7777
return
7878
entities: list[PlugwiseUSBEntity] = []
7979
if (node_duc := config_entry.runtime_data[NODES].get(mac)) is not None:
80-
_LOGGER.debug(
81-
"Add binary_sensor entities for node %s", node_duc.node.name
82-
)
83-
entities.extend(
84-
[
85-
PlugwiseUSBBinarySensor(node_duc, entity_description)
86-
for entity_description in BINARY_SENSOR_TYPES
87-
if entity_description.node_feature in node_duc.node.features
88-
]
89-
)
80+
for entity_description in BINARY_SENSOR_TYPES:
81+
if entity_description.node_feature not in node_duc.node.features:
82+
continue
83+
entities.append(PlugwiseUSBBinarySensor(node_duc, entity_description))
84+
_LOGGER.debug(
85+
"Add %s binary sensor for node %s",
86+
entity_description.translation_key,
87+
node_duc.node.name,
88+
)
89+
9090
if entities:
9191
async_add_entities(entities)
9292

@@ -105,7 +105,8 @@ async def async_add_binary_sensor(node_event: NodeEvent, mac: str) -> None:
105105
for mac, node in api_stick.nodes.items():
106106
if node.is_loaded:
107107
await async_add_binary_sensor(NodeEvent.LOADED, mac)
108-
108+
else:
109+
_LOGGER.debug("Adding binary_sensor(s) for node %s failed, not loaded", mac)
109110

110111
async def async_unload_entry(
111112
_hass: HomeAssistant,

custom_components/plugwise_usb/button.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
1212
from homeassistant.const import EntityCategory, Platform
13-
from homeassistant.core import HomeAssistant, callback
13+
from homeassistant.core import HomeAssistant
1414
from homeassistant.helpers.entity_platform import AddEntitiesCallback
1515

1616
from .const import NODES, STICK, UNSUB_NODE_LOADED
@@ -58,7 +58,7 @@ class PlugwiseButtonEntityDescription(
5858
translation_key="calibrate_light",
5959
entity_category=EntityCategory.CONFIG,
6060
async_button_fn="scan_calibrate_light",
61-
node_feature=NodeFeature.MOTION,
61+
node_feature=NodeFeature.MOTION_CONFIG,
6262
),
6363
)
6464

@@ -76,14 +76,15 @@ async def async_add_button(node_event: NodeEvent, mac: str) -> None:
7676
return
7777
entities: list[PlugwiseUSBEntity] = []
7878
if (node_duc := config_entry.runtime_data[NODES].get(mac)) is not None:
79-
_LOGGER.debug("Add button entities for node %s", node_duc.node.name)
80-
entities.extend(
81-
[
82-
PlugwiseUSBButtonEntity(node_duc, entity_description)
83-
for entity_description in BUTTON_TYPES
84-
if entity_description.node_feature in node_duc.node.features
85-
]
86-
)
79+
for entity_description in BUTTON_TYPES:
80+
if entity_description.node_feature not in node_duc.node.features:
81+
continue
82+
entities.append(PlugwiseUSBButtonEntity(node_duc, entity_description))
83+
_LOGGER.debug(
84+
"Add %s button for node %s",
85+
entity_description.translation_key,
86+
node_duc.node.name,
87+
)
8788
if entities:
8889
async_add_entities(entities)
8990

@@ -102,6 +103,8 @@ async def async_add_button(node_event: NodeEvent, mac: str) -> None:
102103
for mac, node in api_stick.nodes.items():
103104
if node.is_loaded:
104105
await async_add_button(NodeEvent.LOADED, mac)
106+
else:
107+
_LOGGER.debug("Adding button(s) for node %s failed, not loaded", mac)
105108

106109

107110
async def async_unload_entry(
@@ -126,13 +129,6 @@ def __init__(
126129
node_duc.node, entity_description.async_button_fn
127130
)
128131

129-
@callback
130-
def _handle_coordinator_update(self) -> None:
131-
"""Handle updated data from the coordinator."""
132-
133132
async def async_press(self) -> None:
134133
"""Button was pressed."""
135134
await self.async_button_fn()
136-
137-
async def async_added_to_hass(self):
138-
"""Subscribe for push updates."""

custom_components/plugwise_usb/const.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323
UNDO_UPDATE_LISTENER: Final[str] = "undo_update_listener"
2424

25-
PLUGWISE_USB_PLATFORMS: Final[list[str]] = [
25+
PLUGWISE_USB_PLATFORMS: Final[list[Platform]] = [
2626
Platform.BINARY_SENSOR,
27+
Platform.BUTTON,
28+
Platform.EVENT,
2729
Platform.NUMBER,
2830
Platform.SELECT,
2931
Platform.SENSOR,
3032
Platform.SWITCH,
31-
Platform.BUTTON,
32-
Platform.EVENT,
3333
]
3434
CONF_USB_PATH: Final[str] = "usb_path"
3535
SERVICE_DISABLE_PRODUCTION: Final[str] = "disable_production"

custom_components/plugwise_usb/entity.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ def __init__(
4545
@property
4646
def available(self) -> bool:
4747
"""Return if entity is available."""
48-
return self.node_duc.node.available and super().available
48+
available = self.node_duc.node.available and super().available
49+
_LOGGER.debug("Entity %s | available = %s", self.entity_description.key, available)
50+
return available
4951

5052
@property
5153
def device_info(self) -> DeviceInfo:

custom_components/plugwise_usb/event.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,15 @@ async def async_add_event(node_event: NodeEvent, mac: str) -> None:
8383
return
8484
entities: list[PlugwiseUSBEntity] = []
8585
if (node_duc := config_entry.runtime_data[NODES].get(mac)) is not None:
86-
_LOGGER.debug("Add event entities for node %s", node_duc.node.name)
87-
entities.extend(
88-
[
89-
PlugwiseUSBEventEntity(node_duc, entity_description)
90-
for entity_description in EVENT_TYPES
91-
if entity_description.node_feature in node_duc.node.features
92-
]
93-
)
86+
for entity_description in EVENT_TYPES:
87+
if entity_description.node_feature not in node_duc.node.features:
88+
continue
89+
entities.append(PlugwiseUSBEventEntity(node_duc, entity_description))
90+
_LOGGER.debug(
91+
"Add %s event for node %s",
92+
entity_description.translation_key,
93+
node_duc.node.name,
94+
)
9495
if entities:
9596
async_add_entities(entities)
9697

@@ -109,9 +110,11 @@ async def async_add_event(node_event: NodeEvent, mac: str) -> None:
109110
for mac, node in api_stick.nodes.items():
110111
if node.is_loaded:
111112
await async_add_event(NodeEvent.LOADED, mac)
112-
113+
else:
114+
_LOGGER.debug("Adding event(s) for node %s failed, not loaded", mac)
113115

114116
async def async_unload_entry(
117+
_hass: HomeAssistant,
115118
config_entry: PlugwiseUSBConfigEntry,
116119
) -> None:
117120
"""Unload a config entry."""

custom_components/plugwise_usb/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"integration_type": "hub",
99
"iot_class": "local_polling",
1010
"loggers": ["plugwise_usb"],
11-
"requirements": ["plugwise-usb==0.44.12"],
12-
"version": "0.55.9"
11+
"requirements": ["plugwise-usb==0.44.13"],
12+
"version": "0.55.10"
1313
}

custom_components/plugwise_usb/number.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,15 @@ async def async_add_number(node_event: NodeEvent, mac: str) -> None:
113113
return
114114
entities: list[PlugwiseUSBEntity] = []
115115
if (node_duc := config_entry.runtime_data[NODES].get(mac)) is not None:
116-
_LOGGER.debug("Add number entities for node %s", node_duc.node.name)
117-
entities.extend(
118-
[
119-
PlugwiseUSBNumberEntity(node_duc, entity_description)
120-
for entity_description in NUMBER_TYPES
121-
if entity_description.node_feature in node_duc.node.features
122-
]
123-
)
116+
for entity_description in NUMBER_TYPES:
117+
if entity_description.node_feature not in node_duc.node.features:
118+
continue
119+
entities.append(PlugwiseUSBNumberEntity(node_duc, entity_description))
120+
_LOGGER.debug(
121+
"Add %s number for node %s",
122+
entity_description.translation_key,
123+
node_duc.node.name,
124+
)
124125
if entities:
125126
async_add_entities(entities)
126127

@@ -139,9 +140,11 @@ async def async_add_number(node_event: NodeEvent, mac: str) -> None:
139140
for mac, node in api_stick.nodes.items():
140141
if node.is_loaded:
141142
await async_add_number(NodeEvent.LOADED, mac)
142-
143+
else:
144+
_LOGGER.debug("Adding number(s) for node %s failed, not loaded", mac)
143145

144146
async def async_unload_entry(
147+
_hass: HomeAssistant,
145148
config_entry: PlugwiseUSBConfigEntry,
146149
) -> None:
147150
"""Unload a config entry."""

custom_components/plugwise_usb/select.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@ async def async_add_select(node_event: NodeEvent, mac: str) -> None:
5757
return
5858
entities: list[PlugwiseUSBEntity] = []
5959
if (node_duc := config_entry.runtime_data[NODES].get(mac)) is not None:
60-
_LOGGER.debug("Add select entities for node %s", node_duc.node.name)
61-
entities.extend(
62-
[
63-
PlugwiseUSBSelectEntity(node_duc, entity_description)
64-
for entity_description in SELECT_TYPES
65-
if entity_description.node_feature in node_duc.node.features
66-
]
67-
)
60+
for entity_description in SELECT_TYPES:
61+
if entity_description.node_feature not in node_duc.node.features:
62+
continue
63+
entities.append(PlugwiseUSBSelectEntity(node_duc, entity_description))
64+
_LOGGER.debug(
65+
"Add %s select for node %s",
66+
entity_description.translation_key,
67+
node_duc.node.name,
68+
)
6869
if entities:
6970
async_add_entities(entities)
7071

@@ -83,7 +84,8 @@ async def async_add_select(node_event: NodeEvent, mac: str) -> None:
8384
for mac, node in api_stick.nodes.items():
8485
if node.is_loaded:
8586
await async_add_select(NodeEvent.LOADED, mac)
86-
87+
else:
88+
_LOGGER.debug("Adding select(s) for node %s failed, not loaded", mac)
8789

8890
async def async_unload_entry(
8991
_hass: HomeAssistant,

custom_components/plugwise_usb/sensor.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -172,22 +172,19 @@ async def async_setup_entry(
172172

173173
async def async_add_sensor(node_event: NodeEvent, mac: str) -> None:
174174
"""Initialize DUC for sensor."""
175-
_LOGGER.debug("async_add_sensor | %s | node_event=%s", mac, node_event)
176175
if node_event != NodeEvent.LOADED:
177176
return
178177
entities: list[PlugwiseUSBEntity] = []
179178
if (node_duc := config_entry.runtime_data[NODES].get(mac)) is not None:
180-
_LOGGER.debug("Add sensor entities for node %s", node_duc.node.name)
181-
entities.extend(
182-
[
183-
PlugwiseUSBSensorEntity(node_duc, entity_description)
184-
for entity_description in SENSOR_TYPES
185-
if entity_description.node_feature in node_duc.node.features
186-
]
187-
)
188-
else:
189-
_LOGGER.debug("async_add_sensor | %s | GET MAC FAILED", mac)
190-
179+
for entity_description in SENSOR_TYPES:
180+
if entity_description.node_feature not in node_duc.node.features:
181+
continue
182+
entities.append(PlugwiseUSBSensorEntity(node_duc, entity_description))
183+
_LOGGER.debug(
184+
"Add %s sensor for node %s",
185+
entity_description.translation_key,
186+
node_duc.node.name,
187+
)
191188
if entities:
192189
async_add_entities(entities)
193190

@@ -206,7 +203,8 @@ async def async_add_sensor(node_event: NodeEvent, mac: str) -> None:
206203
for mac, node in api_stick.nodes.items():
207204
if node.is_loaded:
208205
await async_add_sensor(NodeEvent.LOADED, mac)
209-
206+
else:
207+
_LOGGER.debug("Adding sensor(s) for node %s failed, not loaded", mac)
210208

211209
async def async_unload_entry(
212210
_hass: HomeAssistant,

0 commit comments

Comments
 (0)