def setup_platform(hass, config: ConfigType, add_devices: Callable[[list], None], discovery_info=None): """Setup the ISY994 fan platform.""" if isy.ISY is None or not isy.ISY.connected: _LOGGER.error('A connection has not been made to the ISY controller.') return False devices = [] for node in isy.filter_nodes(isy.NODES, states=STATES): devices.append(ISYFanDevice(node)) for program in isy.PROGRAMS.get(DOMAIN, []): try: status = program[isy.KEY_STATUS] actions = program[isy.KEY_ACTIONS] assert actions.dtype == 'program', 'Not a program' except (KeyError, AssertionError): pass else: devices.append(ISYFanProgram(program.name, status, actions)) add_devices(devices)
def setup_platform(hass, config: ConfigType, add_devices: Callable[[list], None], discovery_info=None): """Set up the ISY994 switch platform.""" if isy.ISY is None or not isy.ISY.connected: _LOGGER.error('A connection has not been made to the ISY controller.') return False devices = [] for node in isy.filter_nodes(isy.NODES, units=UOM, states=STATES): if not node.dimmable: devices.append(ISYSwitchDevice(node)) for node in isy.GROUPS: devices.append(ISYSwitchDevice(node)) for program in isy.PROGRAMS.get(DOMAIN, []): try: status = program[isy.KEY_STATUS] actions = program[isy.KEY_ACTIONS] assert actions.dtype == 'program', 'Not a program' except (KeyError, AssertionError): pass else: devices.append(ISYSwitchProgram(program.name, status, actions)) add_devices(devices)
def setup_platform(hass, config: ConfigType, add_devices: Callable[[list], None], discovery_info=None): """Set up the ISY994 binary sensor platform.""" if isy.ISY is None or not isy.ISY.connected: _LOGGER.error("A connection has not been made to the ISY controller") return False devices = [] devices_by_nid = {} child_nodes = [] for node in isy.filter_nodes(isy.SENSOR_NODES, units=UOM, states=STATES): if node.parent_node is None: device = ISYBinarySensorDevice(node) devices.append(device) devices_by_nid[node.nid] = device else: # We'll process the child nodes last, to ensure all parent nodes # have been processed child_nodes.append(node) for node in child_nodes: try: parent_device = devices_by_nid[node.parent_node.nid] except KeyError: _LOGGER.error( "Node %s has a parent node %s, but no device " "was created for the parent. Skipping.", node.nid, node.parent_nid) else: device_type = _detect_device_type(node) if device_type in ['moisture', 'opening']: subnode_id = int(node.nid[-1]) # Leak and door/window sensors work the same way with negative # nodes and heartbeat nodes if subnode_id == 4: # Subnode 4 is the heartbeat node, which we will represent # as a separate binary_sensor device = ISYBinarySensorHeartbeat(node, parent_device) parent_device.add_heartbeat_device(device) devices.append(device) elif subnode_id == 2: parent_device.add_negative_node(node) else: # We don't yet have any special logic for other sensor types, # so add the nodes as individual devices device = ISYBinarySensorDevice(node) devices.append(device) for program in isy.PROGRAMS.get(DOMAIN, []): try: status = program[isy.KEY_STATUS] except (KeyError, AssertionError): pass else: devices.append(ISYBinarySensorProgram(program.name, status)) add_devices(devices)
def setup_platform(hass, config: ConfigType, add_devices: Callable[[list], None], discovery_info=None): """Set up the ISY994 light platform.""" if isy.ISY is None or not isy.ISY.connected: _LOGGER.error("A connection has not been made to the ISY controller") return False devices = [] for node in isy.filter_nodes(isy.NODES, units=UOM, states=STATES): if node.dimmable or '51' in node.uom: devices.append(ISYLightDevice(node)) add_devices(devices)
def setup_platform(hass, config: ConfigType, add_devices: Callable[[list], None], discovery_info=None): """Set up the ISY994 light platform.""" if isy.ISY is None or not isy.ISY.connected: _LOGGER.error('A connection has not been made to the ISY controller.') return False devices = [] for node in isy.filter_nodes(isy.NODES, units=UOM, states=STATES): if node.dimmable or '51' in node.uom: devices.append(ISYLightDevice(node)) add_devices(devices)
def setup_platform(hass, config: ConfigType, add_devices: Callable[[list], None], discovery_info=None): """Setup the ISY994 binary sensor platform.""" if isy.ISY is None or not isy.ISY.connected: _LOGGER.error('A connection has not been made to the ISY controller.') return False devices = [] for node in isy.filter_nodes(isy.SENSOR_NODES, units=UOM, states=STATES): devices.append(ISYBinarySensorDevice(node)) for program in isy.PROGRAMS.get(DOMAIN, []): try: status = program[isy.KEY_STATUS] except (KeyError, AssertionError): pass else: devices.append(ISYBinarySensorProgram(program.name, status)) add_devices(devices)
def setup_platform(hass, config: ConfigType, add_devices: Callable[[list], None], discovery_info=None): """Set up the ISY994 binary sensor platform.""" if isy.ISY is None or not isy.ISY.connected: _LOGGER.error("A connection has not been made to the ISY controller") return False devices = [] devices_by_nid = {} child_nodes = [] for node in isy.filter_nodes(isy.SENSOR_NODES, units=UOM, states=STATES): if node.parent_node is None: device = ISYBinarySensorDevice(node) devices.append(device) devices_by_nid[node.nid] = device else: # We'll process the child nodes last, to ensure all parent nodes # have been processed child_nodes.append(node) for node in child_nodes: try: parent_device = devices_by_nid[node.parent_node.nid] except KeyError: _LOGGER.error("Node %s has a parent node %s, but no device " "was created for the parent. Skipping.", node.nid, node.parent_nid) else: device_type = _detect_device_type(node) subnode_id = int(node.nid[-1]) if device_type == 'opening': # Door/window sensors use an optional "negative" node if subnode_id == 4: # Subnode 4 is the heartbeat node, which we will represent # as a separate binary_sensor device = ISYBinarySensorHeartbeat(node, parent_device) parent_device.add_heartbeat_device(device) devices.append(device) elif subnode_id == 2: parent_device.add_negative_node(node) elif device_type == 'moisture': # Moisure nodes have a subnode 2, but we ignore it because it's # just the inverse of the primary node. if subnode_id == 4: # Heartbeat node device = ISYBinarySensorHeartbeat(node, parent_device) parent_device.add_heartbeat_device(device) devices.append(device) else: # We don't yet have any special logic for other sensor types, # so add the nodes as individual devices device = ISYBinarySensorDevice(node) devices.append(device) for program in isy.PROGRAMS.get(DOMAIN, []): try: status = program[isy.KEY_STATUS] except (KeyError, AssertionError): pass else: devices.append(ISYBinarySensorProgram(program.name, status)) add_devices(devices)