diff --git a/homeassistant/components/switch/tahoma.py b/homeassistant/components/switch/tahoma.py new file mode 100644 index 00000000000..339a0c39386 --- /dev/null +++ b/homeassistant/components/switch/tahoma.py @@ -0,0 +1,51 @@ +""" +Support for Tahoma Switch - those are push buttons for garage door etc. + +Those buttons are implemented as switchs that are never on. They only +receive the turn_on action, perform the relay click, and stay in OFF state + +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/switch.tahoma/ +""" +import logging + +from homeassistant.components.switch import SwitchDevice +from homeassistant.components.tahoma import ( + DOMAIN as TAHOMA_DOMAIN, TahomaDevice) + +DEPENDENCIES = ['tahoma'] + +_LOGGER = logging.getLogger(__name__) + + +def setup_platform(hass, config, add_devices, discovery_info=None): + """Set up Tahoma switchs.""" + controller = hass.data[TAHOMA_DOMAIN]['controller'] + devices = [] + for switch in hass.data[TAHOMA_DOMAIN]['devices']['switch']: + devices.append(TahomaSwitch(switch, controller)) + add_devices(devices, True) + + +class TahomaSwitch(TahomaDevice, SwitchDevice): + """Representation a Tahoma Switch.""" + + @property + def device_class(self): + """Return the class of the device.""" + if self.tahoma_device.type == 'rts:GarageDoor4TRTSComponent': + return 'garage' + return None + + def turn_on(self, **kwargs): + """Send the on command.""" + self.toggle() + + def toggle(self, **kwargs): + """Click the switch.""" + self.apply_action('cycle') + + @property + def is_on(self): + """Get whether the switch is in on state.""" + return False diff --git a/homeassistant/components/tahoma.py b/homeassistant/components/tahoma.py index 7c8d047fbcf..055e3f410ea 100644 --- a/homeassistant/components/tahoma.py +++ b/homeassistant/components/tahoma.py @@ -32,7 +32,7 @@ CONFIG_SCHEMA = vol.Schema({ }, extra=vol.ALLOW_EXTRA) TAHOMA_COMPONENTS = [ - 'scene', 'sensor', 'cover' + 'scene', 'sensor', 'cover', 'switch' ] TAHOMA_TYPES = { @@ -43,6 +43,7 @@ TAHOMA_TYPES = { 'io:RollerShutterGenericIOComponent': 'cover', 'io:WindowOpenerVeluxIOComponent': 'cover', 'io:LightIOSystemSensor': 'sensor', + 'rts:GarageDoor4TRTSComponent': 'switch', }