From 1b7bfec2477e98be8b1428085e5d40d1e9943c3e Mon Sep 17 00:00:00 2001
From: Totoo <ttotoo@gmail.com>
Date: Sun, 30 Sep 2018 15:17:39 +0200
Subject: [PATCH] Google Maps supports battery level and charging. (#16969)

* Google Maps supports battery level and charging.

With 3.0.2 locationsharinglib now the battery level and the charging attributes are available.

* Update google_maps.py

fix too long line error

* Update google_maps.py

Fix multi line import, and line length limit

* Update gen_requirements_all.py

Add locationsharinglib to gen_requirements_all

* update requirements_all

* Last try to fix requirements_all...
---
 homeassistant/components/device_tracker/google_maps.py | 8 ++++++--
 requirements_all.txt                                   | 2 +-
 requirements_test_all.txt                              | 3 +++
 script/gen_requirements_all.py                         | 1 +
 4 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/homeassistant/components/device_tracker/google_maps.py b/homeassistant/components/device_tracker/google_maps.py
index 170d3de6800..c0dcd2f00a7 100644
--- a/homeassistant/components/device_tracker/google_maps.py
+++ b/homeassistant/components/device_tracker/google_maps.py
@@ -11,13 +11,15 @@ import voluptuous as vol
 
 from homeassistant.components.device_tracker import (
     PLATFORM_SCHEMA, SOURCE_TYPE_GPS)
-from homeassistant.const import ATTR_ID, CONF_PASSWORD, CONF_USERNAME
+from homeassistant.const import (
+    ATTR_ID, CONF_PASSWORD, CONF_USERNAME, ATTR_BATTERY_CHARGING,
+    ATTR_BATTERY_LEVEL)
 import homeassistant.helpers.config_validation as cv
 from homeassistant.helpers.event import track_time_interval
 from homeassistant.helpers.typing import ConfigType
 from homeassistant.util import slugify, dt as dt_util
 
-REQUIREMENTS = ['locationsharinglib==2.0.11']
+REQUIREMENTS = ['locationsharinglib==3.0.2']
 
 _LOGGER = logging.getLogger(__name__)
 
@@ -94,6 +96,8 @@ class GoogleMapsScanner:
                 ATTR_ID: person.id,
                 ATTR_LAST_SEEN: dt_util.as_utc(person.datetime),
                 ATTR_NICKNAME: person.nickname,
+                ATTR_BATTERY_CHARGING: person.charging,
+                ATTR_BATTERY_LEVEL: person.battery_level
             }
             self.see(
                 dev_id=dev_id,
diff --git a/requirements_all.txt b/requirements_all.txt
index 53d38f09f3b..638599b9642 100644
--- a/requirements_all.txt
+++ b/requirements_all.txt
@@ -558,7 +558,7 @@ liveboxplaytv==2.0.2
 lmnotify==0.0.4
 
 # homeassistant.components.device_tracker.google_maps
-locationsharinglib==2.0.11
+locationsharinglib==3.0.2
 
 # homeassistant.components.logi_circle
 logi_circle==0.1.7
diff --git a/requirements_test_all.txt b/requirements_test_all.txt
index a04f0570ee9..540a200ad32 100644
--- a/requirements_test_all.txt
+++ b/requirements_test_all.txt
@@ -103,6 +103,9 @@ libpurecoollink==0.4.2
 # homeassistant.components.media_player.soundtouch
 libsoundtouch==0.7.2
 
+# homeassistant.components.device_tracker.google_maps
+locationsharinglib==3.0.2
+
 # homeassistant.components.sensor.mfi
 # homeassistant.components.switch.mfi
 mficlient==0.3.0
diff --git a/script/gen_requirements_all.py b/script/gen_requirements_all.py
index 7493e523273..3fca95e1adf 100755
--- a/script/gen_requirements_all.py
+++ b/script/gen_requirements_all.py
@@ -63,6 +63,7 @@ TEST_REQUIREMENTS = (
     'influxdb',
     'libpurecoollink',
     'libsoundtouch',
+    'locationsharinglib',
     'mficlient',
     'numpy',
     'paho-mqtt',
-- 
GitLab