Skip to content

Commit a6c4579

Browse files
authored
Merge pull request #195 from plugwise/asynx-fixes
Various fixes to make testing pass in async-branch
2 parents f505ead + a434fe1 commit a6c4579

File tree

13 files changed

+66
-83
lines changed

13 files changed

+66
-83
lines changed

custom_components/plugwise_usb/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@
1111
from plugwise_usb.api import NodeEvent
1212
from plugwise_usb.exceptions import StickError
1313

14-
from .const import (
15-
CONF_USB_PATH,
16-
DOMAIN,
17-
NODES,
18-
PLUGWISE_USB_PLATFORMS,
19-
STICK,
20-
)
14+
from .const import CONF_USB_PATH, NODES, PLUGWISE_USB_PLATFORMS, STICK
2115
from .coordinator import PlugwiseUSBDataUpdateCoordinator
2216

2317
_LOGGER = logging.getLogger(__name__)

custom_components/plugwise_usb/binary_sensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from homeassistant.helpers.entity_platform import AddEntitiesCallback
1717
from plugwise_usb.api import NodeEvent, NodeFeature
1818

19-
from .const import DOMAIN, NODES, STICK, UNSUB_NODE_LOADED
19+
from .const import NODES, STICK, UNSUB_NODE_LOADED
2020
from .entity import PlugwiseUSBEntity, PlugwiseUSBEntityDescription
2121

2222
_LOGGER = logging.getLogger(__name__)

custom_components/plugwise_usb/config_flow.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@
2020
@callback
2121
def plugwise_stick_entries(hass):
2222
"""Return existing connections for Plugwise USB-stick domain."""
23-
sticks = []
24-
for entry in hass.config_entries.async_entries(DOMAIN):
25-
sticks.append(entry.data.get(CONF_USB_PATH))
26-
return sticks
23+
24+
return [entry.data.get(CONF_USB_PATH) for entry in hass.config_entries.async_entries(DOMAIN)]
2725

2826

2927
async def validate_usb_connection(
@@ -114,9 +112,7 @@ async def async_step_manual_path(
114112
step_id="manual_path",
115113
data_schema=vol.Schema(
116114
{
117-
vol.Required(
118-
CONF_USB_PATH, default="/dev/ttyUSB0" or vol.UNDEFINED
119-
): str
115+
vol.Required(CONF_USB_PATH, default="/dev/ttyUSB0"): str
120116
}
121117
),
122118
errors=errors,

custom_components/plugwise_usb/coordinator.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
"""DataUpdateCoordinator for Plugwise USB-Stick."""
2-
3-
import asyncio
42
from collections import Counter
53
from datetime import timedelta
64
import logging
@@ -53,7 +51,7 @@ def __init__(
5351
async def async_node_update(self) -> dict[NodeFeature, Any]:
5452
"""Request status update for Plugwise Node."""
5553
states: dict[NodeFeature, Any] = {}
56-
54+
5755
# Only unique features
5856
freq_features = Counter(self.async_contexts())
5957
features = tuple(freq_features.keys())
@@ -63,7 +61,7 @@ async def async_node_update(self) -> dict[NodeFeature, Any]:
6361
except StickError as err:
6462
raise ConfigEntryError from err
6563
except (StickTimeout, NodeTimeout) as err:
66-
raise asyncio.TimeoutError from err
64+
raise TimeoutError from err
6765
except NodeError as err:
6866
raise UpdateFailed from err
6967

custom_components/plugwise_usb/entity.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
from collections.abc import Callable
55
from dataclasses import dataclass
66
import logging
7+
from typing import Any
78

89
from homeassistant.helpers.entity import EntityDescription
9-
from homeassistant.helpers.update_coordinator import (
10-
CoordinatorEntity,
11-
)
10+
from homeassistant.helpers.update_coordinator import CoordinatorEntity
1211
from plugwise_usb.api import PUSHING_FEATURES, NodeFeature, NodeInfo
1312

1413
from .const import DOMAIN

custom_components/plugwise_usb/sensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from homeassistant.helpers.entity_platform import AddEntitiesCallback
2727
from plugwise_usb.api import NodeEvent, NodeFeature
2828

29-
from .const import DOMAIN, NODES, STICK, UNSUB_NODE_LOADED
29+
from .const import NODES, STICK, UNSUB_NODE_LOADED
3030
from .entity import PlugwiseUSBEntity, PlugwiseUSBEntityDescription
3131

3232
_LOGGER = logging.getLogger(__name__)

custom_components/plugwise_usb/strings.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
}
1616
},
1717
"error": {
18+
"already_configured": "This device is already configured",
1819
"cannot_connect": "Failed to connect",
1920
"network_down": "Plugwise Zigbee network is down",
2021
"network_timeout": "Network communication timeout",
2122
"stick_init": "Initialization of Plugwise USB-stick failed"
22-
},
23-
"abort": {
24-
"already_configured": "This device is already configured"
2523
}
2624
},
2725
"services": {

custom_components/plugwise_usb/switch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from homeassistant.helpers.entity_platform import AddEntitiesCallback
1717
from plugwise_usb.api import NodeEvent, NodeFeature
1818

19-
from .const import DOMAIN, NODES, STICK, UNSUB_NODE_LOADED
19+
from .const import NODES, STICK, UNSUB_NODE_LOADED
2020
from .coordinator import PlugwiseUSBDataUpdateCoordinator
2121
from .entity import PlugwiseUSBEntity, PlugwiseUSBEntityDescription
2222

custom_components/plugwise_usb/translations/en.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
}
1616
},
1717
"error": {
18+
"already_configured": "This device is already configured",
1819
"cannot_connect": "Failed to connect",
1920
"network_down": "Plugwise Zigbee network is down",
2021
"network_timeout": "Network communication timeout",
2122
"stick_init": "Initialization of Plugwise USB-stick failed"
22-
},
23-
"abort": {
24-
"already_configured": "This device is already configured"
2523
}
2624
},
2725
"services": {

custom_components/plugwise_usb/translations/nl.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
}
1616
},
1717
"error": {
18+
"already_configured": "Dit apparaat is al geconfigureerd",
1819
"cannot_connect": "Verbinden is mislukt",
1920
"network_down": "Plugwise Zigbee netwerk is onbereikbaar",
2021
"network_timeout": "Network communicatie timeout",
2122
"stick_init": "Initaliseren van USB-stick mislukt"
22-
},
23-
"abort": {
24-
"already_configured": "Dit apparaat is al geconfigureerd"
2523
}
2624
},
2725
"services": {

0 commit comments

Comments
 (0)