From c8d4cf08d99477bbb8cfb6634697af346ddba65e Mon Sep 17 00:00:00 2001 From: jasperro <42558625+jasperro@users.noreply.github.com> Date: Mon, 23 Mar 2020 16:40:15 +0100 Subject: [PATCH] Add Tado set presence (#32765) * Updated tado integration climate.py to allow for presence change * Updated tado integration __init__.py to allow for presence change * Black formatting * Added missing docstring * Added missing period to docstring * Using constants from climate component * Filter out other preset_modes * Linting error fix * Isort error fix * Filtering of unwanted presence mode in init * Bumped python-tado version to 0.5.0 Removed unnecessary preset mode check * Update requirements_all.txt --- homeassistant/components/tado/__init__.py | 10 ++++++++++ homeassistant/components/tado/climate.py | 2 +- homeassistant/components/tado/manifest.json | 2 +- requirements_all.txt | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/tado/__init__.py b/homeassistant/components/tado/__init__.py index 727fb868a33..e5e3d1d409c 100644 --- a/homeassistant/components/tado/__init__.py +++ b/homeassistant/components/tado/__init__.py @@ -6,6 +6,7 @@ import urllib from PyTado.interface import Tado import voluptuous as vol +from homeassistant.components.climate.const import PRESET_AWAY, PRESET_HOME from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.helpers import config_validation as cv from homeassistant.helpers.discovery import load_platform @@ -162,6 +163,15 @@ class TadoConnector: self.tado.resetZoneOverlay(zone_id) self.update_sensor("zone", zone_id) + def set_presence( + self, presence=PRESET_HOME, + ): + """Set the presence to home or away.""" + if presence == PRESET_AWAY: + self.tado.setAway() + elif presence == PRESET_HOME: + self.tado.setHome() + def set_zone_overlay( self, zone_id, diff --git a/homeassistant/components/tado/climate.py b/homeassistant/components/tado/climate.py index b92a54edd5e..e202cc49da4 100644 --- a/homeassistant/components/tado/climate.py +++ b/homeassistant/components/tado/climate.py @@ -289,7 +289,7 @@ class TadoClimate(ClimateDevice): def set_preset_mode(self, preset_mode): """Set new preset mode.""" - pass + self._tado.set_presence(preset_mode) @property def temperature_unit(self): diff --git a/homeassistant/components/tado/manifest.json b/homeassistant/components/tado/manifest.json index e51cc53caa5..ab0be2d4346 100644 --- a/homeassistant/components/tado/manifest.json +++ b/homeassistant/components/tado/manifest.json @@ -3,7 +3,7 @@ "name": "Tado", "documentation": "https://www.home-assistant.io/integrations/tado", "requirements": [ - "python-tado==0.3.0" + "python-tado==0.5.0" ], "dependencies": [], "codeowners": [ diff --git a/requirements_all.txt b/requirements_all.txt index 8bae90ae60c..72bc9d27e7e 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1658,7 +1658,7 @@ python-songpal==0.11.2 python-synology==0.4.0 # homeassistant.components.tado -python-tado==0.3.0 +python-tado==0.5.0 # homeassistant.components.telegram_bot python-telegram-bot==11.1.0