parent
26b951194c
commit
f561533d2c
|
@ -2,7 +2,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from greeneye import Monitors
|
||||
import voluptuous as vol
|
||||
|
@ -18,7 +17,7 @@ from homeassistant.const import (
|
|||
TIME_MINUTES,
|
||||
TIME_SECONDS,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.core import Event, HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.discovery import async_load_platform
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
@ -130,7 +129,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||
server_config = config[DOMAIN]
|
||||
server = await monitors.start_server(server_config[CONF_PORT])
|
||||
|
||||
async def close_server(*args: list[Any]) -> None:
|
||||
async def close_server(event: Event) -> None:
|
||||
"""Close the monitoring server."""
|
||||
await server.close()
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Support for the sensors in a GreenEye Monitor."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Generic, TypeVar
|
||||
from typing import Any, Generic, Optional, TypeVar, cast
|
||||
|
||||
import greeneye
|
||||
from greeneye import Monitors
|
||||
|
@ -140,7 +140,7 @@ class GEMSensor(Generic[T], SensorEntity):
|
|||
if not self._try_connect_to_monitor(monitors):
|
||||
monitors.add_listener(self._on_new_monitor)
|
||||
|
||||
def _on_new_monitor(self, *args: list[Any]) -> None:
|
||||
def _on_new_monitor(self, monitor: greeneye.monitor.Monitor) -> None:
|
||||
monitors = self.hass.data[DATA_GREENEYE_MONITOR]
|
||||
if self._try_connect_to_monitor(monitors):
|
||||
monitors.remove_listener(self._on_new_monitor)
|
||||
|
@ -192,8 +192,7 @@ class CurrentSensor(GEMSensor[greeneye.monitor.Channel]):
|
|||
if not self._sensor:
|
||||
return None
|
||||
|
||||
assert isinstance(self._sensor.watts, float)
|
||||
return self._sensor.watts
|
||||
return cast(Optional[float], self._sensor.watts)
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict[str, Any] | None:
|
||||
|
@ -245,8 +244,7 @@ class PulseCounter(GEMSensor[greeneye.monitor.PulseCounter]):
|
|||
* self._counted_quantity_per_pulse
|
||||
* self._seconds_per_time_unit
|
||||
)
|
||||
assert isinstance(result, float)
|
||||
return result
|
||||
return cast(float, result)
|
||||
|
||||
@property
|
||||
def _seconds_per_time_unit(self) -> int:
|
||||
|
@ -301,8 +299,7 @@ class TemperatureSensor(GEMSensor[greeneye.monitor.TemperatureSensor]):
|
|||
if not self._sensor:
|
||||
return None
|
||||
|
||||
assert isinstance(self._sensor.temperature, float)
|
||||
return self._sensor.temperature
|
||||
return cast(Optional[float], self._sensor.temperature)
|
||||
|
||||
@property
|
||||
def native_unit_of_measurement(self) -> str:
|
||||
|
@ -332,5 +329,4 @@ class VoltageSensor(GEMSensor[greeneye.monitor.Monitor]):
|
|||
if not self._sensor:
|
||||
return None
|
||||
|
||||
assert isinstance(self._sensor.voltage, float)
|
||||
return self._sensor.voltage
|
||||
return cast(Optional[float], self._sensor.voltage)
|
||||
|
|
Loading…
Reference in New Issue