From bfa579f8b27742acc7683c739f90323c754aa0da Mon Sep 17 00:00:00 2001 From: MartinHjelmare Date: Sun, 28 Feb 2016 14:56:07 +0100 Subject: [PATCH] Add assumed_state to mysensors switch and light * Return true for assumed_state if optimistic config setting is true. * Fix PEP257 --- homeassistant/components/light/mysensors.py | 5 +++++ homeassistant/components/mysensors.py | 6 +----- homeassistant/components/switch/mysensors.py | 5 +++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/light/mysensors.py b/homeassistant/components/light/mysensors.py index 906f06e6ab4..2df898ec39b 100644 --- a/homeassistant/components/light/mysensors.py +++ b/homeassistant/components/light/mysensors.py @@ -116,6 +116,11 @@ class MySensorsLight(Light): """Return True if entity is available.""" return self.value_type in self._values + @property + def assumed_state(self): + """Return True if unable to access real state of entity.""" + return self.gateway.optimistic + @property def is_on(self): """True if device is on.""" diff --git a/homeassistant/components/mysensors.py b/homeassistant/components/mysensors.py index 0510dc6cece..2d3c8eb1f53 100644 --- a/homeassistant/components/mysensors.py +++ b/homeassistant/components/mysensors.py @@ -1,9 +1,5 @@ """ -homeassistant.components.mysensors. - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -MySensors component that connects to a MySensors gateway via pymysensors -API. +Connect to a MySensors gateway via pymysensors API. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.mysensors/ diff --git a/homeassistant/components/switch/mysensors.py b/homeassistant/components/switch/mysensors.py index d10ce2eabf2..95da32b743e 100644 --- a/homeassistant/components/switch/mysensors.py +++ b/homeassistant/components/switch/mysensors.py @@ -149,6 +149,11 @@ class MySensorsSwitch(SwitchDevice): """Return True if entity is available.""" return self.value_type in self._values + @property + def assumed_state(self): + """Return True if unable to access real state of entity.""" + return self.gateway.optimistic + def update(self): """Update the controller with the latest value from a sensor.""" node = self.gateway.sensors[self.node_id]