From 75775a561bcc22b6dafe31340c24bf264ad9d4ef Mon Sep 17 00:00:00 2001 From: MartinHjelmare Date: Tue, 2 Feb 2016 03:47:03 +0100 Subject: [PATCH] Use entity property available --- homeassistant/components/sensor/mysensors.py | 5 +++++ homeassistant/components/switch/mysensors.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/homeassistant/components/sensor/mysensors.py b/homeassistant/components/sensor/mysensors.py index 62b68ab41b8..76a52ea75b2 100644 --- a/homeassistant/components/sensor/mysensors.py +++ b/homeassistant/components/sensor/mysensors.py @@ -180,6 +180,11 @@ class MySensorsSensor(Entity): self.gateway.version) return attr + @property + def available(self): + """Return True if entity is available.""" + return self.value_type in self._values + def update(self): """Update the controller with the latest values from a sensor.""" node = self.gateway.sensors[self.node_id] diff --git a/homeassistant/components/switch/mysensors.py b/homeassistant/components/switch/mysensors.py index 9768f57f23a..a50266b2597 100644 --- a/homeassistant/components/switch/mysensors.py +++ b/homeassistant/components/switch/mysensors.py @@ -140,6 +140,11 @@ class MySensorsSwitch(SwitchDevice): self._values[self.value_type] = STATE_OFF self.update_ha_state() + @property + def available(self): + """Return True if entity is available.""" + return self.value_type in self._values + def update(self): """Update the controller with the latest value from a sensor.""" node = self.gateway.sensors[self.node_id]