core/homeassistant/components/binary_sensor
Greg Laabs 1c8b5838cd ISY994 sensor improvements (#10805)
* Fire events for ISY994 control events

This allows hass to react directly to Insteon button presses (on switches and remotes), including presses, double-presses, and long holds

* Move change event subscription to after entity is added to hass

The event handler method requires `self.hass` to exist, which doesn't have a value until the async_added_to_hass method is called. Should eliminate a race condition.

* Overhaul binary sensors in ISY994 to be functional "out of the box"

We now smash all of the subnodes from the ISY994 in to one Hass binary_sensor, and automatically support both paradigms of state reporting that Insteon sensors can do. Sometimes a single node's state represents the sensor's state, other times two nodes are used and only "ON" events are sent from each. The logic between the two forunately do not conflict so we can support both without knowing which mode the device is in.

This also allows us to handle the heartbeat functionality that certain sensors have - we simply store the timestamp of the heartbeat as an attribute on the sensor device. It defaults to Unknown on bootup if and only if the device supports heartbeats, due to the presence of subnode 4.

* Parse the binary sensor device class from the ISY's device "type"

Now we automatically know which sensors are moisture, motion, and openings! (We also reverse the moisture sensor state, because Insteon reports ON for dry on the primary node.)

* Code review tweaks

The one material change here is that the event subscribers were moved to the `async_added_to_hass` method, as the handlers depend on things that only exist after the entity has been added.

* Handle cases where a sensor's state is unknown

When the ISY first boots up, if a battery-powered sensor has not reported in yet (due to heartbeat or a change in state), the state is unknown until it does.

* Clean up from code review

Fix coroutine await, remove unnecessary exception check, and return None when state is unknown

* Unknown value from PyISY is now -inf rather than -1

* Move heartbeat handling to a separate sensor

Now all heartbeat-compatible sensors will have a separate `binary_sensor` device that represents the battery state (on = dead)

* Add support for Unknown state, which is being added in next PyISY 

PyISY will report unknown states as the number "-inf". This is implemented in the base ISY994 component, but subcomponents that override the `state` method needed some extra logic to handle it as well.

* Change a couple try blocks to explicit None checks

* Bump PyISY to 1.1.0, now that it has been published!

* Remove -inf checking from base component

The implementation of the -inf checking was improved in another branch which has been merged in to this branch already.

* Restrict negative-node and heartbeat support to known compatible types

Not all Insteon sensors use the same subnode IDs for the same things, so we need to use different logic depending on device type. Negative node and heartbeat support is now only used for leak sensors and open/close sensors.

* Use new style string formatting

* Add binary sensor detection for pre-5.x firmware

Meant to do this originally; writing documentation revealed that this requirement was missed!
2017-12-13 20:14:56 -08:00
..
__init__.py Add problem device class (#11130) 2017-12-13 20:02:24 -08:00
abode.py Abode services, events, lights, cameras, automations, quick actions. (#9310) 2017-09-18 17:39:41 +02:00
ads.py Add ADS component (#10142) 2017-12-05 09:44:22 +01:00
alarmdecoder.py Cleanup and simplitfy the async state update (#9390) 2017-09-12 10:01:03 +02:00
android_ip_webcam.py Update docstrings (#7361) 2017-04-29 22:04:49 -07:00
apcupsd.py Do not call update() in constructor (#8878) 2017-08-08 20:21:33 +02:00
arest.py Remove deprecated sensor_class config options (#8702) 2017-07-29 19:46:27 -04:00
aurora.py Use constants for HTTP headers (#10313) 2017-11-04 12:04:05 -07:00
axis.py WIP: Refactor Axis component removing external dependencies (#9791) 2017-10-25 00:04:30 -07:00
bayesian.py Use constants and update docstrings 2017-10-24 09:12:01 +02:00
bbb_gpio.py Update docstrings (#7361) 2017-04-29 22:04:49 -07:00
blink.py Update docstrings (#7361) 2017-04-29 22:04:49 -07:00
bloomsky.py Do not call update() in constructor (#8878) 2017-08-08 20:21:33 +02:00
command_line.py Added possibilities to use template in the command_line sensor (#8505) 2017-08-10 18:52:52 +02:00
concord232.py Do not call update() in constructor (#8878) 2017-08-08 20:21:33 +02:00
demo.py Update docstrings (#7361) 2017-04-29 22:04:49 -07:00
digital_ocean.py Remove deprecated sensor_class config options (#8702) 2017-07-29 19:46:27 -04:00
doorbird.py DoorBird Component (#9281) 2017-09-17 20:47:30 +02:00
ecobee.py Do not call update() in constructor (#8878) 2017-08-08 20:21:33 +02:00
eight_sleep.py Update docstrings (#7405) 2017-05-02 22:47:20 +02:00
enocean.py Remove deprecated sensor_class config options (#8702) 2017-07-29 19:46:27 -04:00
envisalink.py Cleanup and simplitfy the async state update (#9390) 2017-09-12 10:01:03 +02:00
ffmpeg_motion.py Cleanup and simplitfy the async state update (#9390) 2017-09-12 10:01:03 +02:00
ffmpeg_noise.py Update docstrings (#7361) 2017-04-29 22:04:49 -07:00
flic.py Fix pylint 1.7.2 no-else-return issues (#8361) 2017-07-05 23:30:01 -07:00
gc100.py Add gc100 platforms and component (#10159) 2017-10-30 08:40:14 +01:00
hikvision.py Bump pyHik version to add IO support (#9341) 2017-09-09 00:06:06 -07:00
hive.py New Hive Component / Platforms (#9804) 2017-11-23 13:10:23 +01:00
homematic.py Upgrade HomeMatic, add devices (#10845) 2017-11-28 23:16:47 -08:00
insteon_plm.py Fix a bunch of typos (#9545) 2017-09-23 17:15:46 +02:00
iss.py Move 'show_on_map' to const (#9727) 2017-10-07 15:11:41 +02:00
isy994.py ISY994 sensor improvements (#10805) 2017-12-13 20:14:56 -08:00
knx.py renamed add_devices to async_add_devices according to hass naming scheme (second try after failed #9485) (#9505) 2017-09-20 01:15:20 -04:00
linode.py Linode (#9936) 2017-10-27 16:19:47 +02:00
maxcube.py Update docstrings (#7361) 2017-04-29 22:04:49 -07:00
modbus.py Modbus fixes to work with pymodbus 1.3.1 (#8365) 2017-07-06 22:30:23 -07:00
mqtt.py MQTT Binary Sensor - Add availability_topic for online/offline status (#9507) 2017-09-21 17:02:11 +02:00
mysensors.py Refactor mysensors callback and add validation (#9069) 2017-08-25 08:58:05 -07:00
mystrom.py Cleanup and simplitfy the async state update (#9390) 2017-09-12 10:01:03 +02:00
nest.py Update docstrings (#7361) 2017-04-29 22:04:49 -07:00
netatmo.py Fix missing timeout for Netatmo binary sensor (#9850) 2017-10-18 14:56:24 +02:00
nx584.py Update docstrings (#7361) 2017-04-29 22:04:49 -07:00
octoprint.py Do not call update() in constructor (#8878) 2017-08-08 20:21:33 +02:00
pilight.py Allow Pilight Binary Sensor to control reset_delay_sec through configuration (#8358) 2017-07-06 21:09:31 +02:00
ping.py Remove deprecated sensor_class config options (#8702) 2017-07-29 19:46:27 -04:00
raincloud.py Bump raincloudy version 0.0.3 (#9767) 2017-10-08 21:08:40 -07:00
random.py Add Random binary sensor (#10164) 2017-10-29 11:15:57 +01:00
raspihats.py Add raspihats binary sensor (#7508) 2017-05-12 09:20:48 -07:00
rest.py Do not call update() in constructor (#8881) 2017-08-08 06:52:27 +02:00
rfxtrx.py Rfxtrx binary sensor rewrite (#10152) 2017-10-27 10:01:46 +02:00
ring.py Fixed update() method and removed `ding` feature from stickupcams/floodlight (#10428) 2017-11-09 01:01:20 +01:00
rpi_gpio.py Update docstrings (#7361) 2017-04-29 22:04:49 -07:00
rpi_pfio.py Support for the PiFace Digital I/O module (#7494) 2017-05-09 22:36:33 -07:00
satel_integra.py Added satel_integra alarm panel and binary sensor platform (#9336) 2017-09-18 17:42:31 +02:00
skybell.py Skybell (#9681) 2017-10-08 20:14:39 +02:00
sleepiq.py Update docstrings (#7361) 2017-04-29 22:04:49 -07:00
spc.py Add attribute to show who last un/set alarm (SPC) (#9906) 2017-11-11 12:36:03 -08:00
tapsaff.py Added a Taps Aff binary sensor (#7880) 2017-06-04 13:35:19 +02:00
tcp.py Update docstrings (#7361) 2017-04-29 22:04:49 -07:00
tellduslive.py Telldus Live: Device without methods is a binary sensor (#10106) 2017-10-26 15:54:49 +02:00
template.py Fix async probs (#9924) 2017-10-19 10:56:25 +02:00
tesla.py Tesla bug fixes. (#9774) 2017-10-09 14:38:00 +03:00
threshold.py Add hysteresis attribute to threshold binary sensor (#9596) 2017-10-02 17:15:19 +02:00
trend.py Binary sensor for detecting linear trends (#9808) 2017-10-25 17:33:17 +02:00
velbus.py Velbus (#8076) 2017-07-26 14:03:29 +02:00
vera.py Added Vera scenes (#10424) 2017-12-07 07:47:19 +01:00
verisure.py verisure component names (#8251) 2017-06-30 08:53:14 +02:00
volvooncall.py Remove deprecated sensor_class config options (#8702) 2017-07-29 19:46:27 -04:00
vultr.py Add platform and sensors for Vultr VPS (#9928) 2017-11-05 14:10:14 +01:00
wemo.py Update docstrings (#7361) 2017-04-29 22:04:49 -07:00
wink.py Added super attributes to Wink binary sensors (#9824) 2017-10-16 14:58:23 +02:00
workday.py Workday sensor offset (#8824) 2017-08-21 13:24:30 +02:00
xiaomi_aqara.py Add last action to xiaomi aqara button (#10131) 2017-10-26 18:46:29 +02:00
zha.py zha: Handle both input and output clusters (#8410) 2017-07-10 21:16:44 -07:00
zigbee.py Update docstrings (#7361) 2017-04-29 22:04:49 -07:00
zwave.py Fix off_delay for zwave trigger sensors (#8864) 2017-08-06 18:31:32 +03:00