Skip to content

Commit

Permalink
Added many different Thermia heat pump sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
klejejs committed Jan 21, 2022
1 parent 40eae74 commit 758c54d
Show file tree
Hide file tree
Showing 6 changed files with 349 additions and 84 deletions.
2 changes: 1 addition & 1 deletion custom_components/thermia/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def async_step_user(self, user_input=None):
try:
await self._check_credentials(user_input)
return self.async_create_entry(
title="Thermia",
title=f"Thermia ({user_input[CONF_USERNAME]})",
data=user_input,
)
except Exception:
Expand Down
5 changes: 5 additions & 0 deletions custom_components/thermia/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@

API_TYPE = "api_type"
API_TYPES = [API_TYPE_CLASSIC, API_TYPE_GENESIS]

MDI_TIMER_COG_OUTLINE_ICON = "mdi:timer-cog-outline"
MDI_TEMPERATURE_ICON = "mdi:thermometer"

DIAGNOSTIC_ENTITY_CATEGORY = "diagnostic"
2 changes: 1 addition & 1 deletion custom_components/thermia/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@klejejs"
],
"requirements": [
"ThermiaOnlineAPI==2.7"
"ThermiaOnlineAPI==2.11"
],
"version": "1.0",
"iot_class": "cloud_polling",
Expand Down
299 changes: 288 additions & 11 deletions custom_components/thermia/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
from __future__ import annotations

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TEMP_CELSIUS, TIME_HOURS
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .sensors.active_alarms_sensor import ThermiaActiveAlarmsSensor
from .sensors.outdoor_temperature_sensor import ThermiaOutdoorTemperatureSensor
from .sensors.generic_sensor import ThermiaGenericSensor

from .const import DOMAIN
from .const import (
DIAGNOSTIC_ENTITY_CATEGORY,
DOMAIN,
MDI_TEMPERATURE_ICON,
MDI_TIMER_COG_OUTLINE_ICON,
)


