Fix type issues [fireservicerota] (#67094)

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
Marc Mueller 2022-02-23 11:53:02 +01:00 committed by GitHub
parent 0e54bd448a
commit 4fecd5d8af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 31 deletions

View file

@ -1,4 +1,8 @@
"""Binary Sensor platform for FireServiceRota integration."""
from __future__ import annotations
from typing import Any
from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
@ -8,6 +12,7 @@ from homeassistant.helpers.update_coordinator import (
DataUpdateCoordinator,
)
from . import FireServiceRotaClient
from .const import DATA_CLIENT, DATA_COORDINATOR, DOMAIN as FIRESERVICEROTA_DOMAIN
@ -16,7 +21,9 @@ async def async_setup_entry(
) -> None:
"""Set up FireServiceRota binary sensor based on a config entry."""
client = hass.data[FIRESERVICEROTA_DOMAIN][entry.entry_id][DATA_CLIENT]
client: FireServiceRotaClient = hass.data[FIRESERVICEROTA_DOMAIN][entry.entry_id][
DATA_CLIENT
]
coordinator: DataUpdateCoordinator = hass.data[FIRESERVICEROTA_DOMAIN][
entry.entry_id
@ -28,13 +35,18 @@ async def async_setup_entry(
class ResponseBinarySensor(CoordinatorEntity, BinarySensorEntity):
"""Representation of an FireServiceRota sensor."""
def __init__(self, coordinator: DataUpdateCoordinator, client, entry):
def __init__(
self,
coordinator: DataUpdateCoordinator,
client: FireServiceRotaClient,
entry: ConfigEntry,
) -> None:
"""Initialize."""
super().__init__(coordinator)
self._client = client
self._unique_id = f"{entry.unique_id}_Duty"
self._state = None
self._state: bool | None = None
@property
def name(self) -> str:
@ -55,7 +67,7 @@ class ResponseBinarySensor(CoordinatorEntity, BinarySensorEntity):
return self._unique_id
@property
def is_on(self) -> bool:
def is_on(self) -> bool | None:
"""Return the state of the binary sensor."""
self._state = self._client.on_duty
@ -63,9 +75,9 @@ class ResponseBinarySensor(CoordinatorEntity, BinarySensorEntity):
return self._state
@property
def extra_state_attributes(self):
def extra_state_attributes(self) -> dict[str, Any]:
"""Return available attributes for binary sensor."""
attr = {}
attr: dict[str, Any] = {}
if not self.coordinator.data:
return attr