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
def is_on(self) -> bool:
"""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": {
"name": station.station,
"model": station.model,
"frequency": station.frequency,
"frequency": station.frequence,
"version": station.version,
},
"raw": ecowitt.last_values[station_id],
"sensors": {
sensor.key: sensor.value
for sensor in station.sensors
for sensor in ecowitt.sensors.values()
if sensor.station.key == station_id
},
}

View file

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