Fix ecowitt typing (#78171)

This commit is contained in:
Paulus Schoutsen 2022-09-09 23:32:14 -04:00 committed by GitHub
parent 68b511737d
commit b2692ecc80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View File

@ -68,4 +68,4 @@ class EcowittBinarySensorEntity(EcowittEntity, BinarySensorEntity):
@property @property
def is_on(self) -> bool: def is_on(self) -> bool:
"""Return true if the binary sensor is on.""" """Return true if the binary sensor is on."""
return self.ecowitt.value > 0 return bool(self.ecowitt.value)

View File

@ -25,13 +25,13 @@ async def async_get_device_diagnostics(
"device": { "device": {
"name": station.station, "name": station.station,
"model": station.model, "model": station.model,
"frequency": station.frequency, "frequency": station.frequence,
"version": station.version, "version": station.version,
}, },
"raw": ecowitt.last_values[station_id], "raw": ecowitt.last_values[station_id],
"sensors": { "sensors": {
sensor.key: sensor.value sensor.key: sensor.value
for sensor in station.sensors for sensor in ecowitt.sensors.values()
if sensor.station.key == station_id if sensor.station.key == station_id
}, },
} }

View File

@ -1,5 +1,8 @@
"""Support for Ecowitt Weather Stations.""" """Support for Ecowitt Weather Stations."""
from __future__ import annotations
import dataclasses import dataclasses
from datetime import datetime
from typing import Final from typing import Final
from aioecowitt import EcoWittListener, EcoWittSensor, EcoWittSensorTypes from aioecowitt import EcoWittListener, EcoWittSensor, EcoWittSensorTypes
@ -242,6 +245,6 @@ class EcowittSensorEntity(EcowittEntity, SensorEntity):
self.entity_description = description self.entity_description = description
@property @property
def native_value(self) -> StateType: def native_value(self) -> StateType | datetime:
"""Return the state of the sensor.""" """Return the state of the sensor."""
return self.ecowitt.value return self.ecowitt.value