Hotfix for Fibaro wall plug (#18845)

Fibaro wall plug with a lamp plugged in was misrecognized as a color light, generating crashes in the update function.
pull/18855/head
pbalogh77 2018-11-30 17:23:25 +01:00 committed by Paulus Schoutsen
parent e0f0487ce2
commit 8f50180598
1 changed files with 5 additions and 2 deletions

View File

@ -65,7 +65,8 @@ class FibaroLight(FibaroDevice, Light):
self._update_lock = asyncio.Lock()
if 'levelChange' in fibaro_device.interfaces:
self._supported_flags |= SUPPORT_BRIGHTNESS
if 'color' in fibaro_device.properties:
if 'color' in fibaro_device.properties and \
'setColor' in fibaro_device.actions:
self._supported_flags |= SUPPORT_COLOR
if 'setW' in fibaro_device.actions:
self._supported_flags |= SUPPORT_WHITE_VALUE
@ -168,7 +169,9 @@ class FibaroLight(FibaroDevice, Light):
if self._supported_flags & SUPPORT_BRIGHTNESS:
self._brightness = float(self.fibaro_device.properties.value)
# Color handling
if self._supported_flags & SUPPORT_COLOR:
if self._supported_flags & SUPPORT_COLOR and \
'color' in self.fibaro_device.properties and \
',' in self.fibaro_device.properties.color:
# Fibaro communicates the color as an 'R, G, B, W' string
rgbw_s = self.fibaro_device.properties.color
if rgbw_s == '0,0,0,0' and\