Add Velux Windows to Tahoma (#11538)

* Add Velux Windows to Tahoma

* fix linit

* add supported Tahoma devices by @glpatcern

* hound

* lint

* fix logging

* lint

* lint

* remove blank line after docstring

* changes based on notes by @armills

* fix logging
This commit is contained in:
Thijs de Jong 2018-01-10 15:41:16 +01:00 committed by Adam Mills
parent 0d06e8c1c9
commit 02979db3d6
2 changed files with 19 additions and 6 deletions

View File

@ -74,3 +74,10 @@ class TahomaCover(TahomaDevice, CoverDevice):
def stop_cover(self, **kwargs): def stop_cover(self, **kwargs):
"""Stop the cover.""" """Stop the cover."""
self.apply_action('stopIdentify') self.apply_action('stopIdentify')
def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
if self.tahoma_device.type == 'io:WindowOpenerVeluxIOComponent':
return 'window'
else:
return None

View File

@ -36,6 +36,14 @@ TAHOMA_COMPONENTS = [
'sensor', 'cover' 'sensor', 'cover'
] ]
TAHOMA_TYPES = {
'rts:RollerShutterRTSComponent': 'cover',
'rts:CurtainRTSComponent': 'cover',
'io:RollerShutterWithLowSpeedManagementIOComponent': 'cover',
'io:WindowOpenerVeluxIOComponent': 'cover',
'io:LightIOSystemSensor': 'sensor',
}
def setup(hass, config): def setup(hass, config):
"""Activate Tahoma component.""" """Activate Tahoma component."""
@ -68,6 +76,8 @@ def setup(hass, config):
if all(ext not in _device.type for ext in exclude): if all(ext not in _device.type for ext in exclude):
device_type = map_tahoma_device(_device) device_type = map_tahoma_device(_device)
if device_type is None: if device_type is None:
_LOGGER.warning('Unsupported type %s for Tahoma device %s',
_device.type, _device.label)
continue continue
hass.data[DOMAIN]['devices'][device_type].append(_device) hass.data[DOMAIN]['devices'][device_type].append(_device)
@ -78,12 +88,8 @@ def setup(hass, config):
def map_tahoma_device(tahoma_device): def map_tahoma_device(tahoma_device):
"""Map tahoma classes to Home Assistant types.""" """Map Tahoma device types to Home Assistant components."""
if tahoma_device.type.lower().find("shutter") != -1: return TAHOMA_TYPES.get(tahoma_device.type)
return 'cover'
elif tahoma_device.type == 'io:LightIOSystemSensor':
return 'sensor'
return None
class TahomaDevice(Entity): class TahomaDevice(Entity):