deCONZ - battery sensor instead of battery attribute (#26591)

* Allow all sensors to create battery sensors
* Neither binary sensor, climate nor sensor will have battery attributes
This commit is contained in:
Robert Svensson 2019-09-14 19:15:18 +02:00 committed by GitHub
parent 24f1ff0aef
commit 41c9ed5d51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 48 deletions

View file

@ -2,7 +2,7 @@
from pydeconz.sensor import Presence, Vibration
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.const import ATTR_BATTERY_LEVEL, ATTR_TEMPERATURE
from homeassistant.const import ATTR_TEMPERATURE
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -17,7 +17,6 @@ ATTR_VIBRATIONSTRENGTH = "vibrationstrength"
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Old way of setting up deCONZ platforms."""
pass
async def async_setup_entry(hass, config_entry, async_add_entities):
@ -56,7 +55,7 @@ class DeconzBinarySensor(DeconzDevice, BinarySensorDevice):
def async_update_callback(self, force_update=False):
"""Update the sensor's state."""
changed = set(self._device.changed_keys)
keys = {"battery", "on", "reachable", "state"}
keys = {"on", "reachable", "state"}
if force_update or any(key in changed for key in keys):
self.async_schedule_update_ha_state()
@ -79,8 +78,6 @@ class DeconzBinarySensor(DeconzDevice, BinarySensorDevice):
def device_state_attributes(self):
"""Return the state attributes of the sensor."""
attr = {}
if self._device.battery:
attr[ATTR_BATTERY_LEVEL] = self._device.battery
if self._device.on is not None:
attr[ATTR_ON] = self._device.on