Add basic support for native Hue sensors (#22598)

* Add basic support for native Hue sensors

* Update coveragerc

* Simplify attributes

* Remove config option

* Refactor and document device-ness and update mechanism

* Entity docstrings

* Remove lingering config for sensors

* Whitespace

* Remove redundant entity ID generation and hass assignment.

* More meaningful variable name.

* Add new 'not-darkness' pseudo-sensor.

* Refactor sensors into separate binary, non-binary, and shared modules.

* formatting

* make linter happy.

* Refactor again, fix update mechanism, and address comments.

* Remove unnecessary assignment

* Small fixes.

* docstring

* Another refactor: only call API once and make testing easier

* Tests & test fixes

* Flake & lint

* Use gather and dispatcher

* Remove unnecessary whitespace change.

* Move component related stuff out of the shared module

* Remove unused remnant of failed approach.

* Increase test coverage

* Don't get too upset if we're already trying to update an entity before it has finished adding

* relative imports
This commit is contained in:
Richard Mitchell authored and Paulus Schoutsen committed 2019-04-17 22:13:03 -07:00
1 parent 77244eab1e
commit 474ac8b09e
6 files changed
+875 -7

No files matched your search

@@ -0,0 +1,27 @@
"""Hue binary sensor entities."""
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.hue.sensor_base import (
GenericZLLSensor, async_setup_entry as shared_async_setup_entry)
PRESENCE_NAME_FORMAT = "{} presence"
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Defer binary sensor setup to the shared sensor module."""
await shared_async_setup_entry(
hass, config_entry, async_add_entities, binary=True)
class HuePresence(GenericZLLSensor, BinarySensorDevice):
"""The presence sensor entity for a Hue motion sensor device."""
device_class = 'presence'
async def _async_update_ha_state(self, *args, **kwargs):
await self.async_update_ha_state(self, *args, **kwargs)
@property
def is_on(self):
"""Return true if the binary sensor is on."""
return self.sensor.presence