async def async_setup_entry(
Expand All @@ -21,18 +27,289 @@ async def async_setup_entry(

coordinator = hass.data[DOMAIN][config_entry.entry_id]

hass_thermia_outdoor_temperature_sensors = [
ThermiaOutdoorTemperatureSensor(coordinator, idx)
for idx, heat_pump in enumerate(coordinator.data.heat_pumps)
if heat_pump.is_outdoor_temp_sensor_functioning
and heat_pump.outdoor_temperature
]
hass_thermia_sensors = []

for idx, heat_pump in enumerate(coordinator.data.heat_pumps):
if (
heat_pump.is_outdoor_temp_sensor_functioning
and heat_pump.outdoor_temperature is not None
):
hass_thermia_sensors.append(
ThermiaGenericSensor(
coordinator,
idx,
"is_online",
"Outdoor Temperature",
MDI_TEMPERATURE_ICON,
"sensor",
"temperature",
"measurement",
"outdoor_temperature",
TEMP_CELSIUS,
)
)

if (
heat_pump.has_indoor_temp_sensor
and heat_pump.indoor_temperature is not None
):
hass_thermia_sensors.append(
ThermiaGenericSensor(
coordinator,
idx,
"is_online",
"Indoor Temperature",
MDI_TEMPERATURE_ICON,
"sensor",
"temperature",
"measurement",
"indoor_temperature",
TEMP_CELSIUS,
)
)

if (
heat_pump.is_hot_water_active
and heat_pump.hot_water_temperature is not None
):
hass_thermia_sensors.append(
ThermiaGenericSensor(
coordinator,
idx,
"is_online",
"Hot Water Temperature",
MDI_TEMPERATURE_ICON,
"sensor",
"temperature",
"measurement",
"hot_water_temperature",
TEMP_CELSIUS,
)
)

###########################################################################
# Other temperature sensors
###########################################################################

if heat_pump.supply_line_temperature is not None:
hass_thermia_sensors.append(
ThermiaGenericSensor(
coordinator,
idx,
"is_online",
"Supply Line Temperature",
MDI_TEMPERATURE_ICON,
"sensor",
"temperature",
"measurement",
"supply_line_temperature",
TEMP_CELSIUS,
)
)

if heat_pump.desired_supply_line_temperature is not None:
hass_thermia_sensors.append(
ThermiaGenericSensor(
coordinator,
idx,
"is_online",
"Desired Supply Line Temperature",
MDI_TEMPERATURE_ICON,
"sensor",
"temperature",
"measurement",
"desired_supply_line_temperature",
TEMP_CELSIUS,
)
)

if heat_pump.return_line_temperature is not None:
hass_thermia_sensors.append(
ThermiaGenericSensor(
coordinator,
idx,
"is_online",
"Return Line Temperature",
MDI_TEMPERATURE_ICON,
"sensor",
"temperature",
"measurement",
"return_line_temperature",
TEMP_CELSIUS,
)
)

if heat_pump.brine_out_temperature is not None:
hass_thermia_sensors.append(
ThermiaGenericSensor(
coordinator,
idx,
"is_online",
"Brine Out Temperature",
MDI_TEMPERATURE_ICON,
"sensor",
"temperature",
"measurement",
"brine_out_temperature",
TEMP_CELSIUS,
)
)

if heat_pump.brine_in_temperature is not None:
hass_thermia_sensors.append(
ThermiaGenericSensor(
coordinator,
idx,
"is_online",
"Brine In Temperature",
MDI_TEMPERATURE_ICON,
"sensor",
"temperature",
"measurement",
"brine_in_temperature",
TEMP_CELSIUS,
)
)

if heat_pump.cooling_tank_temperature is not None:
hass_thermia_sensors.append(
ThermiaGenericSensor(
coordinator,
idx,
"is_online",
"Cooling Tank Temperature",
MDI_TEMPERATURE_ICON,
"sensor",
"temperature",
"measurement",
"cooling_tank_temperature",
TEMP_CELSIUS,
)
)

if heat_pump.cooling_supply_line_temperature is not None:
hass_thermia_sensors.append(
ThermiaGenericSensor(
coordinator,
idx,
"is_online",
"Cooling Supply Line Temperature",
MDI_TEMPERATURE_ICON,
"sensor",
"temperature",
"measurement",
"cooling_supply_line_temperature",
TEMP_CELSIUS,
)
)

###########################################################################
# Operational status data
###########################################################################

if heat_pump.operational_status is not None:
hass_thermia_sensors.append(
ThermiaGenericSensor(
coordinator,
idx,
"is_online",
"Operational Status",
"mdi:thermostat",
"sensor",
None,
"measurement",
"operational_status",
None,
)
)

###########################################################################
# Operational time data
###########################################################################

if heat_pump.compressor_operational_time is not None:
hass_thermia_sensors.append(
ThermiaGenericSensor(
coordinator,
idx,
"is_online",
"Compressor Operational Time",
MDI_TIMER_COG_OUTLINE_ICON,
DIAGNOSTIC_ENTITY_CATEGORY,
None,
"total_increasing",
"compressor_operational_time",
TIME_HOURS,
)
)

if heat_pump.hot_water_operational_time is not None:
hass_thermia_sensors.append(
ThermiaGenericSensor(
coordinator,
idx,
"is_online",
"Hot Water Operational Time",
MDI_TIMER_COG_OUTLINE_ICON,
DIAGNOSTIC_ENTITY_CATEGORY,
None,
"total_increasing",
"hot_water_operational_time",
TIME_HOURS,
)
)

if heat_pump.auxiliary_heater_1_operational_time is not None:
hass_thermia_sensors.append(
ThermiaGenericSensor(
coordinator,
idx,
"is_online",
"Auxiliary Heater 1 Operational Time",
MDI_TIMER_COG_OUTLINE_ICON,
DIAGNOSTIC_ENTITY_CATEGORY,
None,
"total_increasing",
"auxiliary_heater_1_operational_time",
TIME_HOURS,
)
)

if heat_pump.auxiliary_heater_2_operational_time is not None:
hass_thermia_sensors.append(
ThermiaGenericSensor(
coordinator,
idx,
"is_online",
"Auxiliary Heater 2 Operational Time",
MDI_TIMER_COG_OUTLINE_ICON,
DIAGNOSTIC_ENTITY_CATEGORY,
None,
"total_increasing",
"auxiliary_heater_2_operational_time",
TIME_HOURS,
)
)

if heat_pump.auxiliary_heater_3_operational_time is not None:
hass_thermia_sensors.append(
ThermiaGenericSensor(
coordinator,
idx,
"is_online",
"Auxiliary Heater 3 Operational Time",
MDI_TIMER_COG_OUTLINE_ICON,
DIAGNOSTIC_ENTITY_CATEGORY,
None,
"total_increasing",
"auxiliary_heater_3_operational_time",
TIME_HOURS,
)
)

hass_thermia_active_alarms_sensors = [
ThermiaActiveAlarmsSensor(coordinator, idx)
for idx, _ in enumerate(coordinator.data.heat_pumps)
]

async_add_entities(
[*hass_thermia_outdoor_temperature_sensors, *hass_thermia_active_alarms_sensors]
)
async_add_entities([*hass_thermia_active_alarms_sensors, *hass_thermia_sensors])
Loading

0 comments on commit 758c54d

Please sign in to comment.