def devices_from_config(domain_config, hass=None): """Parse configuration and add Rflink switch devices.""" devices = [] for device_id, config in domain_config[CONF_DEVICES].items(): device_config = dict(domain_config[CONF_DEVICE_DEFAULTS], **config) remove_deprecated(device_config) device = RflinkSwitch(device_id, hass, **device_config) devices.append(device) # Register entity (and aliases) to listen to incoming rflink events # Device id and normal aliases respond to normal and group command hass.data[DATA_ENTITY_LOOKUP][ EVENT_KEY_COMMAND][device_id].append(device) if config[CONF_GROUP]: hass.data[DATA_ENTITY_GROUP_LOOKUP][ EVENT_KEY_COMMAND][device_id].append(device) for _id in get_deprecated(config, CONF_ALIASES, CONF_ALIASSES): hass.data[DATA_ENTITY_LOOKUP][ EVENT_KEY_COMMAND][_id].append(device) hass.data[DATA_ENTITY_GROUP_LOOKUP][ EVENT_KEY_COMMAND][_id].append(device) # group_aliases only respond to group commands for _id in get_deprecated( config, CONF_GROUP_ALIASES, CONF_GROUP_ALIASSES): hass.data[DATA_ENTITY_GROUP_LOOKUP][ EVENT_KEY_COMMAND][_id].append(device) # nogroup_aliases only respond to normal commands for _id in get_deprecated( config, CONF_NOGROUP_ALIASES, CONF_NOGROUP_ALIASSES): hass.data[DATA_ENTITY_LOOKUP][ EVENT_KEY_COMMAND][_id].append(device) return devices
def devices_from_config(domain_config): """Parse configuration and add Rflink light devices.""" devices = [] for device_id, config in domain_config[CONF_DEVICES].items(): # Determine which kind of entity to create if CONF_TYPE in config: # Remove type from config to not pass it as and argument to entity # instantiation entity_type = config.pop(CONF_TYPE) else: entity_type = entity_type_for_device_id(device_id) entity_class = entity_class_for_type(entity_type) device_config = dict(domain_config[CONF_DEVICE_DEFAULTS], **config) remove_deprecated(device_config) is_hybrid = entity_class is HybridRflinkLight # Make user aware this can cause problems repetitions_enabled = device_config[CONF_SIGNAL_REPETITIONS] != 1 if is_hybrid and repetitions_enabled: _LOGGER.warning( "Hybrid type for %s not compatible with signal " "repetitions. Please set 'dimmable' or 'switchable' " "type explicitly in configuration", device_id) device = entity_class(device_id, **device_config) devices.append(device) return devices
def devices_from_config(domain_config): """Parse configuration and add Rflink switch devices.""" devices = [] for device_id, config in domain_config[CONF_DEVICES].items(): device_config = dict(domain_config[CONF_DEVICE_DEFAULTS], **config) remove_deprecated(device_config) device = RflinkSwitch(device_id, **device_config) devices.append(device) return devices
def devices_from_config(domain_config, hass=None): """Parse configuration and add Rflink light devices.""" devices = [] for device_id, config in domain_config[CONF_DEVICES].items(): # Determine which kind of entity to create if CONF_TYPE in config: # Remove type from config to not pass it as and argument to entity # instantiation entity_type = config.pop(CONF_TYPE) else: entity_type = entity_type_for_device_id(device_id) entity_class = entity_class_for_type(entity_type) device_config = dict(domain_config[CONF_DEVICE_DEFAULTS], **config) remove_deprecated(device_config) is_hybrid = entity_class is HybridRflinkLight # Make user aware this can cause problems repetitions_enabled = device_config[CONF_SIGNAL_REPETITIONS] != 1 if is_hybrid and repetitions_enabled: _LOGGER.warning( "Hybrid type for %s not compatible with signal " "repetitions. Please set 'dimmable' or 'switchable' " "type explicitly in configuration", device_id) device = entity_class(device_id, hass, **device_config) devices.append(device) # Register entity (and aliases) to listen to incoming rflink events # Device id and normal aliases respond to normal and group command hass.data[DATA_ENTITY_LOOKUP][EVENT_KEY_COMMAND][device_id].append( device) if config[CONF_GROUP]: hass.data[DATA_ENTITY_GROUP_LOOKUP][EVENT_KEY_COMMAND][ device_id].append(device) for _id in get_deprecated(config, CONF_ALIASES, CONF_ALIASSES): hass.data[DATA_ENTITY_LOOKUP][EVENT_KEY_COMMAND][_id].append( device) hass.data[DATA_ENTITY_GROUP_LOOKUP][EVENT_KEY_COMMAND][_id].append( device) # group_aliases only respond to group commands for _id in get_deprecated(config, CONF_GROUP_ALIASES, CONF_GROUP_ALIASSES): hass.data[DATA_ENTITY_GROUP_LOOKUP][EVENT_KEY_COMMAND][_id].append( device) # nogroup_aliases only respond to normal commands for _id in get_deprecated(config, CONF_NOGROUP_ALIASES, CONF_NOGROUP_ALIASSES): hass.data[DATA_ENTITY_LOOKUP][EVENT_KEY_COMMAND][_id].append( device) return devices
def devices_from_config(domain_config, hass=None): """Parse configuration and add Rflink light devices.""" devices = [] for device_id, config in domain_config[CONF_DEVICES].items(): # Determine which kind of entity to create if CONF_TYPE in config: # Remove type from config to not pass it as and argument to entity # instantiation entity_type = config.pop(CONF_TYPE) else: entity_type = entity_type_for_device_id(device_id) entity_class = entity_class_for_type(entity_type) device_config = dict(domain_config[CONF_DEVICE_DEFAULTS], **config) remove_deprecated(device_config) is_hybrid = entity_class is HybridRflinkLight # Make user aware this can cause problems repetitions_enabled = device_config[CONF_SIGNAL_REPETITIONS] != 1 if is_hybrid and repetitions_enabled: _LOGGER.warning( "Hybrid type for %s not compatible with signal " "repetitions. Please set 'dimmable' or 'switchable' " "type explicitly in configuration", device_id) device = entity_class(device_id, hass, **device_config) devices.append(device) # Register entity (and aliases) to listen to incoming rflink events # Device id and normal aliases respond to normal and group command hass.data[DATA_ENTITY_LOOKUP][ EVENT_KEY_COMMAND][device_id].append(device) if config[CONF_GROUP]: hass.data[DATA_ENTITY_GROUP_LOOKUP][ EVENT_KEY_COMMAND][device_id].append(device) for _id in get_deprecated(config, CONF_ALIASES, CONF_ALIASSES): hass.data[DATA_ENTITY_LOOKUP][ EVENT_KEY_COMMAND][_id].append(device) hass.data[DATA_ENTITY_GROUP_LOOKUP][ EVENT_KEY_COMMAND][_id].append(device) # group_aliases only respond to group commands for _id in get_deprecated( config, CONF_GROUP_ALIASES, CONF_GROUP_ALIASSES): hass.data[DATA_ENTITY_GROUP_LOOKUP][ EVENT_KEY_COMMAND][_id].append(device) # nogroup_aliases only respond to normal commands for _id in get_deprecated( config, CONF_NOGROUP_ALIASES, CONF_NOGROUP_ALIASSES): hass.data[DATA_ENTITY_LOOKUP][ EVENT_KEY_COMMAND][_id].append(device) return devices
def devices_from_config(domain_config): """Parse configuration and add Rflink sensor devices.""" devices = [] for device_id, config in domain_config[CONF_DEVICES].items(): if ATTR_UNIT_OF_MEASUREMENT not in config: config[ATTR_UNIT_OF_MEASUREMENT] = lookup_unit_for_sensor_type( config[CONF_SENSOR_TYPE]) remove_deprecated(config) device = RflinkSensor(device_id, **config) devices.append(device) return devices
def devices_from_config(domain_config, hass=None): """Parse configuration and add Rflink sensor devices.""" devices = [] for device_id, config in domain_config[CONF_DEVICES].items(): if ATTR_UNIT_OF_MEASUREMENT not in config: config[ATTR_UNIT_OF_MEASUREMENT] = lookup_unit_for_sensor_type( config[CONF_SENSOR_TYPE]) remove_deprecated(config) device = RflinkSensor(device_id, hass, **config) devices.append(device) # Register entity to listen to incoming rflink events hass.data[DATA_ENTITY_LOOKUP][ EVENT_KEY_SENSOR][device_id].append(device) return devices
def devices_from_config(domain_config, hass=None): """Parse configuration and add Rflink sensor devices.""" devices = [] for device_id, config in domain_config[CONF_DEVICES].items(): if not config[ATTR_UNIT_OF_MEASUREMENT]: config[ATTR_UNIT_OF_MEASUREMENT] = lookup_unit_for_sensor_type( config[CONF_SENSOR_TYPE]) remove_deprecated(config) device = RflinkSensor(device_id, hass, **config) devices.append(device) # Register entity to listen to incoming rflink events hass.data[DATA_ENTITY_LOOKUP][EVENT_KEY_SENSOR][device_id].append( device) return devices