Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement heat pump support #97

Merged
merged 2 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion custom_components/oekofen_pellematic_compact/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
CONF_NUM_OF_PELLEMATIC_HEATER,
CONF_NUM_OF_SMART_PV_SE,
CONF_NUM_OF_SMART_PV_SK,
CONF_NUM_OF_HEAT_PUMPS,
DEFAULT_NUM_OF_HEAT_PUMPS,
DEFAULT_NUM_OF_SMART_PV_SE,
DEFAULT_NUM_OF_SMART_PV_SK,
CONF_NUM_OF_HEATING_CIRCUIT,
Expand All @@ -44,11 +46,13 @@
vol.Optional(CONF_NUM_OF_PELLEMATIC_HEATER, default=DEFAULT_NUM_OF_PELLEMATIC_HEATER): int,
vol.Optional(CONF_SOLAR_CIRCUIT, default=False): bool,
vol.Optional(CONF_NUM_OF_SMART_PV_SE, default=DEFAULT_NUM_OF_SMART_PV_SE): int,
vol.Optional(CONF_NUM_OF_SMART_PV_SK, default=DEFAULT_NUM_OF_SMART_PV_SK): int,
vol.Optional(CONF_NUM_OF_SMART_PV_SK, default=DEFAULT_NUM_OF_SMART_PV_SK): int,
vol.Optional(CONF_NUM_OF_HEAT_PUMPS, default=DEFAULT_NUM_OF_HEAT_PUMPS): int,
vol.Optional(CONF_CIRCULATOR, default=False): bool,
vol.Optional(CONF_SMART_PV, default=False): bool,
vol.Optional(CONF_STIRLING, default=False): bool,
vol.Optional(CONF_CHARSET, default=DEFAULT_CHARSET): str,

}
)

Expand Down
223 changes: 223 additions & 0 deletions custom_components/oekofen_pellematic_compact/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
UnitOfPower,
UnitOfEnergy,
UnitOfElectricPotential,
UnitOfVolumeFlowRate,
UnitOfPressure
)
from homeassistant.components.number import NumberDeviceClass, NumberMode

Expand All @@ -20,6 +22,7 @@
DEFAULT_NUM_OF_PELLEMATIC_HEATER = 1
DEFAULT_NUM_OF_SMART_PV_SE = 1
DEFAULT_NUM_OF_SMART_PV_SK = 1
DEFAULT_NUM_OF_HEAT_PUMPS = 1
CONF_SOLAR_CIRCUIT = "solar_circuit"
CONF_CIRCULATOR = "circulator"
CONF_SMART_PV = "smart_pv"
Expand All @@ -28,6 +31,7 @@
CONF_NUM_OF_HEATING_CIRCUIT = "num_of_heating_circuits"
CONF_NUM_OF_PELLEMATIC_HEATER = "num_of_pellematic_heaters"
CONF_NUM_OF_SMART_PV_SE = "num_of_smart_pv_se_count"
CONF_NUM_OF_HEAT_PUMPS = "num_of_heat_pumps_count"
CONF_NUM_OF_SMART_PV_SK = "num_of_smart_pv_sk_count"
CONF_NUM_OF_HOT_WATER = "num_of_hot_water"
DEFAULT_HOST = "http://[YOU_IP]:4321/[YOUR_PASSWORD]/all"
Expand Down Expand Up @@ -945,6 +949,225 @@
],
}

