Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tado service set temperature offset #45014

Merged
merged 12 commits into from
Jan 26, 2021
7 changes: 7 additions & 0 deletions homeassistant/components/tado/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ def update_sensor(self, sensor_type, sensor):
try:
if sensor_type == "device":
data = self.tado.getDeviceInfo(sensor)
if (
"INSIDE_TEMPERATURE_MEASUREMENT"
in data["characteristics"]["capabilities"]
):
data["TEMP_OFFSET"] = self.tado.getDeviceInfo(
sensor, "temperatureOffset"
)
elif sensor_type == "zone":
data = self.tado.getZoneState(sensor)
else:
Expand Down
15 changes: 15 additions & 0 deletions homeassistant/components/tado/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ def __init__(

self._tado_zone_data = None

self._tado_zone_temp_offset = dict()
MartinHjelmare marked this conversation as resolved.
Show resolved Hide resolved

self._async_update_zone_data()

async def async_added_to_hass(self):
Expand Down Expand Up @@ -457,6 +459,11 @@ def swing_modes(self):
return [TADO_SWING_ON, TADO_SWING_OFF]
return None

@property
def device_state_attributes(self):
"""Return temperature offset."""
return self._tado_zone_temp_offset

def set_swing_mode(self, swing_mode):
"""Set swing modes for the device."""
self._control_hvac(swing_mode=swing_mode)
Expand All @@ -465,11 +472,19 @@ def set_swing_mode(self, swing_mode):
def _async_update_zone_data(self):
"""Load tado data into zone."""
self._tado_zone_data = self._tado.data["zone"][self.zone_id]
self._update_offset()
self._current_tado_fan_speed = self._tado_zone_data.current_fan_speed
self._current_tado_hvac_mode = self._tado_zone_data.current_hvac_mode
self._current_tado_hvac_action = self._tado_zone_data.current_hvac_action
self._current_tado_swing_mode = self._tado_zone_data.current_swing_mode

def _update_offset(self):
MartinHjelmare marked this conversation as resolved.
Show resolved Hide resolved
# Add 'offset' to the key so its named correctly as an attribute in HA
for key in self._tado.data["device"][self._device_id]["TEMP_OFFSET"]:
self._tado_zone_temp_offset["offset_" + key] = self._tado.data["device"][
MartinHjelmare marked this conversation as resolved.
Show resolved Hide resolved
self._device_id
]["TEMP_OFFSET"][key]

@callback
def _async_update_callback(self):
"""Load tado data and update state."""
Expand Down