fix: Fixed type errors

ecowitt_support
SchiZzA 2026-05-28 11:30:05 +02:00
parent 16a593e2a0
commit e3d00389de
No known key found for this signature in database
3 changed files with 12 additions and 19 deletions

View File

@ -7,7 +7,7 @@ instead of loosely-typed hass.data[][] dicts.
from __future__ import annotations from __future__ import annotations
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any from typing import TYPE_CHECKING, Any, Final
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core_config import Config from homeassistant.core_config import Config

View File

@ -247,6 +247,7 @@ class EcoWittNativeSensor(SensorEntity):
self._ecowitt_sensor = sensor self._ecowitt_sensor = sensor
self._attr_unique_id = f"ecowitt_{sensor.key}" self._attr_unique_id = f"ecowitt_{sensor.key}"
self._attr_translation_key = None # we do not have translation_keys for native sensors self._attr_translation_key = None # we do not have translation_keys for native sensors
self._attr_name = sensor.name # default name, can be overridden by translation_key if we had one
# set HomeAssistant metadata from aioecowitt sensor type # set HomeAssistant metadata from aioecowitt sensor type
ha_meta = STYPE_TO_HA.get(sensor.stype) ha_meta = STYPE_TO_HA.get(sensor.stype)
@ -256,10 +257,15 @@ class EcoWittNativeSensor(SensorEntity):
self._attr_native_unit_of_measurement = unit self._attr_native_unit_of_measurement = unit
self._attr_state_class = state_class self._attr_state_class = state_class
@property station = sensor.station
def name(self) -> str: self._attr_device_info = DeviceInfo(
"""Sensor name from aioecowitt.""" connections=set(),
return self._ecowitt_sensor.name name=f"Ecowitt {station.model}" if station else "Ecowitt station",
entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, f"ecowitt_{station.key}" if station else "ecowitt")},
manufacturer="Ecowitt impl. from Schizza for SWS12500",
model=station.model if station else None,
)
@property @property
def native_value(self) -> str | int | float | None: def native_value(self) -> str | int | float | None:
@ -269,19 +275,6 @@ class EcoWittNativeSensor(SensorEntity):
return None return None
return value return value
@property
def device_info(self) -> DeviceInfo:
"""Link to the Ecowitt station device."""
station = self._ecowitt_sensor.station
return DeviceInfo(
connections=set(),
name=f"Ecowitt {station.model}" if station else "Ecowitt station",
entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, f"ecowitt_{station.key}" if station else "ecowitt")},
manufacturer="Ecowitt impl. from Schizza for SWS12500",
model=station.model if station else None,
)
async def async_added_to_hass(self) -> None: async def async_added_to_hass(self) -> None:
"""Register update callback when entity is added to HA.""" """Register update callback when entity is added to HA."""
self._ecowitt_sensor.update_cb.append(self._handle_update) self._ecowitt_sensor.update_cb.append(self._handle_update)

View File

@ -94,7 +94,7 @@ async def translated_notification(
persistent_notification.async_create(hass, message, _translations[localize_title], notification_id) persistent_notification.async_create(hass, message, _translations[localize_title], notification_id)
async def update_options(hass: HomeAssistant, entry: ConfigEntry, update_key, update_value) -> bool: async def update_options(hass: HomeAssistant, entry: ConfigEntry, update_key: str, update_value: Any) -> bool:
"""Update config.options entry.""" """Update config.options entry."""
conf = {**entry.options} conf = {**entry.options}
conf[update_key] = update_value conf[update_key] = update_value