From d773ad1ecbfc332b5af421c1b782887b5c00360e Mon Sep 17 00:00:00 2001 From: MartinHjelmare Date: Sat, 6 Feb 2016 09:18:12 +0100 Subject: [PATCH] Fix mysensors version errors * The application of the version check in unit_of_measurement was messed up after the last refactor. Fix that again. * An error could occur in device_state_attributes if there was a mismatch between used value_type in the device and mysensors version in config. Add try... except to handle that. Bump pyvera version. Bump pywemo version. Add unavailable status before properly initialised for maker and insight. --- homeassistant/components/light/vera.py | 2 +- homeassistant/components/sensor/vera.py | 2 +- homeassistant/components/switch/vera.py | 2 +- homeassistant/components/switch/wemo.py | 14 +++++++++++++- requirements_all.txt | 4 ++-- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index 46b4e7c7da8..48e84e5cfb4 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -15,7 +15,7 @@ from homeassistant.components.light import ATTR_BRIGHTNESS from homeassistant.const import EVENT_HOMEASSISTANT_STOP, STATE_ON -REQUIREMENTS = ['pyvera==0.2.7'] +REQUIREMENTS = ['pyvera==0.2.8'] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index c587764ae2e..fe003030e0c 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -15,7 +15,7 @@ from homeassistant.const import ( ATTR_BATTERY_LEVEL, ATTR_TRIPPED, ATTR_ARMED, ATTR_LAST_TRIP_TIME, TEMP_CELCIUS, TEMP_FAHRENHEIT, EVENT_HOMEASSISTANT_STOP) -REQUIREMENTS = ['pyvera==0.2.7'] +REQUIREMENTS = ['pyvera==0.2.8'] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index 3626175c03c..0655f29bbbf 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -21,7 +21,7 @@ from homeassistant.const import ( STATE_ON, STATE_OFF) -REQUIREMENTS = ['pyvera==0.2.7'] +REQUIREMENTS = ['pyvera==0.2.8'] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/switch/wemo.py b/homeassistant/components/switch/wemo.py index d828e23464c..c6d92818466 100644 --- a/homeassistant/components/switch/wemo.py +++ b/homeassistant/components/switch/wemo.py @@ -12,7 +12,7 @@ from homeassistant.components.switch import SwitchDevice from homeassistant.const import ( STATE_ON, STATE_OFF, STATE_STANDBY, EVENT_HOMEASSISTANT_STOP) -REQUIREMENTS = ['pywemo==0.3.8'] +REQUIREMENTS = ['pywemo==0.3.9'] _LOGGER = logging.getLogger(__name__) _WEMO_SUBSCRIPTION_REGISTRY = None @@ -153,6 +153,18 @@ class WemoSwitch(SwitchDevice): """ True if switch is on. """ return self.wemo.get_state() + @property + def available(self): + """ True if switch is available. """ + if (self.wemo.model_name == 'Insight' and + self.insight_params is None): + return False + + if (self.wemo.model_name == 'Maker' and + self.maker_params is None): + return False + return True + def turn_on(self, **kwargs): """ Turns the switch on. """ self.wemo.on() diff --git a/requirements_all.txt b/requirements_all.txt index 23a758240a5..29baf410151 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -196,10 +196,10 @@ pyuserinput==0.1.9 # homeassistant.components.light.vera # homeassistant.components.sensor.vera # homeassistant.components.switch.vera -pyvera==0.2.7 +pyvera==0.2.8 # homeassistant.components.switch.wemo -pywemo==0.3.8 +pywemo==0.3.9 # homeassistant.components.thermostat.radiotherm radiotherm==1.2