Fritzbox enable temp sensor (#52558)
This commit is contained in:
parent
258162d933
commit
24e07bc154
14 changed files with 205 additions and 63 deletions
|
@ -1,7 +1,11 @@
|
|||
"""Support for AVM FRITZ!SmartHome temperature sensor only devices."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity
|
||||
from homeassistant.components.sensor import (
|
||||
ATTR_STATE_CLASS,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
SensorEntity,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_DEVICE_CLASS,
|
||||
|
@ -34,18 +38,15 @@ async def async_setup_entry(
|
|||
coordinator = hass.data[FRITZBOX_DOMAIN][entry.entry_id][CONF_COORDINATOR]
|
||||
|
||||
for ain, device in coordinator.data.items():
|
||||
if (
|
||||
device.has_temperature_sensor
|
||||
and not device.has_switch
|
||||
and not device.has_thermostat
|
||||
):
|
||||
if device.has_temperature_sensor and not device.has_thermostat:
|
||||
entities.append(
|
||||
FritzBoxTempSensor(
|
||||
{
|
||||
ATTR_NAME: f"{device.name}",
|
||||
ATTR_ENTITY_ID: f"{device.ain}",
|
||||
ATTR_NAME: f"{device.name} Temperature",
|
||||
ATTR_ENTITY_ID: f"{device.ain}_temperature",
|
||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
||||
ATTR_DEVICE_CLASS: DEVICE_CLASS_TEMPERATURE,
|
||||
ATTR_STATE_CLASS: STATE_CLASS_MEASUREMENT,
|
||||
},
|
||||
coordinator,
|
||||
ain,
|
||||
|
@ -60,6 +61,7 @@ async def async_setup_entry(
|
|||
ATTR_ENTITY_ID: f"{device.ain}_battery",
|
||||
ATTR_UNIT_OF_MEASUREMENT: PERCENTAGE,
|
||||
ATTR_DEVICE_CLASS: DEVICE_CLASS_BATTERY,
|
||||
ATTR_STATE_CLASS: None,
|
||||
},
|
||||
coordinator,
|
||||
ain,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue