Skip to content

Commit

Permalink
Merge pull request #75 from jasperslits/split-hru
Browse files Browse the repository at this point in the history
Add support for different HRU models
  • Loading branch information
benjamin-dcs authored Dec 24, 2024
2 parents 005a1d9 + 391a284 commit 8e3908f
Show file tree
Hide file tree
Showing 9 changed files with 906 additions and 154 deletions.
15 changes: 15 additions & 0 deletions custom_components/ithodaalderop/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
"""Init package."""

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant

from .const import CONF_ADDON_TYPE, CONF_NONCVE_MODEL

PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up the Itho Wifi add-on integration."""

# Migrate noncve config < v2.2.0 to 2.2.0+
# < 2.2.0 Only 1 HRU was supported. This was the HRU ECO 350
# So, if no hru_device is setup, this has to be the hru_eco_350
if (
entry.data[CONF_ADDON_TYPE] == "noncve"
and entry.data.get(CONF_NONCVE_MODEL) is None
):
new_data = {**entry.data}
new_data[CONF_NONCVE_MODEL] = "hru_eco_350"
hass.config_entries.async_update_entry(entry, data=new_data)

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True

Expand Down
30 changes: 22 additions & 8 deletions custom_components/ithodaalderop/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
_LOGGER,
ADDON_TYPES,
CONF_ADDON_TYPE,
CONF_NONCVE_MODEL,
DOMAIN,
MANUFACTURER,
MQTT_BASETOPIC,
MQTT_STATETOPIC,
NONCVE_DEVICES,
)
from .definitions import (
AUTOTEMPBINARYSENSORS,
NONCVEBINARYSENSORS,
HRUECO350BINARYSENSORS,
HRUECOBINARYSENSORS,
IthoBinarySensorEntityDescription,
)

Expand All @@ -41,14 +44,21 @@ async def async_setup_entry(
return

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

if config_entry.data[CONF_ADDON_TYPE] == "autotemp":
for description in AUTOTEMPBINARYSENSORS:
description.key = f"{MQTT_BASETOPIC["autotemp"]}/{MQTT_STATETOPIC["autotemp"]}"
description.key = (
f"{MQTT_BASETOPIC["autotemp"]}/{MQTT_STATETOPIC["autotemp"]}"
)
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
if config_entry.data[CONF_NONCVE_MODEL] == "hru_eco_350":
hru_sensors = HRUECO350BINARYSENSORS

for description in hru_sensors:
description.key = f"{MQTT_BASETOPIC["noncve"]}/{MQTT_STATETOPIC["noncve"]}"
sensors.append(IthoBinarySensor(description, config_entry))

async_add_entities(sensors)
Expand All @@ -68,10 +78,14 @@ def __init__(
"""Initialize the binary sensor."""
self.entity_description = description

model = ADDON_TYPES[config_entry.data[CONF_ADDON_TYPE]]
if config_entry.data[CONF_ADDON_TYPE] == "noncve":
model = model + " - " + NONCVE_DEVICES[config_entry.data[CONF_NONCVE_MODEL]]

self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, config_entry.data[CONF_ADDON_TYPE])},
manufacturer=MANUFACTURER,
model=ADDON_TYPES[config_entry.data[CONF_ADDON_TYPE]],
model=model,
name="Itho Daalderop " + ADDON_TYPES[config_entry.data[CONF_ADDON_TYPE]],
)

Expand Down
Loading

0 comments on commit 8e3908f

Please sign in to comment.