1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 04:50:05 +00:00

Fix deConz thermostat integration (#26267)

* Fixed logger name to allow selective logging

* Fixed thermostat mode ('off' and 'heat' modes were not consistent with Eurotronic Spirit Zigbee Thermostat state) and added 'auto' to supported mode

* Added required blank lines in code

* Black formatting

* Revert logging code added to each files. Instead, only replaced "." by __package__ in const.py

* Added a test on self._device.state_on to determine hvac_mode

* Black formatting

* Added debug message when unsupported hvac_mode is encountered

* Applied formatting recommandations

* Updated tests for 'auto' hvac_mode
This commit is contained in:
5mauggy
2019-08-30 14:28:39 +02:00
committed by Pascal Vizeli
parent ad6ede9ef7
commit 62338dd28e
3 changed files with 23 additions and 8 deletions

View File

@@ -3,6 +3,7 @@ from pydeconz.sensor import Thermostat
from homeassistant.components.climate import ClimateDevice
from homeassistant.components.climate.const import (
HVAC_MODE_AUTO,
HVAC_MODE_HEAT,
HVAC_MODE_OFF,
SUPPORT_TARGET_TEMPERATURE,
@@ -15,7 +16,7 @@ from .const import ATTR_OFFSET, ATTR_VALVE, NEW_SENSOR
from .deconz_device import DeconzDevice
from .gateway import get_gateway_from_config_entry
SUPPORT_HVAC = [HVAC_MODE_HEAT, HVAC_MODE_OFF]
SUPPORT_HVAC = [HVAC_MODE_AUTO, HVAC_MODE_HEAT, HVAC_MODE_OFF]
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
@@ -68,7 +69,9 @@ class DeconzThermostat(DeconzDevice, ClimateDevice):
Need to be one of HVAC_MODE_*.
"""
if self._device.on:
if self._device.mode in SUPPORT_HVAC:
return self._device.mode
if self._device.state_on:
return HVAC_MODE_HEAT
return HVAC_MODE_OFF
@@ -101,8 +104,10 @@ class DeconzThermostat(DeconzDevice, ClimateDevice):
async def async_set_hvac_mode(self, hvac_mode):
"""Set new target hvac mode."""
if hvac_mode == HVAC_MODE_HEAT:
if hvac_mode == HVAC_MODE_AUTO:
data = {"mode": "auto"}
elif hvac_mode == HVAC_MODE_HEAT:
data = {"mode": "heat"}
elif hvac_mode == HVAC_MODE_OFF:
data = {"mode": "off"}