From 68bda1c7321bec5fbf209a22100305efde6be6da Mon Sep 17 00:00:00 2001
From: Heiko Thiery <heiko.thiery@gmail.com>
Date: Mon, 1 Oct 2018 12:53:25 +0200
Subject: [PATCH] Add new device attributes to fritzbox climate (#17027)

* Add new device attributes to fritzbox climate

With Fitz!OS 7 new parameters are introduced.

Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>

* update requirements

Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
---
 homeassistant/components/climate/fritzbox.py | 19 ++++++++++++++++---
 homeassistant/components/fritzbox.py         |  7 +++++--
 requirements_all.txt                         |  2 +-
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/homeassistant/components/climate/fritzbox.py b/homeassistant/components/climate/fritzbox.py
index 3eedb89a3b7..f2d13ee92f6 100644
--- a/homeassistant/components/climate/fritzbox.py
+++ b/homeassistant/components/climate/fritzbox.py
@@ -10,13 +10,15 @@ import requests
 
 from homeassistant.components.fritzbox import DOMAIN as FRITZBOX_DOMAIN
 from homeassistant.components.fritzbox import (
-    ATTR_STATE_DEVICE_LOCKED, ATTR_STATE_BATTERY_LOW, ATTR_STATE_LOCKED)
+    ATTR_STATE_DEVICE_LOCKED, ATTR_STATE_BATTERY_LOW, ATTR_STATE_HOLIDAY_MODE,
+    ATTR_STATE_LOCKED, ATTR_STATE_SUMMER_MODE,
+    ATTR_STATE_WINDOW_OPEN)
 from homeassistant.components.climate import (
     ATTR_OPERATION_MODE, ClimateDevice, STATE_ECO, STATE_HEAT, STATE_MANUAL,
     STATE_OFF, STATE_ON, SUPPORT_OPERATION_MODE,
     SUPPORT_TARGET_TEMPERATURE)
 from homeassistant.const import (
-    ATTR_TEMPERATURE, PRECISION_HALVES, TEMP_CELSIUS)
+    ATTR_BATTERY_LEVEL, ATTR_TEMPERATURE, PRECISION_HALVES, TEMP_CELSIUS)
 DEPENDENCIES = ['fritzbox']
 
 _LOGGER = logging.getLogger(__name__)
@@ -151,10 +153,21 @@ class FritzboxThermostat(ClimateDevice):
     def device_state_attributes(self):
         """Return the device specific state attributes."""
         attrs = {
+            ATTR_STATE_BATTERY_LOW: self._device.battery_low,
             ATTR_STATE_DEVICE_LOCKED: self._device.device_lock,
             ATTR_STATE_LOCKED: self._device.lock,
-            ATTR_STATE_BATTERY_LOW: self._device.battery_low,
         }
+
+        # the following attributes are available since fritzos 7
+        if self._device.battery_level is not None:
+            attrs[ATTR_BATTERY_LEVEL] = self._device.battery_level
+        if self._device.holiday_active is not None:
+            attrs[ATTR_STATE_HOLIDAY_MODE] = self._device.holiday_active
+        if self._device.summer_active is not None:
+            attrs[ATTR_STATE_SUMMER_MODE] = self._device.summer_active
+        if ATTR_STATE_WINDOW_OPEN is not None:
+            attrs[ATTR_STATE_WINDOW_OPEN] = self._device.window_open
+
         return attrs
 
     def update(self):
diff --git a/homeassistant/components/fritzbox.py b/homeassistant/components/fritzbox.py
index a3c35aaa597..49bc4c8f6e6 100644
--- a/homeassistant/components/fritzbox.py
+++ b/homeassistant/components/fritzbox.py
@@ -16,15 +16,18 @@ from homeassistant.helpers import discovery
 
 _LOGGER = logging.getLogger(__name__)
 
-REQUIREMENTS = ['pyfritzhome==0.3.7']
+REQUIREMENTS = ['pyfritzhome==0.4.0']
 
 SUPPORTED_DOMAINS = ['climate', 'switch']
 
 DOMAIN = 'fritzbox'
 
+ATTR_STATE_BATTERY_LOW = 'battery_low'
 ATTR_STATE_DEVICE_LOCKED = 'device_locked'
+ATTR_STATE_HOLIDAY_MODE = 'holiday_mode'
 ATTR_STATE_LOCKED = 'locked'
-ATTR_STATE_BATTERY_LOW = 'battery_low'
+ATTR_STATE_SUMMER_MODE = 'summer_mode'
+ATTR_STATE_WINDOW_OPEN = 'window_open'
 
 
 CONFIG_SCHEMA = vol.Schema({
diff --git a/requirements_all.txt b/requirements_all.txt
index 853e404c8b1..87c8ffdbb0a 100644
--- a/requirements_all.txt
+++ b/requirements_all.txt
@@ -884,7 +884,7 @@ pyflic-homeassistant==0.4.dev0
 pyfnip==0.2
 
 # homeassistant.components.fritzbox
-pyfritzhome==0.3.7
+pyfritzhome==0.4.0
 
 # homeassistant.components.ifttt
 pyfttt==0.3
-- 
GitLab