diff --git a/homeassistant/components/isy994.py b/homeassistant/components/isy994.py index fe5d5516cb64c93dffc6a5e53986df36a59a91db..489df94c22ee1b589a6fff73a7cd08fd30bb3611 100644 --- a/homeassistant/components/isy994.py +++ b/homeassistant/components/isy994.py @@ -22,7 +22,7 @@ from homeassistant.const import ( DOMAIN = "isy994" DEPENDENCIES = [] DISCOVER_LIGHTS = "isy994.lights" -# DISCOVER_SWITCHES = "isy994.switches" +DISCOVER_SWITCHES = "isy994.switches" DISCOVER_SENSORS = "isy994.sensors" ISY = None @@ -63,7 +63,8 @@ def setup(hass, config): # Load components for the devices in the ISY controller that we support for comp_name, discovery in ((('sensor', DISCOVER_SENSORS), - ('light', DISCOVER_LIGHTS))): + ('light', DISCOVER_LIGHTS), + ('switch', DISCOVER_SWITCHES))): component = get_component(comp_name) bootstrap.setup_component(hass, component.DOMAIN, config) hass.bus.fire(EVENT_PLATFORM_DISCOVERED, @@ -137,7 +138,7 @@ class ISYDeviceABC(ToggleEntity): pass def onUpdate(self, e): - """ Handles the update recieved event. """ + """ Handles the update received event. """ self.update_ha_state() @property @@ -157,12 +158,18 @@ class ISYDeviceABC(ToggleEntity): def turn_on(self, **kwargs): """ turns the device on """ - attrs = [kwargs.get(name) for name in self._onattrs] - self.node.on(*attrs) + if self.domain is not 'sensor': + attrs = [kwargs.get(name) for name in self._onattrs] + self.node.on(*attrs) + else: + logger.error('ISY cannot turn on sensors.') def turn_off(self, **kwargs): """ turns the device off """ - self.node.off() + if self.domain is not 'sensor': + self.node.off() + else: + logger.error('ISY cannot turn off sensors.') @property def unit_of_measurement(self): diff --git a/homeassistant/components/switch/__init__.py b/homeassistant/components/switch/__init__.py index f246692560dd28f779af8db141126d2b248c412a..359839a39467dc60b7fe023f10b7122a0ef4ddf1 100644 --- a/homeassistant/components/switch/__init__.py +++ b/homeassistant/components/switch/__init__.py @@ -10,7 +10,7 @@ from homeassistant.helpers.entity_component import EntityComponent from homeassistant.const import ( STATE_ON, SERVICE_TURN_ON, SERVICE_TURN_OFF, ATTR_ENTITY_ID) -from homeassistant.components import group, discovery, wink +from homeassistant.components import group, discovery, wink, isy994 DOMAIN = 'switch' DEPENDENCIES = [] @@ -30,6 +30,7 @@ MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10) DISCOVERY_PLATFORMS = { discovery.services.BELKIN_WEMO: 'wemo', wink.DISCOVER_SWITCHES: 'wink', + isy994.DISCOVER_SWITCHES: 'isy994', } _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/switch/isy994.py b/homeassistant/components/switch/isy994.py new file mode 100644 index 0000000000000000000000000000000000000000..ae4f7b552e45f3b0702912eda2be84c1f5fc4619 --- /dev/null +++ b/homeassistant/components/switch/isy994.py @@ -0,0 +1,33 @@ +""" Support for ISY994 lights. """ +# system imports +import logging + +# homeassistant imports +from homeassistant.components.isy994 import ISY, ISYDeviceABC +from homeassistant.const import STATE_ON, STATE_OFF + + +def setup_platform(hass, config, add_devices, discovery_info=None): + """ Sets up the isy994 platform. """ + logger = logging.getLogger(__name__) + devs = [] + # verify connection + if ISY is None or not ISY.connected: + logger.error('A connection has not been made to the ISY controller.') + return False + + # import not dimmable nodes and groups + for node in ISY.nodes: + if not node.dimmable: + devs.append(ISYSwitchDevice(node)) + # import ISY programs + + add_devices(devs) + + +class ISYSwitchDevice(ISYDeviceABC): + """ represents as isy light within home assistant. """ + + _domain = 'switch' + _dtype = 'binary' + _states = [STATE_ON, STATE_OFF]