Fix typing for wemo (#62157)

This commit is contained in:
Eric Severance 2021-12-19 16:09:30 -08:00 committed by GitHub
parent 7919960570
commit 1318597370
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 207 additions and 122 deletions

View file

@ -4,16 +4,24 @@ import asyncio
from pywemo import Insight, Maker
from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN as WEMO_DOMAIN
from .entity import WemoEntity
from .wemo_device import DeviceCoordinator
async def async_setup_entry(hass, config_entry, async_add_entities):
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up WeMo binary sensors."""
async def _discovered_wemo(coordinator):
async def _discovered_wemo(coordinator: DeviceCoordinator) -> None:
"""Handle a discovered Wemo device."""
if isinstance(coordinator.wemo, Insight):
async_add_entities([InsightBinarySensor(coordinator)])
@ -38,7 +46,7 @@ class WemoBinarySensor(WemoEntity, BinarySensorEntity):
@property
def is_on(self) -> bool:
"""Return true if the state is on. Standby is on."""
return self.wemo.get_state()
return bool(self.wemo.get_state())
class MakerBinarySensor(WemoEntity, BinarySensorEntity):
@ -49,7 +57,7 @@ class MakerBinarySensor(WemoEntity, BinarySensorEntity):
@property
def is_on(self) -> bool:
"""Return true if the Maker's sensor is pulled low."""
return self.wemo.has_sensor and self.wemo.sensor_state == 0
return bool(self.wemo.has_sensor) and self.wemo.sensor_state == 0
class InsightBinarySensor(WemoBinarySensor):