Use imports from `helpers.typing` (#63459)
parent
b0f72f59da
commit
b168a8c7d0
|
@ -8,7 +8,6 @@ from homeassistant.components.sensor import (
|
|||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
StateType,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
|
@ -23,6 +22,7 @@ from homeassistant.const import (
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
|
|
|
@ -28,6 +28,7 @@ from homeassistant.helpers import entity, entity_registry, update_coordinator
|
|||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
from homeassistant.helpers.typing import StateType
|
||||
from homeassistant.util import dt
|
||||
|
||||
from .const import (
|
||||
|
@ -221,7 +222,7 @@ class IotaWattSensor(update_coordinator.CoordinatorEntity, SensorEntity):
|
|||
return attrs
|
||||
|
||||
@property
|
||||
def native_value(self) -> entity.StateType:
|
||||
def native_value(self) -> StateType:
|
||||
"""Return the state of the sensor."""
|
||||
if func := self.entity_description.value:
|
||||
return func(self._sensor_data.getValue())
|
||||
|
@ -258,7 +259,7 @@ class IotaWattAccumulatingSensor(IotaWattSensor, RestoreEntity):
|
|||
super()._handle_coordinator_update()
|
||||
|
||||
@property
|
||||
def native_value(self) -> entity.StateType:
|
||||
def native_value(self) -> StateType:
|
||||
"""Return the state of the sensor."""
|
||||
if self._accumulated_value is None:
|
||||
return None
|
||||
|
|
|
@ -51,7 +51,7 @@ from homeassistant.helpers import config_validation as cv, event, template
|
|||
from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.frame import report
|
||||
from homeassistant.helpers.typing import ConfigType, ServiceDataType
|
||||
from homeassistant.helpers.typing import ConfigType, ServiceDataType, TemplateVarsType
|
||||
from homeassistant.loader import bind_hass
|
||||
from homeassistant.util import dt as dt_util
|
||||
from homeassistant.util.async_ import run_callback_threadsafe
|
||||
|
@ -286,7 +286,7 @@ class MqttCommandTemplate:
|
|||
def async_render(
|
||||
self,
|
||||
value: PublishPayloadType = None,
|
||||
variables: template.TemplateVarsType = None,
|
||||
variables: TemplateVarsType = None,
|
||||
) -> PublishPayloadType:
|
||||
"""Render or convert the command template with given value or variables."""
|
||||
|
||||
|
@ -328,7 +328,7 @@ class MqttValueTemplate:
|
|||
*,
|
||||
hass: HomeAssistant | None = None,
|
||||
entity: Entity | None = None,
|
||||
config_attributes: template.TemplateVarsType = None,
|
||||
config_attributes: TemplateVarsType = None,
|
||||
) -> None:
|
||||
"""Instantiate a value template."""
|
||||
self._value_template = value_template
|
||||
|
@ -347,7 +347,7 @@ class MqttValueTemplate:
|
|||
self,
|
||||
payload: ReceivePayloadType,
|
||||
default: ReceivePayloadType | object = _SENTINEL,
|
||||
variables: template.TemplateVarsType = None,
|
||||
variables: TemplateVarsType = None,
|
||||
) -> ReceivePayloadType:
|
||||
"""Render with possible json value or pass-though a received MQTT value."""
|
||||
if self._value_template is None:
|
||||
|
|
|
@ -6,13 +6,13 @@ from homeassistant.components.sensor import (
|
|||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
StateType,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_KILO_WATT
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
|
|
|
@ -39,11 +39,8 @@ from homeassistant.const import (
|
|||
from homeassistant.core import HomeAssistant, ServiceCall
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import (
|
||||
AddEntitiesCallback,
|
||||
ConfigType,
|
||||
DiscoveryInfoType,
|
||||
)
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.util.temperature import convert as convert_temperature
|
||||
|
||||
from .const import _FETCH_FIELDS, ALL, DOMAIN, TIMEOUT
|
||||
|
|
|
@ -33,11 +33,8 @@ from homeassistant.const import (
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import (
|
||||
AddEntitiesCallback,
|
||||
ConfigType,
|
||||
DiscoveryInfoType,
|
||||
)
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
from .const import ATTR_ACTIVE, ATTR_MEASURE_TIME, ATTRIBUTION, CONF_STATION, DOMAIN
|
||||
|
|
|
@ -16,11 +16,8 @@ from homeassistant.const import CONF_NAME, CONF_PASSWORD, CONF_USERNAME
|
|||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import (
|
||||
AddEntitiesCallback,
|
||||
ConfigType,
|
||||
DiscoveryInfoType,
|
||||
)
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import (
|
||||
|
|
Loading…
Reference in New Issue