Add cleanup to OpenUV (#32886)

* Add cleanup to OpenUV

* Linting
This commit is contained in:
Aaron Bach authored and GitHub committed 2020-03-17 22:03:16 -05:00
1 parent f02c5f66d6
commit 609263e1bb
3 files changed
+35 -42

No files matched your search

+2 -20
View File
@@ -3,14 +3,12 @@ import logging
from homeassistant.const import TIME_MINUTES
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.util.dt import as_local, parse_datetime
from . import (
DATA_OPENUV_CLIENT,
DATA_UV,
DOMAIN,
TOPIC_UPDATE,
TYPE_CURRENT_OZONE_LEVEL,
TYPE_CURRENT_UV_INDEX,
TYPE_CURRENT_UV_LEVEL,
@@ -135,24 +133,8 @@ class OpenUvSensor(OpenUvEntity):
"""Return the unit the value is expressed in."""
return self._unit
async def async_added_to_hass(self):
"""Register callbacks."""
@callback
def update():
"""Update the state."""
self.async_schedule_update_ha_state(True)
self._async_unsub_dispatcher_connect = async_dispatcher_connect(
self.hass, TOPIC_UPDATE, update
)
async def async_will_remove_from_hass(self):
"""Disconnect dispatcher listener when removed."""
if self._async_unsub_dispatcher_connect:
self._async_unsub_dispatcher_connect()
async def async_update(self):
@callback
def update_from_latest_data(self):
"""Update the state."""
data = self.openuv.data[DATA_UV].get("result")