From 0527459b6611c9827dceea62fab8abd442a60f49 Mon Sep 17 00:00:00 2001 From: Chris Kacerguis Date: Thu, 8 Nov 2018 16:41:51 -0600 Subject: [PATCH 1/4] show battery_level as a percent vs a decimal --- homeassistant/components/wirelesstag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/wirelesstag.py b/homeassistant/components/wirelesstag.py index f2832100066152..6fa677ead5faba 100644 --- a/homeassistant/components/wirelesstag.py +++ b/homeassistant/components/wirelesstag.py @@ -271,7 +271,7 @@ def update(self): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_BATTERY_LEVEL: self._tag.battery_remaining, + ATTR_BATTERY_LEVEL: '{:.0%}'.format(self._tag.battery_remaining), ATTR_VOLTAGE: '{:.2f}V'.format(self._tag.battery_volts), ATTR_TAG_SIGNAL_STRENGTH: '{}dBm'.format( self._tag.signal_strength), From d9622c7391a101fea8feabdee48c1630aa340686 Mon Sep 17 00:00:00 2001 From: Chris Kacerguis Date: Sat, 10 Nov 2018 06:49:53 -0600 Subject: [PATCH 2/4] updated to not return the percent sign --- homeassistant/components/wirelesstag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/wirelesstag.py b/homeassistant/components/wirelesstag.py index 6fa677ead5faba..78e950fc26b91f 100644 --- a/homeassistant/components/wirelesstag.py +++ b/homeassistant/components/wirelesstag.py @@ -271,7 +271,7 @@ def update(self): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_BATTERY_LEVEL: '{:.0%}'.format(self._tag.battery_remaining), + ATTR_BATTERY_LEVEL: '{:.0}'.format(self._tag.battery_remaining), ATTR_VOLTAGE: '{:.2f}V'.format(self._tag.battery_volts), ATTR_TAG_SIGNAL_STRENGTH: '{}dBm'.format( self._tag.signal_strength), From 9c9f6bb61a3ddb4cf54e9e9fe3af7fbf274452f1 Mon Sep 17 00:00:00 2001 From: Chris Kacerguis Date: Sat, 10 Nov 2018 10:43:00 -0600 Subject: [PATCH 3/4] multiply my hand (vs format) --- homeassistant/components/wirelesstag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/wirelesstag.py b/homeassistant/components/wirelesstag.py index 78e950fc26b91f..ef0c690a38d8cb 100644 --- a/homeassistant/components/wirelesstag.py +++ b/homeassistant/components/wirelesstag.py @@ -271,7 +271,7 @@ def update(self): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_BATTERY_LEVEL: '{:.0}'.format(self._tag.battery_remaining), + ATTR_BATTERY_LEVEL: self._tag.battery_remaining*100, ATTR_VOLTAGE: '{:.2f}V'.format(self._tag.battery_volts), ATTR_TAG_SIGNAL_STRENGTH: '{}dBm'.format( self._tag.signal_strength), From cb3ce30fc3ddcc474141599018a1fdac011d31b9 Mon Sep 17 00:00:00 2001 From: Chris Kacerguis Date: Sat, 10 Nov 2018 10:59:51 -0600 Subject: [PATCH 4/4] added int to clear out the decimal Thanks for your help @amelchio --- homeassistant/components/wirelesstag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/wirelesstag.py b/homeassistant/components/wirelesstag.py index ef0c690a38d8cb..77b4c48b41b798 100644 --- a/homeassistant/components/wirelesstag.py +++ b/homeassistant/components/wirelesstag.py @@ -271,7 +271,7 @@ def update(self): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_BATTERY_LEVEL: self._tag.battery_remaining*100, + ATTR_BATTERY_LEVEL: int(self._tag.battery_remaining*100), ATTR_VOLTAGE: '{:.2f}V'.format(self._tag.battery_volts), ATTR_TAG_SIGNAL_STRENGTH: '{}dBm'.format( self._tag.signal_strength),