From 5a7e44664694d940db4c98b456a6c89b5cc7f694 Mon Sep 17 00:00:00 2001 From: Daniel Hoyer Iversen Date: Sat, 3 Dec 2016 23:44:06 +0100 Subject: [PATCH] device tracker --- homeassistant/components/device_tracker/__init__.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/device_tracker/__init__.py b/homeassistant/components/device_tracker/__init__.py index 91f0720e927..eaa0621b04c 100644 --- a/homeassistant/components/device_tracker/__init__.py +++ b/homeassistant/components/device_tracker/__init__.py @@ -332,7 +332,6 @@ class Device(Entity): gps = None # type: GPSType gps_accuracy = 0 last_seen = None # type: dt_util.dt.datetime - battery = None # type: str attributes = None # type: dict vendor = None # type: str @@ -396,9 +395,6 @@ class Device(Entity): attr[ATTR_LONGITUDE] = self.gps[1] attr[ATTR_GPS_ACCURACY] = self.gps_accuracy - if self.battery: - attr[ATTR_BATTERY] = self.battery - if self.attributes: for key, value in self.attributes.items(): attr[key] = value @@ -419,8 +415,13 @@ class Device(Entity): self.host_name = host_name self.location_name = location_name self.gps_accuracy = gps_accuracy or 0 - self.battery = battery - self.attributes = attributes + if (battery or attributes) and self.attributes is None: + self.attributes = {} + if battery: + self.attributes[ATTR_BATTERY] = battery + if attributes: + for key, value in attributes.items(): + self.attributes[key] = value self.gps = None if gps is not None: