mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Improve type hints in fireservicerota (#137628)
This commit is contained in:
parent
4323968222
commit
f06d209b2d
@ -54,7 +54,9 @@ class FireServiceUpdateCoordinator(DataUpdateCoordinator[dict | None]):
|
||||
class FireServiceRotaOauth:
|
||||
"""Handle authentication tokens."""
|
||||
|
||||
def __init__(self, hass, entry, fsr):
|
||||
def __init__(
|
||||
self, hass: HomeAssistant, entry: ConfigEntry, fsr: FireServiceRota
|
||||
) -> None:
|
||||
"""Initialize the oauth object."""
|
||||
self._hass = hass
|
||||
self._entry = entry
|
||||
@ -94,7 +96,7 @@ class FireServiceRotaOauth:
|
||||
class FireServiceRotaWebSocket:
|
||||
"""Define a FireServiceRota websocket manager object."""
|
||||
|
||||
def __init__(self, hass, entry):
|
||||
def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||
"""Initialize the websocket object."""
|
||||
self._hass = hass
|
||||
self._entry = entry
|
||||
@ -128,7 +130,7 @@ class FireServiceRotaWebSocket:
|
||||
class FireServiceRotaClient:
|
||||
"""Getting the latest data from fireservicerota."""
|
||||
|
||||
def __init__(self, hass, entry):
|
||||
def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||
"""Initialize the data object."""
|
||||
self._hass = hass
|
||||
self._entry = entry
|
||||
|
@ -11,6 +11,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
|
||||
from .const import DATA_CLIENT, DOMAIN as FIRESERVICEROTA_DOMAIN
|
||||
from .coordinator import FireServiceRotaClient
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -32,13 +33,13 @@ class IncidentsSensor(RestoreEntity, SensorEntity):
|
||||
_attr_has_entity_name = True
|
||||
_attr_translation_key = "incidents"
|
||||
|
||||
def __init__(self, client):
|
||||
def __init__(self, client: FireServiceRotaClient) -> None:
|
||||
"""Initialize."""
|
||||
self._client = client
|
||||
self._entry_id = self._client.entry_id
|
||||
self._attr_unique_id = f"{self._client.unique_id}_Incidents"
|
||||
self._state = None
|
||||
self._state_attributes = {}
|
||||
self._state: str | None = None
|
||||
self._state_attributes: dict[str, Any] = {}
|
||||
|
||||
@property
|
||||
def icon(self) -> str:
|
||||
@ -52,7 +53,7 @@ class IncidentsSensor(RestoreEntity, SensorEntity):
|
||||
return "mdi:fire-truck"
|
||||
|
||||
@property
|
||||
def native_value(self) -> str:
|
||||
def native_value(self) -> str | None:
|
||||
"""Return the state of the sensor."""
|
||||
return self._state
|
||||
|
||||
|
@ -10,6 +10,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DATA_CLIENT, DATA_COORDINATOR, DOMAIN as FIRESERVICEROTA_DOMAIN
|
||||
from .coordinator import FireServiceRotaClient, FireServiceUpdateCoordinator
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -32,15 +33,20 @@ class ResponseSwitch(SwitchEntity):
|
||||
_attr_has_entity_name = True
|
||||
_attr_translation_key = "incident_response"
|
||||
|
||||
def __init__(self, coordinator, client, entry):
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: FireServiceUpdateCoordinator,
|
||||
client: FireServiceRotaClient,
|
||||
entry: ConfigEntry,
|
||||
) -> None:
|
||||
"""Initialize."""
|
||||
self._coordinator = coordinator
|
||||
self._client = client
|
||||
self._attr_unique_id = f"{entry.unique_id}_Response"
|
||||
self._entry_id = entry.entry_id
|
||||
|
||||
self._state = None
|
||||
self._state_attributes = {}
|
||||
self._state: bool | None = None
|
||||
self._state_attributes: dict[str, Any] = {}
|
||||
self._state_icon = None
|
||||
|
||||
@property
|
||||
@ -54,7 +60,7 @@ class ResponseSwitch(SwitchEntity):
|
||||
return "mdi:forum"
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
def is_on(self) -> bool | None:
|
||||
"""Get the assumed state of the switch."""
|
||||
return self._state
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user