Remove monitored conditions from OpenUV (#31019)

* Remove monitored conditions from OpenUV

* Code review comments
This commit is contained in:
Aaron Bach authored and Paulus Schoutsen committed 2020-01-22 17:48:20 -08:00
1 parent 80887d757a
commit 288574b8d1
4 files changed
+80 -102

No files matched your search

@@ -7,7 +7,6 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.util.dt import as_local, parse_datetime, utcnow
from . import (
BINARY_SENSORS,
DATA_OPENUV_CLIENT,
DATA_PROTECTION_WINDOW,
DOMAIN,
@@ -17,21 +16,24 @@ from . import (
)
_LOGGER = logging.getLogger(__name__)
ATTR_PROTECTION_WINDOW_ENDING_TIME = "end_time"
ATTR_PROTECTION_WINDOW_ENDING_UV = "end_uv"
ATTR_PROTECTION_WINDOW_STARTING_TIME = "start_time"
ATTR_PROTECTION_WINDOW_STARTING_UV = "start_uv"
BINARY_SENSORS = {TYPE_PROTECTION_WINDOW: ("Protection Window", "mdi:sunglasses")}
async def async_setup_entry(hass, entry, async_add_entities):
"""Set up an OpenUV sensor based on a config entry."""
openuv = hass.data[DOMAIN][DATA_OPENUV_CLIENT][entry.entry_id]
binary_sensors = []
for sensor_type in openuv.binary_sensor_conditions:
name, icon = BINARY_SENSORS[sensor_type]
for kind, attrs in BINARY_SENSORS.items():
name, icon = attrs
binary_sensors.append(
OpenUvBinarySensor(openuv, sensor_type, name, icon, entry.entry_id)
OpenUvBinarySensor(openuv, kind, name, icon, entry.entry_id)
)
async_add_entities(binary_sensors, True)