From dd63ed7e694d5919579288a1963aef97b29938a1 Mon Sep 17 00:00:00 2001
From: Simone Chemelli <simone.chemelli@gmail.com>
Date: Fri, 25 Oct 2024 12:57:52 +0200
Subject: [PATCH] Vodafone Station typing (#129143)

---
 .../components/vodafone_station/sensor.py     | 20 ++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/homeassistant/components/vodafone_station/sensor.py b/homeassistant/components/vodafone_station/sensor.py
index e12e668db26..2e2ca63761c 100644
--- a/homeassistant/components/vodafone_station/sensor.py
+++ b/homeassistant/components/vodafone_station/sensor.py
@@ -5,7 +5,7 @@ from __future__ import annotations
 from collections.abc import Callable
 from dataclasses import dataclass
 from datetime import datetime
-from typing import Any, Final
+from typing import Final
 
 from homeassistant.components.sensor import (
     SensorDeviceClass,
@@ -16,7 +16,6 @@ from homeassistant.config_entries import ConfigEntry
 from homeassistant.const import PERCENTAGE, EntityCategory, UnitOfDataRate
 from homeassistant.core import HomeAssistant
 from homeassistant.helpers.entity_platform import AddEntitiesCallback
-from homeassistant.helpers.typing import StateType
 from homeassistant.helpers.update_coordinator import CoordinatorEntity
 
 from .const import _LOGGER, DOMAIN, LINE_TYPES
@@ -30,19 +29,22 @@ UPTIME_DEVIATION = 30
 class VodafoneStationEntityDescription(SensorEntityDescription):
     """Vodafone Station entity description."""
 
-    value: Callable[[Any, Any, Any], Any] = (
-        lambda coordinator, last_value, key: coordinator.data.sensors[key]
-    )
+    value: Callable[
+        [VodafoneStationRouter, str | datetime | float | None, str],
+        str | datetime | float | None,
+    ] = lambda coordinator, last_value, key: coordinator.data.sensors[key]
     is_suitable: Callable[[dict], bool] = lambda val: True
 
 
 def _calculate_uptime(
     coordinator: VodafoneStationRouter,
-    last_value: datetime | None,
+    last_value: str | datetime | float | None,
     key: str,
 ) -> datetime:
     """Calculate device uptime."""
 
+    assert isinstance(last_value, datetime)
+
     delta_uptime = coordinator.api.convert_uptime(coordinator.data.sensors[key])
 
     if (
@@ -56,7 +58,7 @@ def _calculate_uptime(
 
 def _line_connection(
     coordinator: VodafoneStationRouter,
-    last_value: str | None,
+    last_value: str | datetime | float | None,
     key: str,
 ) -> str | None:
     """Identify line type."""
@@ -199,10 +201,10 @@ class VodafoneStationSensorEntity(
         self.entity_description = description
         self._attr_device_info = coordinator.device_info
         self._attr_unique_id = f"{coordinator.serial_number}_{description.key}"
-        self._old_state = None
+        self._old_state: str | datetime | float | None = None
 
     @property
-    def native_value(self) -> StateType:
+    def native_value(self) -> str | datetime | float | None:
         """Sensor value."""
         self._old_state = self.entity_description.value(
             self.coordinator, self._old_state, self.entity_description.key
-- 
GitLab