Preparing for public release
This commit is contained in:
+241
@@ -0,0 +1,241 @@
|
||||
"""
|
||||
Custom integration for heat pump monitoring and control via web interface.
|
||||
Place this code in custom_components/rdz_innova_heatpump/__init__.py
|
||||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
import aiohttp
|
||||
from datetime import timedelta
|
||||
from homeassistant.core import HomeAssistant, ServiceCall
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONF_URL,
|
||||
CONF_SCAN_INTERVAL,
|
||||
UnitOfTemperature
|
||||
)
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
UpdateFailed,
|
||||
)
|
||||
import voluptuous as vol
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
DOMAIN = "rdz_innova_heatpump"
|
||||
DEFAULT_SCAN_INTERVAL = 3
|
||||
|
||||
# Add climate to the platforms
|
||||
PLATFORMS = ["sensor", "binary_sensor", "climate", "water_heater"]
|
||||
|
||||
# Service constants
|
||||
SERVICE_SET_WATER_SETPOINT = "set_water_setpoint"
|
||||
ATTR_TEMPERATURE = "temperature"
|
||||
ATTR_DURATION = "duration"
|
||||
|
||||
# Service schema
|
||||
SET_WATER_SETPOINT_SCHEMA = vol.Schema({
|
||||
vol.Required(ATTR_TEMPERATURE): vol.All(vol.Coerce(float), vol.Range(min=35, max=60)),
|
||||
vol.Optional(ATTR_DURATION, default="forever"): cv.string,
|
||||
})
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
||||
"""Set up the Heat Pump Monitor component."""
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
return True
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up heat pump monitor from a config entry."""
|
||||
url = entry.data[CONF_URL]
|
||||
scan_interval = entry.options.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)
|
||||
|
||||
coordinator = HeatPumpDataCoordinator(
|
||||
hass,
|
||||
_LOGGER,
|
||||
url=url,
|
||||
update_interval=timedelta(seconds=scan_interval),
|
||||
)
|
||||
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
hass.data[DOMAIN][entry.entry_id] = coordinator
|
||||
|
||||
# Register the service
|
||||
async def set_water_setpoint(call: ServiceCall) -> None:
|
||||
"""Set the water setpoint of the heat pump."""
|
||||
temperature = call.data.get(ATTR_TEMPERATURE)
|
||||
duration = call.data.get(ATTR_DURATION, "forever")
|
||||
await coordinator.set_water_setpoint(temperature, duration)
|
||||
|
||||
hass.services.async_register(
|
||||
DOMAIN,
|
||||
SERVICE_SET_WATER_SETPOINT,
|
||||
set_water_setpoint,
|
||||
schema=SET_WATER_SETPOINT_SCHEMA,
|
||||
)
|
||||
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
return True
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Unload a config entry."""
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
if unload_ok:
|
||||
hass.data[DOMAIN].pop(entry.entry_id)
|
||||
return unload_ok
|
||||
|
||||
class HeatPumpDataCoordinator(DataUpdateCoordinator):
|
||||
"""Class to manage fetching heat pump data."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
logger: logging.Logger,
|
||||
url: str,
|
||||
update_interval: timedelta,
|
||||
) -> None:
|
||||
"""Initialize."""
|
||||
super().__init__(
|
||||
hass,
|
||||
logger,
|
||||
name=DOMAIN,
|
||||
update_interval=update_interval,
|
||||
)
|
||||
self.url = url
|
||||
# Extract the base URL by removing the last path segment
|
||||
parts = url.split('/')
|
||||
self.base_url = '/'.join(parts[:-1])
|
||||
|
||||
async def _async_update_data(self):
|
||||
"""Fetch data from heat pump."""
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(self.url) as response:
|
||||
if response.status != 200:
|
||||
raise UpdateFailed(f"Error fetching data: {response.status}")
|
||||
data = await response.json()
|
||||
|
||||
if not data.get("success", False):
|
||||
raise UpdateFailed("Heat pump returned unsuccessful response")
|
||||
|
||||
status = data.get("RESULT", {}).get("status", {})
|
||||
return {
|
||||
"software_version": data.get("sw", {}).get("V"),
|
||||
"last_update": data.get("RESULT", {}).get("TSLastUpdate"),
|
||||
"datetime": data.get("RESULT", {}).get("info", {}).get("datetime"),
|
||||
# Temperature readings
|
||||
# heating smart setpoint?
|
||||
"inlet_setpoint_temp": float(status.get("ISP", "0").split()[0]),
|
||||
# sanitary setpoint?
|
||||
"system_setpoint_temp": status.get("SSP"),
|
||||
"water_temp_t1": status.get("watert1"),
|
||||
"water_temp_t2": status.get("watert2"),
|
||||
"dhw_temp_t3": status.get("dhwt3"),
|
||||
"outdoor_temp_t4": status.get("t4"),
|
||||
# Setpoints
|
||||
# heating water normal setpoint
|
||||
"water_setpoint": status.get("watersetpoint"),
|
||||
"dhw_setpoint": status.get("dhwsetpoint"),
|
||||
# Operation states
|
||||
"is_heating": status.get("heating", False),
|
||||
"is_working": status.get("pwr", False),
|
||||
"is_cooling": status.get("cooling", False),
|
||||
"is_dhw": status.get("san", False),
|
||||
"is_pump_active": status.get("pump", False),
|
||||
"is_aux_heater" : status.get("res",False),
|
||||
"aux_heater": status.get("auxheater", 0),
|
||||
"is_standby": status.get("standby", False),
|
||||
"disabled_prod": status.get("disableProd",False),
|
||||
"sce": status.get("sce",False),
|
||||
# Operation times
|
||||
"worktime_pdc": status.get("worktime_pdc", 0),
|
||||
"worktime_res": status.get("worktime_res", 0),
|
||||
# Alarm status
|
||||
"has_alarm": status.get("alarm", {}).get("status", False),
|
||||
"alarm_type": status.get("alarm", {}).get("type", ""),
|
||||
"alarm_label": status.get("alarm", {}).get("label", ""),
|
||||
}
|
||||
except aiohttp.ClientError as err:
|
||||
raise UpdateFailed(f"Error communicating with heat pump: {err}")
|
||||
|
||||
async def set_water_setpoint(self, temperature: float, duration: str = "forever") -> bool:
|
||||
"""Set water setpoint temperature."""
|
||||
try:
|
||||
setpoint_url = f"{self.base_url}/index.php?Action=SetParameter"
|
||||
|
||||
# Prepare form data
|
||||
form_data = {
|
||||
"Key": "watersetpoint",
|
||||
"Value": str(temperature),
|
||||
"manual": duration
|
||||
}
|
||||
|
||||
_LOGGER.debug(f"Setting watersetpoint to {temperature} with duration {duration}")
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.post(
|
||||
setpoint_url,
|
||||
data=form_data,
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded"}
|
||||
) as response:
|
||||
if response.status != 200:
|
||||
_LOGGER.error(f"Failed to set water setpoint: {response.status}")
|
||||
return False
|
||||
_LOGGER.info(f"Successfully set water setpoint to {temperature}")
|
||||
# Force an immediate data refresh
|
||||
await self.async_request_refresh()
|
||||
return True
|
||||
except Exception as err:
|
||||
_LOGGER.error(f"Error setting water setpoint: {err}")
|
||||
return False
|
||||
|
||||
async def set_dhw_setpoint(self, temperature: float, duration: str = "forever") -> bool:
|
||||
"""Set water setpoint temperature."""
|
||||
try:
|
||||
setpoint_url = f"{self.base_url}/index.php?Action=SetParameter"
|
||||
|
||||
# Prepare form data
|
||||
form_data = {
|
||||
"Key": "dhwsetpoint",
|
||||
"Value": str(temperature),
|
||||
"manual": duration
|
||||
}
|
||||
|
||||
_LOGGER.debug(f"Setting dhwsetpoint to {temperature} with duration {duration}")
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.post(
|
||||
setpoint_url,
|
||||
data=form_data,
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded"}
|
||||
) as response:
|
||||
if response.status != 200:
|
||||
_LOGGER.error(f"Failed to set dhw setpoint: {response.status}")
|
||||
return False
|
||||
_LOGGER.info(f"Successfully set dhw setpoint to {temperature}")
|
||||
# Force an immediate data refresh
|
||||
await self.async_request_refresh()
|
||||
return True
|
||||
except Exception as err:
|
||||
_LOGGER.error(f"Error setting dhw setpoint: {err}")
|
||||
return False
|
||||
|
||||
class HeatPumpEntity(CoordinatorEntity):
|
||||
"""Base class for heat pump entities."""
|
||||
|
||||
def __init__(self, coordinator, sensor_type=None):
|
||||
"""Initialize the entity."""
|
||||
super().__init__(coordinator)
|
||||
self.sensor_type = sensor_type
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return device information."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, "heat_pump")},
|
||||
"name": "Heat Pump",
|
||||
"manufacturer": "RDZ",
|
||||
"model": "PDC",
|
||||
"sw_version": self.coordinator.data.get("software_version", "Unknown"),
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
"""
|
||||
Place this code in custom_components/rdz_innova_heatpump/binary_sensor.py
|
||||
"""
|
||||
from homeassistant.components.binary_sensor import (
|
||||
BinarySensorEntity,
|
||||
BinarySensorDeviceClass,
|
||||
)
|
||||
|
||||
from . import DOMAIN, HeatPumpEntity
|
||||
|
||||
async def async_setup_entry(hass, entry, async_add_entities):
|
||||
"""Set up binary sensors."""
|
||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
|
||||
entities = [
|
||||
HeatPumpOperatingBinarySensor(coordinator, "is_heating", "Heating", BinarySensorDeviceClass.HEAT),
|
||||
HeatPumpOperatingBinarySensor(coordinator, "is_working", "Working", BinarySensorDeviceClass.RUNNING),
|
||||
HeatPumpOperatingBinarySensor(coordinator, "is_cooling", "Cooling", BinarySensorDeviceClass.COLD),
|
||||
HeatPumpOperatingBinarySensor(coordinator, "is_dhw", "DHW Mode", BinarySensorDeviceClass.RUNNING),
|
||||
HeatPumpOperatingBinarySensor(coordinator, "is_pump_active", "Water Pump", BinarySensorDeviceClass.RUNNING),
|
||||
HeatPumpOperatingBinarySensor(coordinator, "is_aux_heater", "Auxiliary Heater", BinarySensorDeviceClass.HEAT),
|
||||
HeatPumpOperatingBinarySensor(coordinator, "is_standby", "Standby", BinarySensorDeviceClass.POWER),
|
||||
HeatPumpOperatingBinarySensor(coordinator, "disabled_prod", "Disabled Prod", BinarySensorDeviceClass.POWER),
|
||||
HeatPumpOperatingBinarySensor(coordinator, "sce", "SCE", BinarySensorDeviceClass.POWER),
|
||||
HeatPumpOperatingBinarySensor(coordinator, "has_alarm", "Alarm", BinarySensorDeviceClass.PROBLEM),
|
||||
]
|
||||
async_add_entities(entities)
|
||||
|
||||
class HeatPumpOperatingBinarySensor(HeatPumpEntity, BinarySensorEntity):
|
||||
"""Binary sensor for heat pump operation states."""
|
||||
|
||||
def __init__(self, coordinator, sensor_type, name, device_class):
|
||||
"""Initialize the binary sensor."""
|
||||
super().__init__(coordinator, sensor_type)
|
||||
self._attr_name = f"Heat Pump {name}"
|
||||
self._attr_unique_id = f"{DOMAIN}_{sensor_type}"
|
||||
self._attr_device_class = device_class
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if the binary sensor is on."""
|
||||
return self.coordinator.data.get(self.sensor_type, False)
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
"""
|
||||
Place this code in custom_components/rdz_innova_heatpump/climate.py
|
||||
"""
|
||||
import logging
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from homeassistant.components.climate import (
|
||||
ClimateEntity,
|
||||
ClimateEntityFeature,
|
||||
HVACMode,
|
||||
HVACAction,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_TEMPERATURE,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
|
||||
from . import DOMAIN, HeatPumpEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
# Define available HVAC modes based on heat pump capabilities
|
||||
HVAC_MODES = [HVACMode.HEAT, HVACMode.COOL, HVACMode.OFF]
|
||||
|
||||
async def async_setup_entry(hass, entry, async_add_entities):
|
||||
"""Set up the heat pump climate."""
|
||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
async_add_entities([HeatPumpClimate(coordinator)])
|
||||
|
||||
class HeatPumpClimate(HeatPumpEntity, ClimateEntity):
|
||||
"""Heat pump climate entity."""
|
||||
|
||||
def __init__(self, coordinator):
|
||||
"""Initialize the heat pump climate entity."""
|
||||
super().__init__(coordinator)
|
||||
self._attr_name = "Heat Pump Water Temperature"
|
||||
self._attr_unique_id = f"{DOMAIN}_climate"
|
||||
self._attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||
self._attr_hvac_modes = HVAC_MODES
|
||||
self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
self._attr_min_temp = 35
|
||||
self._attr_max_temp = 60
|
||||
self._attr_target_temperature_step = 0.5
|
||||
|
||||
@property
|
||||
def current_temperature(self) -> Optional[float]:
|
||||
"""Return the current temperature."""
|
||||
# Use T1 (inflow temperature) as the current temperature
|
||||
return self.coordinator.data.get("water_temp_t1")
|
||||
|
||||
@property
|
||||
def target_temperature(self) -> Optional[float]:
|
||||
"""Return the target temperature."""
|
||||
return self.coordinator.data.get("water_setpoint")
|
||||
|
||||
@property
|
||||
def hvac_mode(self) -> str:
|
||||
"""Return the current HVAC mode."""
|
||||
if self.coordinator.data.get("is_standby", False):
|
||||
return HVACMode.OFF
|
||||
elif self.coordinator.data.get("is_cooling", False):
|
||||
return HVACMode.COOL
|
||||
else:
|
||||
return HVACMode.HEAT
|
||||
|
||||
@property
|
||||
def hvac_action(self) -> Optional[str]:
|
||||
"""Return the current HVAC action."""
|
||||
if self.coordinator.data.get("is_standby", False):
|
||||
return HVACAction.OFF
|
||||
elif self.coordinator.data.get("is_cooling", False) and self.coordinator.data.get("is_working", False):
|
||||
return HVACAction.COOLING
|
||||
elif self.coordinator.data.get("is_heating", False) and self.coordinator.data.get("is_working", False):
|
||||
return HVACAction.HEATING
|
||||
else:
|
||||
return HVACAction.IDLE
|
||||
|
||||
async def async_set_temperature(self, **kwargs) -> None:
|
||||
"""Set new target temperature."""
|
||||
if ATTR_TEMPERATURE not in kwargs:
|
||||
return
|
||||
|
||||
temperature = kwargs[ATTR_TEMPERATURE]
|
||||
await self.coordinator.set_water_setpoint(temperature)
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
|
||||
"""Set HVAC mode."""
|
||||
# Note: This would require additional endpoints to control the heat pump mode
|
||||
# For now, we'll just log that this functionality isn't implemented
|
||||
_LOGGER.warning("Setting HVAC mode is not currently supported by this integration")
|
||||
# In the future, you could implement this if the heat pump API supports mode changes
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
"""
|
||||
Place this code in custom_components/heat_pump_monitor/config_flow.py
|
||||
"""
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.const import CONF_URL, CONF_SCAN_INTERVAL
|
||||
import voluptuous as vol
|
||||
|
||||
class HeatPumpMonitorConfigFlow(config_entries.ConfigFlow, domain="rdz_innova_heatpump"):
|
||||
"""Handle a config flow."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(self, user_input=None):
|
||||
"""Handle the initial step."""
|
||||
errors = {}
|
||||
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(
|
||||
title="Heat Pump Monitor",
|
||||
data={
|
||||
CONF_URL: user_input[CONF_URL],
|
||||
CONF_SCAN_INTERVAL: user_input.get(CONF_SCAN_INTERVAL, 3),
|
||||
},
|
||||
)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_URL): str,
|
||||
vol.Optional(CONF_SCAN_INTERVAL, default=3): int,
|
||||
}
|
||||
),
|
||||
errors=errors,
|
||||
)
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
|
||||
{
|
||||
"domain": "rdz_innova_heatpump",
|
||||
"name": "Heat Pump Monitor",
|
||||
"documentation": "https://github.com/your_username/heat_pump_monitor",
|
||||
"dependencies": [],
|
||||
"codeowners": ["@your_username"],
|
||||
"requirements": [],
|
||||
"config_flow": true,
|
||||
"iot_class": "local_polling",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
"""
|
||||
Place this code in custom_components/rdz_innova_heatpump/sensor.py
|
||||
"""
|
||||
from homeassistant.components.sensor import (
|
||||
SensorEntity,
|
||||
SensorDeviceClass,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.const import UnitOfTemperature, UnitOfTime
|
||||
|
||||
from . import DOMAIN, HeatPumpEntity
|
||||
|
||||
async def async_setup_entry(hass, entry, async_add_entities):
|
||||
"""Set up sensors."""
|
||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
|
||||
entities = [
|
||||
HeatPumpTemperatureSensor(coordinator, "inlet_setpoint_temp", "Inlet Setpoint Temperature"),
|
||||
HeatPumpTemperatureSensor(coordinator, "system_setpoint_temp", "System Setpoint Temperature"),
|
||||
HeatPumpTemperatureSensor(coordinator, "water_temp_t1", "Inflow Temperature T1"),
|
||||
HeatPumpTemperatureSensor(coordinator, "water_temp_t2", "Outflow Temperature T2"),
|
||||
HeatPumpTemperatureSensor(coordinator, "dhw_temp_t3", "DHW Temperature T3"),
|
||||
HeatPumpTemperatureSensor(coordinator, "outdoor_temp_t4", "Outdoor Temperature T4"),
|
||||
HeatPumpTemperatureSensor(coordinator, "water_setpoint", "Water Setpoint"),
|
||||
HeatPumpTemperatureSensor(coordinator, "dhw_setpoint", "DHW Setpoint"),
|
||||
HeatPumpTemperatureSensor(coordinator, "aux_heater", "Auxiliary Heater"),
|
||||
HeatPumpTimeSensor(coordinator, "worktime_pdc", "Runtime"),
|
||||
HeatPumpTimeSensor(coordinator, "worktime_res", "Auxiliary Heater Runtime"),
|
||||
HeatPumpVersionSensor(coordinator, "software_version", "Software Version"),
|
||||
]
|
||||
async_add_entities(entities)
|
||||
|
||||
class HeatPumpTemperatureSensor(HeatPumpEntity, SensorEntity):
|
||||
"""Temperature sensor for heat pump."""
|
||||
|
||||
def __init__(self, coordinator, sensor_type, name):
|
||||
"""Initialize the sensor."""
|
||||
super().__init__(coordinator, sensor_type)
|
||||
self._attr_name = f"Heat Pump {name}"
|
||||
self._attr_unique_id = f"{DOMAIN}_{sensor_type}"
|
||||
self._attr_device_class = SensorDeviceClass.TEMPERATURE
|
||||
self._attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS
|
||||
self._attr_state_class = SensorStateClass.MEASUREMENT
|
||||
|
||||
@property
|
||||
def native_value(self):
|
||||
"""Return the state of the sensor."""
|
||||
return self.coordinator.data.get(self.sensor_type)
|
||||
|
||||
class HeatPumpTimeSensor(HeatPumpEntity, SensorEntity):
|
||||
"""Time sensor for heat pump operation hours."""
|
||||
|
||||
def __init__(self, coordinator, sensor_type, name):
|
||||
"""Initialize the sensor."""
|
||||
super().__init__(coordinator, sensor_type)
|
||||
self._attr_name = f"Heat Pump {name}"
|
||||
self._attr_unique_id = f"{DOMAIN}_{sensor_type}"
|
||||
self._attr_device_class = SensorDeviceClass.DURATION
|
||||
self._attr_native_unit_of_measurement = UnitOfTime.HOURS
|
||||
self._attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||
|
||||
@property
|
||||
def native_value(self):
|
||||
"""Return the state of the sensor."""
|
||||
# Return the hours value directly
|
||||
return self.coordinator.data.get(self.sensor_type, 0)
|
||||
|
||||
class HeatPumpVersionSensor(HeatPumpEntity, SensorEntity):
|
||||
"""Software version sensor for heat pump."""
|
||||
|
||||
def __init__(self, coordinator, sensor_type, name):
|
||||
"""Initialize the sensor."""
|
||||
super().__init__(coordinator, sensor_type)
|
||||
self._attr_name = f"Heat Pump {name}"
|
||||
self._attr_unique_id = f"{DOMAIN}_{sensor_type}"
|
||||
|
||||
@property
|
||||
def native_value(self):
|
||||
"""Return the state of the sensor."""
|
||||
return self.coordinator.data.get(self.sensor_type)
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"config": {
|
||||
"step": {
|
||||
"user": {
|
||||
"title": "Heat Pump Monitor",
|
||||
"description": "Set up heat pump monitoring",
|
||||
"data": {
|
||||
"url": "Heat Pump URL",
|
||||
"scan_interval": "Update interval (seconds)"
|
||||
}
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"cannot_connect": "Failed to connect",
|
||||
"invalid_url": "Invalid URL"
|
||||
},
|
||||
"abort": {
|
||||
"already_configured": "Device is already configured"
|
||||
}
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
"""
|
||||
Place this code in custom_components/rdz_innova_heatpump/water_heater.py
|
||||
"""
|
||||
from homeassistant.components.water_heater import (
|
||||
WaterHeaterEntity,
|
||||
WaterHeaterEntityFeature,
|
||||
STATE_OFF,
|
||||
STATE_ON,
|
||||
)
|
||||
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
||||
|
||||
from . import DOMAIN, HeatPumpEntity
|
||||
|
||||
async def async_setup_entry(hass, entry, async_add_entities):
|
||||
"""Set up water heater."""
|
||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
async_add_entities([HeatPumpWaterHeater(coordinator)])
|
||||
|
||||
class HeatPumpWaterHeater(HeatPumpEntity, WaterHeaterEntity):
|
||||
"""Heat pump water heater entity."""
|
||||
|
||||
def __init__(self, coordinator):
|
||||
"""Initialize the water heater entity."""
|
||||
super().__init__(coordinator)
|
||||
self._attr_name = "Heat Pump DHW"
|
||||
self._attr_unique_id = f"{DOMAIN}_water_heater"
|
||||
self._attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||
self._attr_min_temp = 35
|
||||
self._attr_max_temp = 60
|
||||
self._attr_target_temperature_step = 0.5
|
||||
self._attr_supported_features = WaterHeaterEntityFeature.TARGET_TEMPERATURE
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
"""Return the current temperature."""
|
||||
return self.coordinator.data.get("dhw_temp_t3")
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
"""Return the target temperature."""
|
||||
return self.coordinator.data.get("dhw_setpoint")
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the current state."""
|
||||
if self.coordinator.data.get("is_dhw", False):
|
||||
return STATE_ON
|
||||
return STATE_OFF
|
||||
|
||||
async def async_set_temperature(self, **kwargs):
|
||||
"""Set new target temperature."""
|
||||
temperature = kwargs.get(ATTR_TEMPERATURE)
|
||||
await self.coordinator.set_dhw_setpoint(temperature)
|
||||
Reference in New Issue
Block a user