From e1eab214ad67a88a2e4a25a1ee82fe1a8c502ecf Mon Sep 17 00:00:00 2001 From: David Bonnes Date: Tue, 29 Oct 2019 21:29:39 +0000 Subject: [PATCH] allow multiple heaters per incomfort gateway (#28324) * add multiple heaters per gateway * bump client to handle the above --- homeassistant/components/incomfort/__init__.py | 5 +++-- homeassistant/components/incomfort/binary_sensor.py | 7 ++++--- homeassistant/components/incomfort/climate.py | 6 ++++-- homeassistant/components/incomfort/manifest.json | 2 +- homeassistant/components/incomfort/sensor.py | 10 ++++------ homeassistant/components/incomfort/water_heater.py | 4 ++-- requirements_all.txt | 2 +- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/incomfort/__init__.py b/homeassistant/components/incomfort/__init__.py index adf57e35093..bb115650061 100644 --- a/homeassistant/components/incomfort/__init__.py +++ b/homeassistant/components/incomfort/__init__.py @@ -44,12 +44,13 @@ async def async_setup(hass, hass_config): ) try: - heater = incomfort_data["heater"] = list(await client.heaters)[0] + heaters = incomfort_data["heaters"] = list(await client.heaters) except ClientResponseError as err: _LOGGER.warning("Setup failed, check your configuration, message is: %s", err) return False - await heater.update() + for heater in heaters: + await heater.update() for platform in ["water_heater", "binary_sensor", "sensor", "climate"]: hass.async_create_task( diff --git a/homeassistant/components/incomfort/binary_sensor.py b/homeassistant/components/incomfort/binary_sensor.py index b5dbd8e223d..150515cbbf5 100644 --- a/homeassistant/components/incomfort/binary_sensor.py +++ b/homeassistant/components/incomfort/binary_sensor.py @@ -11,9 +11,10 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= if discovery_info is None: return - async_add_entities( - [IncomfortFailed(hass.data[DOMAIN]["client"], hass.data[DOMAIN]["heater"])] - ) + client = hass.data[DOMAIN]["client"] + heaters = hass.data[DOMAIN]["heaters"] + + async_add_entities([IncomfortFailed(client, h) for h in heaters]) class IncomfortFailed(IncomfortChild, BinarySensorDevice): diff --git a/homeassistant/components/incomfort/climate.py b/homeassistant/components/incomfort/climate.py index 95ccf186372..23bda6b2fdf 100644 --- a/homeassistant/components/incomfort/climate.py +++ b/homeassistant/components/incomfort/climate.py @@ -17,9 +17,11 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= return client = hass.data[DOMAIN]["client"] - heater = hass.data[DOMAIN]["heater"] + heaters = hass.data[DOMAIN]["heaters"] - async_add_entities([InComfortClimate(client, heater, r) for r in heater.rooms]) + async_add_entities( + [InComfortClimate(client, h, r) for h in heaters for r in h.rooms] + ) class InComfortClimate(IncomfortChild, ClimateDevice): diff --git a/homeassistant/components/incomfort/manifest.json b/homeassistant/components/incomfort/manifest.json index 4bdf43f8957..45365c7e354 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/integrations/incomfort", "requirements": [ - "incomfort-client==0.3.5" + "incomfort-client==0.4.0" ], "dependencies": [], "codeowners": [ diff --git a/homeassistant/components/incomfort/sensor.py b/homeassistant/components/incomfort/sensor.py index f3170b7b9bb..4164225b0d7 100644 --- a/homeassistant/components/incomfort/sensor.py +++ b/homeassistant/components/incomfort/sensor.py @@ -29,14 +29,12 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= return client = hass.data[DOMAIN]["client"] - heater = hass.data[DOMAIN]["heater"] + heaters = hass.data[DOMAIN]["heaters"] async_add_entities( - [ - IncomfortPressure(client, heater, INCOMFORT_PRESSURE), - IncomfortTemperature(client, heater, INCOMFORT_HEATER_TEMP), - IncomfortTemperature(client, heater, INCOMFORT_TAP_TEMP), - ] + [IncomfortPressure(client, h, INCOMFORT_PRESSURE) for h in heaters] + + [IncomfortTemperature(client, h, INCOMFORT_HEATER_TEMP) for h in heaters] + + [IncomfortTemperature(client, h, INCOMFORT_TAP_TEMP) for h in heaters] ) diff --git a/homeassistant/components/incomfort/water_heater.py b/homeassistant/components/incomfort/water_heater.py index 0015107b40f..9096a7cb72c 100644 --- a/homeassistant/components/incomfort/water_heater.py +++ b/homeassistant/components/incomfort/water_heater.py @@ -22,9 +22,9 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= return client = hass.data[DOMAIN]["client"] - heater = hass.data[DOMAIN]["heater"] + heaters = hass.data[DOMAIN]["heaters"] - async_add_entities([IncomfortWaterHeater(client, heater)]) + async_add_entities([IncomfortWaterHeater(client, h) for h in heaters]) class IncomfortWaterHeater(IncomfortEntity, WaterHeaterDevice): diff --git a/requirements_all.txt b/requirements_all.txt index eb1db77263e..51f7d0816c7 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -694,7 +694,7 @@ iglo==1.2.7 ihcsdk==2.3.0 # homeassistant.components.incomfort -incomfort-client==0.3.5 +incomfort-client==0.4.0 # homeassistant.components.influxdb influxdb==5.2.3