mirror of
https://github.com/home-assistant/core.git
synced 2026-04-02 08:26:41 +01:00
30 lines
893 B
Python
30 lines
893 B
Python
"""Provides conditions for power."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN, SensorDeviceClass
|
|
from homeassistant.const import UnitOfPower
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.automation import DomainSpec
|
|
from homeassistant.helpers.condition import (
|
|
Condition,
|
|
make_entity_numerical_condition_with_unit,
|
|
)
|
|
from homeassistant.util.unit_conversion import PowerConverter
|
|
|
|
POWER_DOMAIN_SPECS = {
|
|
SENSOR_DOMAIN: DomainSpec(device_class=SensorDeviceClass.POWER),
|
|
}
|
|
|
|
|
|
CONDITIONS: dict[str, type[Condition]] = {
|
|
"is_value": make_entity_numerical_condition_with_unit(
|
|
POWER_DOMAIN_SPECS, UnitOfPower.WATT, PowerConverter
|
|
),
|
|
}
|
|
|
|
|
|
async def async_get_conditions(hass: HomeAssistant) -> dict[str, type[Condition]]:
|
|
"""Return the power conditions."""
|
|
return CONDITIONS
|