Add switch platform to UptimeRobot (#65394)

* Add switch platfor mto UptimeRobot

* Add tests

* Apply review comment

* review comments part 2

* review comments part 3

* Fix tests after swapping logic on/off

* Fix reauth test

* Check for read-only key

* Fix reauth for switch platform

* mypy

* cleanup

* cleanup part 2

* Fixes + review comments

* Tests

* Apply more review comments

* Required changes

* fix test

* Remove if

* 100% tests coverage

* Check readonly key in config_flow

* Fix strings & translation

* Add guard for 'monitor' keys

* allign tests

* Wrong API key message reworded
This commit is contained in:
Simone Chemelli 2022-03-18 12:18:19 +01:00 committed by GitHub
parent 5bb271c9fb
commit 35261a9089
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 357 additions and 42 deletions

View file

@ -23,18 +23,16 @@ async def async_setup_entry(
"""Set up the UptimeRobot binary_sensors."""
coordinator: UptimeRobotDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
async_add_entities(
[
UptimeRobotBinarySensor(
coordinator,
BinarySensorEntityDescription(
key=str(monitor.id),
name=monitor.friendly_name,
device_class=BinarySensorDeviceClass.CONNECTIVITY,
),
monitor=monitor,
)
for monitor in coordinator.data
],
UptimeRobotBinarySensor(
coordinator,
BinarySensorEntityDescription(
key=str(monitor.id),
name=monitor.friendly_name,
device_class=BinarySensorDeviceClass.CONNECTIVITY,
),
monitor=monitor,
)
for monitor in coordinator.data
)