From 2a9fd9ae269e8929084e53ab12901e96aec93e7d Mon Sep 17 00:00:00 2001 From: David Bonnes Date: Sun, 12 May 2019 12:40:10 +0100 Subject: [PATCH] Add incomfort climate and bump client (#23830) * Initial commit * bump client for bugfix * bump client for bugfix 2 * de-lint --- .../components/incomfort/__init__.py | 5 +- homeassistant/components/incomfort/climate.py | 93 +++++++++++++++++++ .../components/incomfort/manifest.json | 2 +- requirements_all.txt | 2 +- 4 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 homeassistant/components/incomfort/climate.py diff --git a/homeassistant/components/incomfort/__init__.py b/homeassistant/components/incomfort/__init__.py index edff8c8299f..8aaa8e7e19d 100644 --- a/homeassistant/components/incomfort/__init__.py +++ b/homeassistant/components/incomfort/__init__.py @@ -44,7 +44,8 @@ async def async_setup(hass, hass_config): exc_info=True) return False - hass.async_create_task(async_load_platform( - hass, 'water_heater', DOMAIN, {}, hass_config)) + for platform in ['water_heater', 'climate']: + hass.async_create_task(async_load_platform( + hass, platform, DOMAIN, {}, hass_config)) return True diff --git a/homeassistant/components/incomfort/climate.py b/homeassistant/components/incomfort/climate.py new file mode 100644 index 00000000000..fa42ced32c2 --- /dev/null +++ b/homeassistant/components/incomfort/climate.py @@ -0,0 +1,93 @@ +"""Support for an Intergas boiler via an InComfort/InTouch Lan2RF gateway.""" +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import SUPPORT_TARGET_TEMPERATURE +from homeassistant.const import (ATTR_TEMPERATURE, TEMP_CELSIUS) +from homeassistant.core import callback +from homeassistant.helpers.dispatcher import async_dispatcher_connect + +from . import DOMAIN + +INTOUCH_SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE + +INTOUCH_MAX_TEMP = 30.0 +INTOUCH_MIN_TEMP = 5.0 + + +async def async_setup_platform(hass, hass_config, async_add_entities, + discovery_info=None): + """Set up an InComfort/InTouch climate device.""" + client = hass.data[DOMAIN]['client'] + heater = hass.data[DOMAIN]['heater'] + + rooms = [InComfortClimate(client, r) + for r in heater.rooms if not r.room_temp] + if rooms: + async_add_entities(rooms) + + +class InComfortClimate(ClimateDevice): + """Representation of an InComfort/InTouch climate device.""" + + def __init__(self, client, room): + """Initialize the climate device.""" + self._client = client + self._room = room + self._name = 'Room {}'.format(room.room_no) + + async def async_added_to_hass(self): + """Set up a listener when this entity is added to HA.""" + async_dispatcher_connect(self.hass, DOMAIN, self._refresh) + + @callback + def _refresh(self): + self.async_schedule_update_ha_state(force_refresh=True) + + @property + def name(self): + """Return the name of the climate device.""" + return self._name + + @property + def device_state_attributes(self): + """Return the device state attributes.""" + return {'status': self._room.status} + + @property + def current_temperature(self): + """Return the current temperature.""" + return self._room.room_temp + + @property + def target_temperature(self): + """Return the temperature we try to reach.""" + return self._room.override + + @property + def min_temp(self): + """Return max valid temperature that can be set.""" + return INTOUCH_MIN_TEMP + + @property + def max_temp(self): + """Return max valid temperature that can be set.""" + return INTOUCH_MAX_TEMP + + @property + def temperature_unit(self): + """Return the unit of measurement.""" + return TEMP_CELSIUS + + @property + def supported_features(self): + """Return the list of supported features.""" + return INTOUCH_SUPPORT_FLAGS + + async def async_set_temperature(self, **kwargs): + """Set a new target temperature for this zone.""" + temperature = kwargs.get(ATTR_TEMPERATURE) + await self._room.set_override(temperature) + + @property + def should_poll(self) -> bool: + """Return False as this device should never be polled.""" + return False diff --git a/homeassistant/components/incomfort/manifest.json b/homeassistant/components/incomfort/manifest.json index 028a741a673..1731c8c942f 100644 --- a/homeassistant/components/incomfort/manifest.json +++ b/homeassistant/components/incomfort/manifest.json @@ -3,7 +3,7 @@ "name": "Intergas InComfort/Intouch Lan2RF gateway", "documentation": "https://www.home-assistant.io/components/incomfort", "requirements": [ - "incomfort-client==0.2.8" + "incomfort-client==0.2.9" ], "dependencies": [], "codeowners": [ diff --git a/requirements_all.txt b/requirements_all.txt index 805056d33d3..5a8a72c7cd4 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -602,7 +602,7 @@ iglo==1.2.7 ihcsdk==2.3.0 # homeassistant.components.incomfort -incomfort-client==0.2.8 +incomfort-client==0.2.9 # homeassistant.components.influxdb influxdb==5.2.0