mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add heating_type for ViCare integration (#27296)
* Add heating_type for ViCare * Add additional gas heating properties * Update requirements_all * Add hvac action * Remove measurements * Remove unused property
This commit is contained in:
parent
aaad8eac0a
commit
06c26f3ffc
@ -1,8 +1,12 @@
|
||||
"""The ViCare integration."""
|
||||
import enum
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from PyViCare.PyViCareDevice import Device
|
||||
from PyViCare.PyViCareGazBoiler import GazBoiler
|
||||
from PyViCare.PyViCareHeatPump import HeatPump
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD, CONF_NAME
|
||||
@ -15,8 +19,20 @@ VICARE_PLATFORMS = ["climate", "water_heater"]
|
||||
DOMAIN = "vicare"
|
||||
VICARE_API = "api"
|
||||
VICARE_NAME = "name"
|
||||
VICARE_HEATING_TYPE = "heating_type"
|
||||
|
||||
CONF_CIRCUIT = "circuit"
|
||||
CONF_HEATING_TYPE = "heating_type"
|
||||
DEFAULT_HEATING_TYPE = "generic"
|
||||
|
||||
|
||||
class HeatingType(enum.Enum):
|
||||
"""Possible options for heating type."""
|
||||
|
||||
generic = "generic"
|
||||
gas = "gas"
|
||||
heatpump = "heatpump"
|
||||
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
@ -26,6 +42,9 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
vol.Required(CONF_PASSWORD): cv.string,
|
||||
vol.Optional(CONF_CIRCUIT): int,
|
||||
vol.Optional(CONF_NAME, default="ViCare"): cv.string,
|
||||
vol.Optional(CONF_HEATING_TYPE, default=DEFAULT_HEATING_TYPE): cv.enum(
|
||||
HeatingType
|
||||
),
|
||||
}
|
||||
)
|
||||
},
|
||||
@ -40,7 +59,14 @@ def setup(hass, config):
|
||||
if conf.get(CONF_CIRCUIT) is not None:
|
||||
params["circuit"] = conf[CONF_CIRCUIT]
|
||||
|
||||
heating_type = conf[CONF_HEATING_TYPE]
|
||||
|
||||
try:
|
||||
if heating_type == HeatingType.gas:
|
||||
vicare_api = GazBoiler(conf[CONF_USERNAME], conf[CONF_PASSWORD], **params)
|
||||
elif heating_type == HeatingType.heatpump:
|
||||
vicare_api = HeatPump(conf[CONF_USERNAME], conf[CONF_PASSWORD], **params)
|
||||
else:
|
||||
vicare_api = Device(conf[CONF_USERNAME], conf[CONF_PASSWORD], **params)
|
||||
except AttributeError:
|
||||
_LOGGER.error(
|
||||
@ -51,6 +77,7 @@ def setup(hass, config):
|
||||
hass.data[DOMAIN] = {}
|
||||
hass.data[DOMAIN][VICARE_API] = vicare_api
|
||||
hass.data[DOMAIN][VICARE_NAME] = conf[CONF_NAME]
|
||||
hass.data[DOMAIN][VICARE_HEATING_TYPE] = heating_type
|
||||
|
||||
for platform in VICARE_PLATFORMS:
|
||||
discovery.load_platform(hass, platform, DOMAIN, {}, config)
|
||||
|
@ -10,12 +10,16 @@ from homeassistant.components.climate.const import (
|
||||
HVAC_MODE_OFF,
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_AUTO,
|
||||
CURRENT_HVAC_HEAT,
|
||||
CURRENT_HVAC_IDLE,
|
||||
)
|
||||
from homeassistant.const import TEMP_CELSIUS, ATTR_TEMPERATURE, PRECISION_WHOLE
|
||||
|
||||
from . import DOMAIN as VICARE_DOMAIN
|
||||
from . import VICARE_API
|
||||
from . import VICARE_NAME
|
||||
from . import VICARE_HEATING_TYPE
|
||||
from . import HeatingType
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -77,15 +81,22 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
if discovery_info is None:
|
||||
return
|
||||
vicare_api = hass.data[VICARE_DOMAIN][VICARE_API]
|
||||
heating_type = hass.data[VICARE_DOMAIN][VICARE_HEATING_TYPE]
|
||||
add_entities(
|
||||
[ViCareClimate(f"{hass.data[VICARE_DOMAIN][VICARE_NAME]} Heating", vicare_api)]
|
||||
[
|
||||
ViCareClimate(
|
||||
f"{hass.data[VICARE_DOMAIN][VICARE_NAME]} Heating",
|
||||
vicare_api,
|
||||
heating_type,
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class ViCareClimate(ClimateDevice):
|
||||
"""Representation of the ViCare heating climate device."""
|
||||
|
||||
def __init__(self, name, api):
|
||||
def __init__(self, name, api, heating_type):
|
||||
"""Initialize the climate device."""
|
||||
self._name = name
|
||||
self._state = None
|
||||
@ -95,6 +106,8 @@ class ViCareClimate(ClimateDevice):
|
||||
self._current_mode = None
|
||||
self._current_temperature = None
|
||||
self._current_program = None
|
||||
self._heating_type = heating_type
|
||||
self._current_action = None
|
||||
|
||||
def update(self):
|
||||
"""Let HA know there has been an update from the ViCare API."""
|
||||
@ -117,7 +130,7 @@ class ViCareClimate(ClimateDevice):
|
||||
|
||||
self._current_mode = self._api.getActiveMode()
|
||||
|
||||
# Update the device attributes
|
||||
# Update the generic device attributes
|
||||
self._attributes = {}
|
||||
self._attributes["room_temperature"] = _room_temperature
|
||||
self._attributes["supply_temperature"] = _supply_temperature
|
||||
@ -136,6 +149,18 @@ class ViCareClimate(ClimateDevice):
|
||||
"circulationpump_active"
|
||||
] = self._api.getCirculationPumpActive()
|
||||
|
||||
# Update the specific device attributes
|
||||
if self._heating_type == HeatingType.gas:
|
||||
self._current_action = self._api.getBurnerActive()
|
||||
|
||||
self._attributes["burner_modulation"] = self._api.getBurnerModulation()
|
||||
self._attributes["boiler_temperature"] = self._api.getBoilerTemperature()
|
||||
|
||||
elif self._heating_type == HeatingType.heatpump:
|
||||
self._current_action = self._api.getCompressorActive()
|
||||
|
||||
self._attributes["return_temperature"] = self._api.getReturnTemperature()
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
@ -183,6 +208,13 @@ class ViCareClimate(ClimateDevice):
|
||||
"""Return the list of available hvac modes."""
|
||||
return list(HA_TO_VICARE_HVAC_HEATING)
|
||||
|
||||
@property
|
||||
def hvac_action(self):
|
||||
"""Return the current hvac action."""
|
||||
if self._current_action:
|
||||
return CURRENT_HVAC_HEAT
|
||||
return CURRENT_HVAC_IDLE
|
||||
|
||||
@property
|
||||
def min_temp(self):
|
||||
"""Return the minimum temperature."""
|
||||
|
@ -4,6 +4,6 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/vicare",
|
||||
"dependencies": [],
|
||||
"codeowners": ["@oischinger"],
|
||||
"requirements": ["PyViCare==0.1.1"]
|
||||
"requirements": ["PyViCare==0.1.2"]
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ from homeassistant.const import TEMP_CELSIUS, ATTR_TEMPERATURE, PRECISION_WHOLE
|
||||
from . import DOMAIN as VICARE_DOMAIN
|
||||
from . import VICARE_API
|
||||
from . import VICARE_NAME
|
||||
from . import VICARE_HEATING_TYPE
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -46,22 +47,31 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
if discovery_info is None:
|
||||
return
|
||||
vicare_api = hass.data[VICARE_DOMAIN][VICARE_API]
|
||||
heating_type = hass.data[VICARE_DOMAIN][VICARE_HEATING_TYPE]
|
||||
add_entities(
|
||||
[ViCareWater(f"{hass.data[VICARE_DOMAIN][VICARE_NAME]} Water", vicare_api)]
|
||||
[
|
||||
ViCareWater(
|
||||
f"{hass.data[VICARE_DOMAIN][VICARE_NAME]} Water",
|
||||
vicare_api,
|
||||
heating_type,
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class ViCareWater(WaterHeaterDevice):
|
||||
"""Representation of the ViCare domestic hot water device."""
|
||||
|
||||
def __init__(self, name, api):
|
||||
def __init__(self, name, api, heating_type):
|
||||
"""Initialize the DHW water_heater device."""
|
||||
self._name = name
|
||||
self._state = None
|
||||
self._api = api
|
||||
self._attributes = {}
|
||||
self._target_temperature = None
|
||||
self._current_temperature = None
|
||||
self._current_mode = None
|
||||
self._heating_type = heating_type
|
||||
|
||||
def update(self):
|
||||
"""Let HA know there has been an update from the ViCare API."""
|
||||
|
@ -78,7 +78,7 @@ PySocks==1.7.1
|
||||
PyTransportNSW==0.1.1
|
||||
|
||||
# homeassistant.components.vicare
|
||||
PyViCare==0.1.1
|
||||
PyViCare==0.1.2
|
||||
|
||||
# homeassistant.components.xiaomi_aqara
|
||||
PyXiaomiGateway==0.12.4
|
||||
|
Loading…
x
Reference in New Issue
Block a user