mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Add sensors for current and potential to AVM FRITZ!SmartHome / Fritz!DECT (#69999)
* Update sensor.py Add sensors for current and potential to AVM FRITZ!SmartHome. Tested with Fritz!DECT 200 * Update sensor.py black, flake8 and isort checked * Fix the change requests Fixed the division by 1000 on two code parts to comply with the AVM API documention. Added device.power to availability check. * black --fast applied * fix issort * rename electric potential to voltage Co-authored-by: mib1185 <mail@mib85.de>
This commit is contained in:
parent
dc7e3a6df6
commit
31b6b3deb5
@ -17,6 +17,8 @@ from homeassistant.components.sensor import (
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ELECTRIC_CURRENT_AMPERE,
|
||||
ELECTRIC_POTENTIAL_VOLT,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
@ -87,6 +89,26 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
|
||||
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]
|
||||
native_value=lambda device: device.power / 1000 if device.power else 0.0,
|
||||
),
|
||||
FritzSensorEntityDescription(
|
||||
key="voltage",
|
||||
name="Voltage",
|
||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]
|
||||
native_value=lambda device: device.voltage / 1000 if device.voltage else 0.0,
|
||||
),
|
||||
FritzSensorEntityDescription(
|
||||
key="electric_current",
|
||||
name="Electric Current",
|
||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||
device_class=SensorDeviceClass.CURRENT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]
|
||||
native_value=lambda device: device.power / device.voltage
|
||||
if device.power and device.voltage
|
||||
else 0.0,
|
||||
),
|
||||
FritzSensorEntityDescription(
|
||||
key="total_energy",
|
||||
name="Total Energy",
|
||||
|
Loading…
x
Reference in New Issue
Block a user