Remove monitored conditions from OpenUV (#31019)

* Remove monitored conditions from OpenUV

* Code review comments
This commit is contained in:
Aaron Bach 2020-01-22 18:48:20 -07:00 committed by Paulus Schoutsen
parent 80887d757a
commit 288574b8d1
4 changed files with 80 additions and 102 deletions

View file

@ -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)