Skip to content

Commit

Permalink
Split definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin-dcs committed Dec 16, 2024
1 parent 391a284 commit 87016a2
Show file tree
Hide file tree
Showing 10 changed files with 630 additions and 660 deletions.
16 changes: 10 additions & 6 deletions custom_components/ithodaalderop/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
MQTT_STATETOPIC,
NONCVE_DEVICES,
)
from .definitions import (
AUTOTEMPBINARYSENSORS,
HRUECO350BINARYSENSORS,
HRUECOBINARYSENSORS,
IthoBinarySensorEntityDescription,
)
from .def_autotemp import AUTOTEMPBINARYSENSORS
from .def_cve import CVEBINARYSENSORS
from .def_hru350 import HRUECO350BINARYSENSORS
from .def_hrueco import HRUECOBINARYSENSORS
from .definitions import IthoBinarySensorEntityDescription


async def async_setup_entry(
Expand All @@ -51,6 +50,11 @@ async def async_setup_entry(
)
sensors.append(IthoBinarySensor(description, config_entry))

if config_entry.data[CONF_ADDON_TYPE] == "cve":
for description in CVEBINARYSENSORS:
description.key = f"{MQTT_BASETOPIC["cve"]}/{MQTT_STATETOPIC["cve"]}"
sensors.append(IthoBinarySensor(description, config_entry))

if config_entry.data[CONF_ADDON_TYPE] == "noncve":
if config_entry.data[CONF_NONCVE_MODEL] == "hru_eco":
hru_sensors = HRUECOBINARYSENSORS
Expand Down
63 changes: 63 additions & 0 deletions custom_components/ithodaalderop/def_autotemp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""Definitions for Itho sensors added to MQTT."""

from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import EntityCategory, UnitOfPower, UnitOfTemperature

from .definitions import IthoBinarySensorEntityDescription, IthoSensorEntityDescription

AUTOTEMPBINARYSENSORS: tuple[IthoBinarySensorEntityDescription, ...] = (
IthoBinarySensorEntityDescription(
json_field="Empty battery ( 0=OK )",
translation_key="empty_battery",
device_class=BinarySensorDeviceClass.BATTERY,
entity_category=EntityCategory.DIAGNOSTIC,
),
)

AUTOTEMPSENSORS: tuple[IthoSensorEntityDescription, ...] = (
IthoSensorEntityDescription(
json_field="Error",
translation_key="error",
entity_category=EntityCategory.DIAGNOSTIC,
),
IthoSensorEntityDescription(
json_field="Mode",
translation_key="mode",
),
IthoSensorEntityDescription(
json_field="State off",
translation_key="state",
),
)

AUTOTEMPROOMSENSORS: tuple[IthoSensorEntityDescription, ...] = (
IthoSensorEntityDescription(
json_field="Room X power % (%)",
translation_key="power_perc",
device_class=SensorDeviceClass.POWER_FACTOR,
native_unit_of_measurement="%",
state_class=SensorStateClass.MEASUREMENT,
),
IthoSensorEntityDescription(
json_field="Room X power kW (kW)",
translation_key="power_kw",
device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=UnitOfPower.KILO_WATT,
state_class=SensorStateClass.MEASUREMENT,
),
IthoSensorEntityDescription(
json_field="Room X setp",
translation_key="setpoint_temp",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
),
IthoSensorEntityDescription(
json_field="Room X temp",
translation_key="actual_temp",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
),
)
86 changes: 86 additions & 0 deletions custom_components/ithodaalderop/def_cve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"""Definitions for Itho sensors added to MQTT."""

from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION,
PERCENTAGE,
REVOLUTIONS_PER_MINUTE,
EntityCategory,
UnitOfTemperature,
UnitOfTime,
)

from .definitions import IthoBinarySensorEntityDescription, IthoSensorEntityDescription

CVEBINARYSENSORS: tuple[IthoBinarySensorEntityDescription, ...] = (
IthoBinarySensorEntityDescription(
json_field="Filter dirty",
translation_key="filter_dirty",
device_class=BinarySensorDeviceClass.PROBLEM,
entity_category=EntityCategory.DIAGNOSTIC,
icon_off="mdi:air-filter",
icon_on="mdi:vacuum-outline",
),
)

CVESENSORS: tuple[IthoSensorEntityDescription, ...] = (
IthoSensorEntityDescription(
json_field="Error",
translation_key="error",
entity_category=EntityCategory.DIAGNOSTIC,
),
IthoSensorEntityDescription(
json_field="Fan setpoint (rpm)",
translation_key="fan_setpoint_rpm",
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
state_class=SensorStateClass.MEASUREMENT,
),
IthoSensorEntityDescription(
json_field="Fan speed (rpm)",
translation_key="fan_speed",
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False,
),
IthoSensorEntityDescription(
json_field="Highest CO2 concentration (ppm)",
translation_key="highest_received_co2_value",
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False,
icon="mdi:molecule-co2",
),
IthoSensorEntityDescription(
json_field="Highest RH concentration (%)",
translation_key="highest_received_rh_value",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False,
),
IthoSensorEntityDescription(
json_field="hum",
translation_key="humidity",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
),
IthoSensorEntityDescription(
json_field="temp",
translation_key="temp",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
),
IthoSensorEntityDescription(
json_field="Total operation (hours)",
translation_key="total_operation_time",
native_unit_of_measurement=UnitOfTime.HOURS,
state_class=SensorStateClass.TOTAL_INCREASING,
entity_category=EntityCategory.DIAGNOSTIC,
),
IthoSensorEntityDescription(
json_field="Ventilation setpoint (%)",
translation_key="ventilation_setpoint_percentage",
native_unit_of_measurement=PERCENTAGE,
),
)
98 changes: 98 additions & 0 deletions custom_components/ithodaalderop/def_hru200.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
"""Definitions for Itho sensors added to MQTT."""

from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION,
PERCENTAGE,
REVOLUTIONS_PER_MINUTE,
EntityCategory,
UnitOfTemperature,
UnitOfTime,
)

from .definitions import IthoBinarySensorEntityDescription, IthoSensorEntityDescription

HRUECO200SENSORS: tuple[IthoSensorEntityDescription, ...] = (
IthoSensorEntityDescription(
json_field="Actual speed (rpm)",
translation_key="actual_speed",
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
state_class=SensorStateClass.MEASUREMENT,
),
IthoSensorEntityDescription(
json_field="Air discharge temperature (°C)",
translation_key="air_discharge_temp",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
),
IthoSensorEntityDescription(
json_field="Average air outlet temperature (°C)",
translation_key="average_air_outlet_temp",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
),
IthoSensorEntityDescription(
json_field="Error",
translation_key="error",
entity_category=EntityCategory.DIAGNOSTIC,
),
IthoSensorEntityDescription(
json_field="Filter use counter (hour)",
translation_key="filter_use_counter",
native_unit_of_measurement=UnitOfTime.HOURS,
state_class=SensorStateClass.TOTAL_INCREASING,
entity_category=EntityCategory.DIAGNOSTIC,
icon="mdi:counter",
),
IthoSensorEntityDescription(
json_field="Max. CO2 level (ppm)",
translation_key="max_co2_level",
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False,
icon="mdi:molecule-co2",
),
IthoSensorEntityDescription(
json_field="Max. RH level (%)",
translation_key="max_rh_level",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False,
),
IthoSensorEntityDescription(
json_field="Room temp setpoint (°C)",
translation_key="room_temp_setpoint",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
),
IthoSensorEntityDescription(
json_field="Outside temperature (°C)",
translation_key="outside_temp",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
),
IthoSensorEntityDescription(
json_field="Speed setpoint (rpm)",
translation_key="speed_setpoint",
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False,
),
IthoSensorEntityDescription(
json_field="Total operation (hrs)",
translation_key="total_operation_time",
native_unit_of_measurement=UnitOfTime.HOURS,
state_class=SensorStateClass.TOTAL_INCREASING,
entity_category=EntityCategory.DIAGNOSTIC,
),
IthoSensorEntityDescription(
json_field="Ventilation setpoint (%)",
translation_key="ventilation_setpoint_percentage",
native_unit_of_measurement=PERCENTAGE,
),
)
Loading

0 comments on commit 87016a2

Please sign in to comment.