Skip to content

Commit 771f99c

Browse files
authored
Merge pull request #45 from plugwise/requestfix
Requestfix counterpart
2 parents eeb3fa3 + bc9b85e commit 771f99c

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

custom_components/plugwise-beta/__init__.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from homeassistant.config_entries import ConfigEntry
1010
from homeassistant.core import HomeAssistant, callback
11+
from homeassistant.exceptions import PlatformNotReady
1112
from homeassistant.helpers import device_registry as dr
1213
from homeassistant.helpers.aiohttp_client import async_get_clientsession
1314
from homeassistant.helpers.event import async_track_time_interval
@@ -36,9 +37,19 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
3637
)
3738

3839
try:
39-
await api.connect()
40+
connected = await api.connect()
41+
42+
if not connected:
43+
_LOGGER.error("Unable to connect to Smile: %s",api.smile_status)
44+
raise PlatformNotReady
45+
46+
except Smile.PlugwiseError:
47+
_LOGGER.error("Error while communicating to device")
48+
raise PlatformNotReady
49+
4050
except asyncio.TimeoutError:
4151
_LOGGER.error("Timeout while connecting to Smile")
52+
raise PlatformNotReady
4253

4354
if api.smile_type == "power":
4455
update_interval = timedelta(seconds=10)
@@ -47,7 +58,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
4758

4859
api.get_all_devices()
4960

50-
_LOGGER.debug("Plugwise async update interval %s", update_interval)
61+
_LOGGER.debug("Async update interval %s", update_interval)
5162

5263
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = {
5364
"api": api,
@@ -56,7 +67,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
5667
),
5768
}
5869

59-
_LOGGER.debug("Plugwise gateway is %s", api.gateway_id)
70+
_LOGGER.debug("Gateway is %s", api.gateway_id)
6071
device_registry = await dr.async_get_registry(hass)
6172
device_registry.async_get_or_create(
6273
config_entry_id=entry.entry_id,
@@ -66,7 +77,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
6677
model=f"Smile {api.smile_name}",
6778
sw_version=api.smile_version[0],
6879
)
69-
_LOGGER.debug("Plugwise device registry %s", result)
7080

7181
single_master_thermostat = api.single_master_thermostat()
7282
_LOGGER.debug("Single master thermostat = %s", single_master_thermostat)
@@ -148,14 +158,18 @@ def async_remove_listener(self, update_callback):
148158

149159
async def async_refresh_all(self, _now: Optional[int] = None) -> None:
150160
"""Time to update."""
151-
_LOGGER.debug("Plugwise Smile updating with interval: %s", self.update_interval)
161+
_LOGGER.debug("Smile updating with interval: %s", self.update_interval)
152162
if not self.listeners:
153-
_LOGGER.error("Plugwise Smile has no listeners, not updating")
163+
_LOGGER.error("Smile has no listeners, not updating")
154164
return
155165

156-
_LOGGER.debug("Plugwise Smile updating data using: %s", self.update_method)
166+
_LOGGER.debug("Smile updating data using: %s", self.update_method)
157167

158-
await self.api.full_update_device()
168+
try:
169+
await self.api.full_update_device()
170+
except Smile.XMLDataMissingError as e:
171+
_LOGGER.error("Smile update failed")
172+
raise e
159173

160174
for update_callback in self.listeners:
161175
update_callback()

custom_components/plugwise-beta/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"domain": "plugwise-beta",
33
"name": "Plugwise Beta for Home Assistant",
44
"documentation": "https://github.com/plugwise/plugwise-beta",
5-
"requirements": ["Plugwise_Smile==0.1.23"],
5+
"requirements": ["Plugwise_Smile==0.1.24"],
66
"dependencies": [],
77
"codeowners": ["@CoMPaTech","@bouwew"],
88
"config_flow": true

custom_components/plugwise-beta/strings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"config": {
3-
"title": "Plugwise Smile beta",
43
"step": {
54
"user": {
65
"title": "Connect to the device",

custom_components/plugwise-beta/.translations/en.json renamed to custom_components/plugwise-beta/translations/en.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"config": {
3-
"title": "Plugwise Smile beta",
43
"step": {
54
"user": {
65
"title": "Connect to the device",

custom_components/plugwise-beta/.translations/nl.json renamed to custom_components/plugwise-beta/translations/nl.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"config": {
3-
"title": "Plugwise Smile beta",
43
"step": {
54
"user": {
65
"title": "Verbinden met de Smile",

0 commit comments

Comments
 (0)