mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Add binary sensor for Vallox post heater (#59762)
This commit is contained in:
parent
3af3d9414d
commit
0ccb535f0a
@ -1242,6 +1242,7 @@ omit =
|
||||
homeassistant/components/vallox/const.py
|
||||
homeassistant/components/vallox/fan.py
|
||||
homeassistant/components/vallox/sensor.py
|
||||
homeassistant/components/vallox/binary_sensor.py
|
||||
homeassistant/components/vasttrafik/sensor.py
|
||||
homeassistant/components/velbus/__init__.py
|
||||
homeassistant/components/velbus/binary_sensor.py
|
||||
|
@ -1006,8 +1006,8 @@ homeassistant/components/usgs_earthquakes_feed/* @exxamalte
|
||||
tests/components/usgs_earthquakes_feed/* @exxamalte
|
||||
homeassistant/components/utility_meter/* @dgomes
|
||||
tests/components/utility_meter/* @dgomes
|
||||
homeassistant/components/vallox/* @andre-richter @slovdahl
|
||||
tests/components/vallox/* @andre-richter @slovdahl
|
||||
homeassistant/components/vallox/* @andre-richter @slovdahl @viiru-
|
||||
tests/components/vallox/* @andre-richter @slovdahl @viiru-
|
||||
homeassistant/components/velbus/* @Cereal2nd @brefra
|
||||
tests/components/velbus/* @Cereal2nd @brefra
|
||||
homeassistant/components/velux/* @Julius2342
|
||||
|
@ -52,6 +52,7 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
PLATFORMS: list[str] = [
|
||||
Platform.SENSOR,
|
||||
Platform.FAN,
|
||||
Platform.BINARY_SENSOR,
|
||||
]
|
||||
|
||||
ATTR_PROFILE = "profile"
|
||||
|
85
homeassistant/components/vallox/binary_sensor.py
Normal file
85
homeassistant/components/vallox/binary_sensor.py
Normal file
@ -0,0 +1,85 @@
|
||||
"""Support for Vallox ventilation unit binary sensors."""
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
BinarySensorEntity,
|
||||
BinarySensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from . import ValloxDataUpdateCoordinator
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
class ValloxBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
||||
"""Representation of a Vallox binary sensor."""
|
||||
|
||||
entity_description: ValloxBinarySensorEntityDescription
|
||||
coordinator: ValloxDataUpdateCoordinator
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
coordinator: ValloxDataUpdateCoordinator,
|
||||
description: ValloxBinarySensorEntityDescription,
|
||||
) -> None:
|
||||
"""Initialize the Vallox binary sensor."""
|
||||
super().__init__(coordinator)
|
||||
|
||||
self.entity_description = description
|
||||
|
||||
self._attr_name = f"{name} {description.name}"
|
||||
|
||||
uuid = self.coordinator.data.get_uuid()
|
||||
self._attr_unique_id = f"{uuid}-{description.key}"
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool | None:
|
||||
"""Return true if the binary sensor is on."""
|
||||
return self.coordinator.data.get_metric(self.entity_description.metric_key) == 1
|
||||
|
||||
|
||||
@dataclass
|
||||
class ValloxMetricKeyMixin:
|
||||
"""Dataclass to allow defining metric_key without a default value."""
|
||||
|
||||
metric_key: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class ValloxBinarySensorEntityDescription(
|
||||
BinarySensorEntityDescription, ValloxMetricKeyMixin
|
||||
):
|
||||
"""Describes Vallox binary sensor entity."""
|
||||
|
||||
|
||||
SENSORS: tuple[ValloxBinarySensorEntityDescription, ...] = (
|
||||
ValloxBinarySensorEntityDescription(
|
||||
key="post_heater",
|
||||
name="Post Heater",
|
||||
icon="mdi:radiator",
|
||||
metric_key="A_CYC_IO_HEATER",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
entry: ConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the sensors."""
|
||||
|
||||
data = hass.data[DOMAIN][entry.entry_id]
|
||||
|
||||
async_add_entities(
|
||||
[
|
||||
ValloxBinarySensor(data["name"], data["coordinator"], description)
|
||||
for description in SENSORS
|
||||
]
|
||||
)
|
@ -3,7 +3,7 @@
|
||||
"name": "Vallox",
|
||||
"documentation": "https://www.home-assistant.io/integrations/vallox",
|
||||
"requirements": ["vallox-websocket-api==2.9.0"],
|
||||
"codeowners": ["@andre-richter", "@slovdahl"],
|
||||
"codeowners": ["@andre-richter", "@slovdahl", "@viiru-"],
|
||||
"config_flow": true,
|
||||
"iot_class": "local_polling"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user