mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Cleanup code for UptimeRobot (#154892)
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from pyuptimerobot import (
|
||||
UptimeRobot,
|
||||
UptimeRobotAuthenticationException,
|
||||
@@ -51,7 +53,12 @@ class UptimeRobotDataUpdateCoordinator(DataUpdateCoordinator[list[UptimeRobotMon
|
||||
raise UpdateFailed(exception) from exception
|
||||
|
||||
if response.status != API_ATTR_OK:
|
||||
raise UpdateFailed(response.error.message)
|
||||
raise UpdateFailed(
|
||||
response.error.message if response.error else "Unknown error"
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
assert isinstance(response.data, list)
|
||||
|
||||
monitors: list[UptimeRobotMonitor] = response.data
|
||||
|
||||
@@ -70,11 +77,4 @@ class UptimeRobotDataUpdateCoordinator(DataUpdateCoordinator[list[UptimeRobotMon
|
||||
remove_config_entry_id=self.config_entry.entry_id,
|
||||
)
|
||||
|
||||
# If there are new monitors, we should reload the config entry so we can
|
||||
# create new devices and entities.
|
||||
if self.data and new_monitors - current_monitors:
|
||||
self.hass.async_create_task(
|
||||
self.hass.config_entries.async_reload(self.config_entry.entry_id)
|
||||
)
|
||||
|
||||
return monitors
|
||||
|
||||
Reference in New Issue
Block a user