WP_SENSOR_TYPES = {
"L_state": [
"Heat Pump{0} State",
"L_state",
None,
"mdi:heat-pump",
],
"L_statetext": [
"Heat Pump{0} State Text",
"L_statetext",
None,
"mdi:heat-pump",
],
"L_sg_ready": [
"Heat Pump{0} SG Ready",
"L_sg_ready",
None,
"mdi:heat-pump",
],
"L_cop": [
"Heat Pump{0} COP",
"L_cop",
None,
"mdi:heat-pump",
],
"L_uwp": [
"Heat Pump{0} UWP Compressor",
"L_uwp",
PERCENTAGE,
None,
],
"L_fan": [
"Heat Pump{0} Fan",
"L_fan",
PERCENTAGE,
None,
],
"L_highpressure": [
"Heat Pump{0} High pressure",
"L_highpressure",
UnitOfPressure.BAR,
"mdi:heat-pump",
],
"L_lowpressure": [
"Heat Pump{0} Low pressure",
"L_lowpressure",
UnitOfPressure.BAR,
"mdi:heat-pump",
],
"L_overheat_is": [
"Heat Pump{0} Overheat is",
"L_overheat_is",
None,
"mdi:heat-pump",
],
"L_overheat_set": [
"Heat Pump{0} Overheat set",
"L_overheat_set",
None,
"mdi:heat-pump",
],
"L_eev": [
"Heat Pump{0} EEV",
"L_eev",
None,
"mdi:heat-pump",
],
"L_overheat": [
"Heat Pump{0} Overheat",
"L_overheat",
None,
"mdi:heat-pump",
],
"L_compressor_in": [
"Heat Pump{0} Compressor in",
"L_compressor_in",
UnitOfTemperature.CELSIUS,
None,
],
"L_compressor_out": [
"Heat Pump{0} Compressor out",
"L_compressor_out",
UnitOfTemperature.CELSIUS,
None,
],
"L_temp_src_in": [
"Heat Pump{0} Fan in",
"L_temp_src_in",
UnitOfTemperature.CELSIUS,
None,
],
"L_temp_src_out": [
"Heat Pump{0} Fan out",
"L_temp_src_out",
UnitOfTemperature.CELSIUS,
None,
],
"L_temp_flow_is": [
"Heat Pump{0} Flow is",
"L_temp_flow_is",
UnitOfTemperature.CELSIUS,
None,
],
"L_temp_flow_set": [
"Heat Pump{0} Flow set",
"L_temp_flow_set",
UnitOfTemperature.CELSIUS,
None,
],
"L_temp_return_is": [
"Heat Pump{0} Flow return",
"L_temp_return_is",
UnitOfTemperature.CELSIUS,
None,
],
"L_flowrate": [
"Heat Pump{0} Flow rate",
"L_flowrate",
UnitOfVolumeFlowRate.LITERS_PER_MINUTE,
None,
],
"L_temp_vap": [
"Heat Pump{0} Evaporation temperature",
"L_temp_vap",
UnitOfTemperature.CELSIUS,
None,
],
"L_temp_condens": [
"Heat Pump{0} Condensation temperature",
"L_temp_condens",
UnitOfTemperature.CELSIUS,
None,
],
"L_temp_heater": [
"Heat Pump{0} Heating power",
"L_temp_heater",
UnitOfPower.WATT,
None,
],
"L_temp_cooler": [
"Heat Pump{0} Cooling power",
"L_temp_cooler",
UnitOfPower.WATT,
None,
],
"L_el_energy": [
"Heat Pump{0} Electrical power",
"L_el_energy",
UnitOfPower.WATT,
None,
],
"L_total_runtime": [
"Heat Pump{0} Runtime Total",
"L_total_runtime",
UnitOfTime.HOURS,
"mdi:timer",
],
"L_min_runtime": [
"Heat Pump{0} Runtime Min",
"L_min_runtime",
UnitOfTime.HOURS,
"mdi:timer",
],
"L_max_runtime": [
"Heat Pump{0} Runtime Max",
"L_max_runtime",
UnitOfTime.HOURS,
"mdi:timer",
],
"L_activation_count": [
"Heat Pump{0} Activation counts",
"L_activation_count",
None,
"mdi:numeric",
],
"L_jaz_all": [
"Heat Pump{0} JAZ",
"L_jaz_all",
None,
"mdi:numeric",
],
"L_jaz_heat": [
"Heat Pump{0} JAZ Heat",
"L_jaz_heat",
None,
"mdi:numeric",
],
"L_jaz_cool": [
"Heat Pump{0} JAZ Cool",
"L_jaz_cool",
None,
"mdi:numeric",
],
"L_az_all": [
"Heat Pump{0} AZ",
"L_az_all",
None,
"mdi:numeric",
],
"L_az_heat": [
"Heat Pump{0} AZ Heat",
"L_az_heat",
None,
"mdi:numeric",
],
"L_az_cool": [
"Heat Pump{0} AZ Cool",
"L_az_cool",
None,
"mdi:numeric",
],
"mode": [
"Heat Pump{0} Mode",
"mode",
None,
"mdi:heat-pump",
]
}

