Skip to content

Commit 080b16a

Browse files
authored
Cleanup code for UptimeRobot (#154892)
1 parent 6a1cf98 commit 080b16a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

homeassistant/components/uptimerobot/coordinator.py

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

33
from __future__ import annotations
44

5+
from typing import TYPE_CHECKING
6+
57
from pyuptimerobot import (
68
UptimeRobot,
79
UptimeRobotAuthenticationException,
@@ -51,7 +53,12 @@ async def _async_update_data(self) -> list[UptimeRobotMonitor]:
5153
raise UpdateFailed(exception) from exception
5254

5355
if response.status != API_ATTR_OK:
54-
raise UpdateFailed(response.error.message)
56+
raise UpdateFailed(
57+
response.error.message if response.error else "Unknown error"
58+
)
59+
60+
if TYPE_CHECKING:
61+
assert isinstance(response.data, list)
5562

5663
monitors: list[UptimeRobotMonitor] = response.data
5764

@@ -70,11 +77,4 @@ async def _async_update_data(self) -> list[UptimeRobotMonitor]:
7077
remove_config_entry_id=self.config_entry.entry_id,
7178
)
7279

73-
# If there are new monitors, we should reload the config entry so we can
74-
# create new devices and entities.
75-
if self.data and new_monitors - current_monitors:
76-
self.hass.async_create_task(
77-
self.hass.config_entries.async_reload(self.config_entry.entry_id)
78-
)
79-
8080
return monitors

0 commit comments

Comments
 (0)