Support for Entity.available in sensor/rest (#10073)

This commit is contained in:
pezinek authored and Fabian Affolter committed 2017-10-23 23:29:41 +02:00
1 parent 74e93e5853
commit d1424714c7
2 files changed
+12 -8

No files matched your search

+5 -4
View File
@@ -68,10 +68,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
rest = RestData(method, resource, auth, headers, payload, verify_ssl)
rest.update()
if rest.data is None:
_LOGGER.error("Unable to fetch REST data")
return False
add_devices([RestSensor(hass, rest, name, unit, value_template)], True)
@@ -97,6 +93,11 @@ class RestSensor(Entity):
"""Return the unit the value is expressed in."""
return self._unit_of_measurement
@property
def available(self):
"""Return if the sensor data are available."""
return self.rest.data is not None
@property
def state(self):
"""Return the state of the device."""