WW_SENSOR_TYPES = {
"L_temp_set": [
"Hot Water Circuit{0} Temperature set ",
Expand Down
40 changes: 38 additions & 2 deletions custom_components/oekofen_pellematic_compact/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
CONF_NUM_OF_PELLEMATIC_HEATER,
CONF_NUM_OF_SMART_PV_SE,
CONF_NUM_OF_SMART_PV_SK,
CONF_NUM_OF_HEAT_PUMPS,
CONF_SOLAR_CIRCUIT,
CONF_CIRCULATOR,
CONF_SMART_PV,
Expand All @@ -35,6 +36,7 @@
DOMAIN,
ATTR_MANUFACTURER,
ATTR_MODEL,
WP_SENSOR_TYPES
)

from homeassistant.const import (
Expand All @@ -45,6 +47,8 @@
UnitOfTemperature,
UnitOfMass,
UnitOfTime,
UnitOfVolumeFlowRate,
UnitOfPressure
)

from homeassistant.components.sensor import (
Expand Down Expand Up @@ -104,7 +108,11 @@ async def async_setup_entry(
try:
num_smart_pv_sk = entry.data[CONF_NUM_OF_SMART_PV_SK]
except:
num_smart_pv_sk = 1
num_smart_pv_sk = 1
try:
num_heat_pumps = entry.data[CONF_NUM_OF_HEAT_PUMPS]
except:
num_heat_pumps = 1

_LOGGER.debug("Setup entry %s %s", hub_name, hub)

Expand Down Expand Up @@ -321,6 +329,20 @@ async def async_setup_entry(
)
entities.append(sensor)

for heatpump_count in range(num_heat_pumps):
for name, key, unit, icon in WP_SENSOR_TYPES.values():
sensor = PellematicSensor(
hub_name,
hub,
device_info,
f"wp{heatpump_count+1}",
name.format(" " + str(heatpump_count + 1)),
key,
unit,
icon,
)
entities.append(sensor)

_LOGGER.debug("Entities added : %i", len(entities))

async_add_entities(entities)
Expand Down Expand Up @@ -470,6 +492,12 @@ def __init__(
self._icon = icon
self._device_info = device_info
self._state = None
if self._unit_of_measurement == UnitOfVolumeFlowRate.LITERS_PER_MINUTE:
self._attr_state_class = SensorStateClass.MEASUREMENT
self._attr_device_class = SensorDeviceClass.VOLUME_FLOW_RATE
if self._unit_of_measurement == UnitOfPressure.BAR:
self._attr_state_class = SensorStateClass.MEASUREMENT
self._attr_device_class = SensorDeviceClass.PRESSURE
if self._unit_of_measurement == UnitOfPower.KILO_WATT:
self._attr_state_class = SensorStateClass.MEASUREMENT
self._attr_device_class = SensorDeviceClass.POWER
Expand Down Expand Up @@ -538,6 +566,8 @@ def _update_state(self):
current_value = self._hub.data[self._prefix][self._key.replace("#2", "")]["val"]
if self._attr_device_class == SensorDeviceClass.TEMPERATURE:
current_value = int(current_value) / 10
if self._attr_device_class == UnitOfPower.LITERS_PER_MINUTE:
current_value = int(current_value) * 60
if self._attr_device_class == UnitOfPower.KILO_WATT:
current_value = int(current_value) / 10
if self._unit_of_measurement == UnitOfEnergy.KILO_WATT_HOUR:
Expand All @@ -556,8 +586,10 @@ def _update_state(self):
current_value = self._hub.data[self._prefix][self._key.replace("#2", "")]
if self._attr_device_class == SensorDeviceClass.TEMPERATURE:
current_value = int(current_value) / 10
if self._attr_device_class == UnitOfPower.LITERS_PER_MINUTE:
current_value = int(current_value) * 60
if self._attr_device_class == UnitOfPower.KILO_WATT:
current_value = int(current_value) / 10
current_value = int(current_value) / 10
if self._unit_of_measurement == UnitOfEnergy.KILO_WATT_HOUR:
# SE1 need / 10 but POWER need / 10000
if self._prefix == "se1":
Expand Down Expand Up @@ -596,6 +628,8 @@ def state(self):
current_value = self._hub.data[self._prefix][self._key.replace("#2", "")]["val"]
if self._attr_device_class == SensorDeviceClass.TEMPERATURE:
current_value = int(current_value) / 10
if self._attr_device_class == UnitOfPower.LITERS_PER_MINUTE:
current_value = int(current_value) * 60
if self._attr_device_class == UnitOfPower.KILO_WATT:
current_value = int(current_value) / 10
if self._unit_of_measurement == UnitOfEnergy.KILO_WATT_HOUR:
Expand All @@ -614,6 +648,8 @@ def state(self):
current_value = self._hub.data[self._prefix][self._key.replace("#2", "")]
if self._attr_device_class == SensorDeviceClass.TEMPERATURE:
current_value = int(current_value) / 10
if self._attr_device_class == UnitOfPower.LITERS_PER_MINUTE:
current_value = int(current_value) * 60
if self._attr_device_class == UnitOfPower.KILO_WATT:
current_value = int(current_value) / 10
if self._unit_of_measurement == UnitOfEnergy.KILO_WATT_HOUR:
Expand Down
1 change: 1 addition & 0 deletions custom_components/oekofen_pellematic_compact/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"num_of_pellematic_heaters": "Num of Pellematic heaters (PELx)",
"num_of_smart_pv_se_count" : "Num of Smart PV (SEx)",
"num_of_smart_pv_sk_count" : "Num of thermal solar collectors (SKx)",
"num_of_heat_pumps_count" : "Num of Heat Pumps (WPx)",
"charset": "Character set for decoding (try iso-8859-1 or utf-8)"
}
}
Expand Down
Loading
Loading