mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add additional sensors to ecoforest integration (#100681)
* add ecoforest additional sensors * add ecoforest additional sensors * use StateType Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * use StateType Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * update cpu temp translation Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * use common translation Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * use common on translation Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * use common standby translation Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * update strings * update strings * import state type * relabel preheating Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * add cpu temp disable by default --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
parent
cd30286913
commit
86a692bb22
@ -5,7 +5,7 @@ from collections.abc import Callable
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pyecoforest.models.device import Device
|
from pyecoforest.models.device import Alarm, Device, State
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
@ -16,6 +16,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.const import UnitOfTemperature
|
from homeassistant.const import UnitOfTemperature
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import EcoforestCoordinator
|
from .coordinator import EcoforestCoordinator
|
||||||
@ -23,12 +24,15 @@ from .entity import EcoforestEntity
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
STATUS_TYPE = [s.value for s in State]
|
||||||
|
ALARM_TYPE = [a.value for a in Alarm] + ["none"]
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class EcoforestRequiredKeysMixin:
|
class EcoforestRequiredKeysMixin:
|
||||||
"""Mixin for required keys."""
|
"""Mixin for required keys."""
|
||||||
|
|
||||||
value_fn: Callable[[Device], float | None]
|
value_fn: Callable[[Device], StateType]
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -45,6 +49,45 @@ SENSOR_TYPES: tuple[EcoforestSensorEntityDescription, ...] = (
|
|||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
value_fn=lambda data: data.environment_temperature,
|
value_fn=lambda data: data.environment_temperature,
|
||||||
),
|
),
|
||||||
|
EcoforestSensorEntityDescription(
|
||||||
|
key="cpu_temperature",
|
||||||
|
translation_key="cpu_temperature",
|
||||||
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
value_fn=lambda data: data.cpu_temperature,
|
||||||
|
),
|
||||||
|
EcoforestSensorEntityDescription(
|
||||||
|
key="gas_temperature",
|
||||||
|
translation_key="gas_temperature",
|
||||||
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
value_fn=lambda data: data.gas_temperature,
|
||||||
|
),
|
||||||
|
EcoforestSensorEntityDescription(
|
||||||
|
key="ntc_temperature",
|
||||||
|
translation_key="ntc_temperature",
|
||||||
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
value_fn=lambda data: data.ntc_temperature,
|
||||||
|
),
|
||||||
|
EcoforestSensorEntityDescription(
|
||||||
|
key="status",
|
||||||
|
translation_key="status",
|
||||||
|
device_class=SensorDeviceClass.ENUM,
|
||||||
|
options=STATUS_TYPE,
|
||||||
|
value_fn=lambda data: data.state.value,
|
||||||
|
),
|
||||||
|
EcoforestSensorEntityDescription(
|
||||||
|
key="alarm",
|
||||||
|
translation_key="alarm",
|
||||||
|
device_class=SensorDeviceClass.ENUM,
|
||||||
|
options=ALARM_TYPE,
|
||||||
|
icon="mdi:alert",
|
||||||
|
value_fn=lambda data: data.alarm.value if data.alarm else "none",
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -67,6 +110,6 @@ class EcoforestSensor(SensorEntity, EcoforestEntity):
|
|||||||
entity_description: EcoforestSensorEntityDescription
|
entity_description: EcoforestSensorEntityDescription
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> float | None:
|
def native_value(self) -> StateType:
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return self.entity_description.value_fn(self.data)
|
return self.entity_description.value_fn(self.data)
|
||||||
|
@ -19,6 +19,39 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"entity": {
|
"entity": {
|
||||||
|
"sensor": {
|
||||||
|
"cpu_temperature": {
|
||||||
|
"name": "CPU temperature"
|
||||||
|
},
|
||||||
|
"gas_temperature": {
|
||||||
|
"name": "Gas temperature"
|
||||||
|
},
|
||||||
|
"ntc_temperature": {
|
||||||
|
"name": "NTC probe temperature"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"name": "Status",
|
||||||
|
"state": {
|
||||||
|
"off": "[%key:common::state::off%]",
|
||||||
|
"starting": "Starting",
|
||||||
|
"pre_heating": "Pre-heating",
|
||||||
|
"on": "[%key:common::state::on%]",
|
||||||
|
"shutting_down": "Shutting down",
|
||||||
|
"stand_by": "[%key:common::state::standby%]",
|
||||||
|
"alarm": "Alarm"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"alarm": {
|
||||||
|
"name": "Alarm",
|
||||||
|
"state": {
|
||||||
|
"air_depression": "Air depression",
|
||||||
|
"pellets": "Pellets",
|
||||||
|
"cpu_overheating": "CPU overheating",
|
||||||
|
"unkownn": "Unknown alarm",
|
||||||
|
"none": "None"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"number": {
|
"number": {
|
||||||
"power_level": {
|
"power_level": {
|
||||||
"name": "Power level"
|
"name": "Power level"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user