Strictly type Twente Milieu integration (#50062)

This commit is contained in:
Franck Nijhof 2021-05-06 07:04:09 +02:00 committed by GitHub
parent af832e5434
commit e3e9239798
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 15 deletions

View file

@ -12,7 +12,7 @@ from twentemilieu import (
from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_ID
from homeassistant.const import ATTR_IDENTIFIERS, ATTR_MANUFACTURER, ATTR_NAME, CONF_ID
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import PlatformNotReady
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -89,7 +89,6 @@ class TwenteMilieuSensor(SensorEntity):
self._name = name
self._twentemilieu = twentemilieu
self._waste_type = waste_type
self._unsub_dispatcher = None
self._state = None
@ -120,14 +119,12 @@ class TwenteMilieuSensor(SensorEntity):
async def async_added_to_hass(self) -> None:
"""Connect to dispatcher listening for entity data notifications."""
self._unsub_dispatcher = async_dispatcher_connect(
self.hass, DATA_UPDATE, self._schedule_immediate_update
self.async_on_remove(
async_dispatcher_connect(
self.hass, DATA_UPDATE, self._schedule_immediate_update
)
)
async def async_will_remove_from_hass(self) -> None:
"""Disconnect from update signal."""
self._unsub_dispatcher()
@callback
def _schedule_immediate_update(self, unique_id: str) -> None:
"""Schedule an immediate update of the entity."""
@ -149,7 +146,7 @@ class TwenteMilieuSensor(SensorEntity):
def device_info(self) -> DeviceInfo:
"""Return device information about Twente Milieu."""
return {
"identifiers": {(DOMAIN, self._unique_id)},
"name": "Twente Milieu",
"manufacturer": "Twente Milieu",
ATTR_IDENTIFIERS: {(DOMAIN, self._unique_id)},
ATTR_NAME: "Twente Milieu",
ATTR_MANUFACTURER: "Twente Milieu",
}