Mark REST binary_sensor unavailable if request fails (#11506)

* Mark REST binary_sensor unavailable if request fails

* Add test suite for RESTful binary sensor
This commit is contained in:
Dan Nixon 2018-01-11 09:48:15 +00:00 committed by Pascal Vizeli
parent 5fda78cf91
commit 3972d1d4c6
2 changed files with 197 additions and 0 deletions

View file

@ -98,6 +98,11 @@ class RestBinarySensor(BinarySensorDevice):
"""Return the class of this sensor."""
return self._device_class
@property
def available(self):
"""Return the availability of this sensor."""
return self.rest.data is not None
@property
def is_on(self):
"""Return true if the binary sensor is on."""