Python homeassistant.const.CONF_NAME Examples

The following are 30 code examples of homeassistant.const.CONF_NAME(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module homeassistant.const , or try the search function .
Example #1
Source File: sensor.py    From lutron-caseta-pro with Apache License 2.0 6 votes vote down vote up
def __init__(self, pico, data, mac):
        """Initialize a Lutron Pico."""
        self._data = data
        self._name = pico[CONF_NAME]
        self._area_name = None
        if CONF_AREA_NAME in pico:
            self._area_name = pico[CONF_AREA_NAME]
            # if available, prepend area name to sensor
            self._name = pico[CONF_AREA_NAME] + " " + pico[CONF_NAME]
        self._integration = int(pico[CONF_ID])
        self._buttons = pico[CONF_BUTTONS]
        self._minbutton = 100
        for button_num in self._buttons:
            if button_num < self._minbutton:
                self._minbutton = button_num
        self._state = 0
        self._mac = mac 
Example #2
Source File: switch.py    From hass-opensprinkler with MIT License 6 votes vote down vote up
def _create_entities(hass: HomeAssistant, entry: dict):
    entities = []

    controller = hass.data[DOMAIN][entry.entry_id]["controller"]
    coordinator = hass.data[DOMAIN][entry.entry_id]["coordinator"]
    name = entry.data[CONF_NAME]

    entities.append(ControllerOperationSwitch(entry, name, controller, coordinator))

    for _, program in controller.programs.items():
        entities.append(ProgramEnabledSwitch(entry, name, program, coordinator))

    for _, station in controller.stations.items():
        entities.append(StationEnabledSwitch(entry, name, station, coordinator))

    return entities 
Example #3
Source File: binary_sensor.py    From homeassistant-config with The Unlicense 6 votes vote down vote up
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Set up a binary sensor for an Amcrest IP Camera."""
    if discovery_info is None:
        return

    device_name = discovery_info[CONF_NAME]
    binary_sensors = discovery_info[CONF_BINARY_SENSORS]
    amcrest = hass.data[DATA_AMCREST][device_name]

    amcrest_binary_sensors = []
    for sensor_type in binary_sensors:
        amcrest_binary_sensors.append(
            AmcrestBinarySensor(amcrest.name, amcrest.device, sensor_type))

    async_add_devices(amcrest_binary_sensors, True)
    return True 
Example #4
Source File: binary_sensor.py    From hass-opensprinkler with MIT License 6 votes vote down vote up
def _create_entities(hass: HomeAssistant, entry: dict):
    entities = []

    controller = hass.data[DOMAIN][entry.entry_id]["controller"]
    coordinator = hass.data[DOMAIN][entry.entry_id]["coordinator"]
    name = entry.data[CONF_NAME]

    entities.append(
        ControllerSensorActive(entry, name, "sensor_1", controller, coordinator)
    )
    entities.append(
        ControllerSensorActive(entry, name, "sensor_2", controller, coordinator)
    )
    entities.append(
        ControllerSensorActive(entry, name, "rain_delay", controller, coordinator)
    )

    for _, program in controller.programs.items():
        entities.append(ProgramIsRunningBinarySensor(entry, name, program, coordinator))

    for _, station in controller.stations.items():
        entities.append(StationIsRunningBinarySensor(entry, name, station, coordinator))

    return entities 
Example #5
Source File: sensor.py    From hass-opensprinkler with MIT License 6 votes vote down vote up
def _create_entities(hass: HomeAssistant, entry: dict):
    entities = []

    controller = hass.data[DOMAIN][entry.entry_id]["controller"]
    coordinator = hass.data[DOMAIN][entry.entry_id]["coordinator"]
    name = entry.data[CONF_NAME]

    entities.append(LastRunSensor(entry, name, controller, coordinator))
    entities.append(RainDelayStopTimeSensor(entry, name, controller, coordinator))
    entities.append(WaterLevelSensor(entry, name, controller, coordinator))
    entities.append(FlowRateSensor(entry, name, controller, coordinator))

    for _, station in controller.stations.items():
        entities.append(StationStatusSensor(entry, name, station, coordinator))

    return entities 
Example #6
Source File: block.py    From ShellyForHASS with MIT License 6 votes vote down vote up
def __init__(self, block, instance, prefix=""):
        conf = instance.conf
        id_prefix = conf.get(CONF_OBJECT_ID_PREFIX)
        self._unique_id = slugify(id_prefix + "_" + block.type + "_" +
                                  block.id + prefix)
        self.entity_id = "." + self._unique_id
        entity_id = \
            instance._get_specific_config(CONF_ENTITY_ID, None, block.id)
        if entity_id is not None:
            self.entity_id = "." + slugify(id_prefix + "_" + entity_id + prefix)
            self._unique_id += "_" + slugify(entity_id)
        self._show_id_in_name = conf.get(CONF_SHOW_ID_IN_NAME)
        self._block = block
        self.hass = instance.hass
        self.instance = instance
        self._block.cb_updated.append(self._updated)
        block.shelly_device = self  #todo, should be array??
        self._name = instance._get_specific_config(CONF_NAME, None, block.id)
        self._name_ext = None
        self._is_removed = False
        self.async_on_remove(self._remove_handler)
        self._master_unit = False
        self._settings = instance.get_settings(block.id) 
Example #7
Source File: config_flow.py    From Anniversaries with MIT License 6 votes vote down vote up
def _show_init_form(self, user_input):
        data_schema = OrderedDict()
        one_time = self.config_entry.options.get(CONF_ONE_TIME)
        unit_of_measurement = self.config_entry.options.get(CONF_UNIT_OF_MEASUREMENT)
        half_anniversary = self.config_entry.options.get(CONF_HALF_ANNIVERSARY)
        if one_time is None:
            one_time = DEFAULT_ONE_TIME
        if half_anniversary is None:
            half_anniversary = DEFAULT_HALF_ANNIVERSARY
        if unit_of_measurement is None:
            unit_of_measurement = DEFAULT_UNIT_OF_MEASUREMENT
        data_schema[vol.Required(CONF_NAME,default=self.config_entry.options.get(CONF_NAME),)] = str
        data_schema[vol.Required(CONF_DATE, default=self.config_entry.options.get(CONF_DATE),)] = str
        data_schema[vol.Required(CONF_ONE_TIME, default=one_time,)] = bool
        data_schema[vol.Required(CONF_HALF_ANNIVERSARY,default=half_anniversary,)] = bool
        data_schema[vol.Required(CONF_DATE_FORMAT,default=self.config_entry.options.get(CONF_DATE_FORMAT),)] = str
        data_schema[vol.Required(CONF_UNIT_OF_MEASUREMENT,default=unit_of_measurement,)] = str
        return self.async_show_form(
            step_id="init", data_schema=vol.Schema(data_schema), errors=self._errors
        ) 
Example #8
Source File: cover.py    From xknx with MIT License 6 votes vote down vote up
def async_add_entities_config(hass, config, async_add_entities):
    """Set up cover for KNX platform configured within platform."""
    cover = XknxCover(
        hass.data[DATA_XKNX].xknx,
        name=config[CONF_NAME],
        group_address_long=config.get(CONF_MOVE_LONG_ADDRESS),
        group_address_short=config.get(CONF_MOVE_SHORT_ADDRESS),
        group_address_position_state=config.get(CONF_POSITION_STATE_ADDRESS),
        group_address_angle=config.get(CONF_ANGLE_ADDRESS),
        group_address_angle_state=config.get(CONF_ANGLE_STATE_ADDRESS),
        group_address_position=config.get(CONF_POSITION_ADDRESS),
        travel_time_down=config[CONF_TRAVELLING_TIME_DOWN],
        travel_time_up=config[CONF_TRAVELLING_TIME_UP],
        invert_position=config[CONF_INVERT_POSITION],
        invert_angle=config[CONF_INVERT_ANGLE],
    )

    hass.data[DATA_XKNX].xknx.devices.add(cover)
    async_add_entities([KNXCover(cover)]) 
Example #9
Source File: switch.py    From lutron-caseta-pro with Apache License 2.0 5 votes vote down vote up
def __init__(self, switch, data, mac):
        """Initialize a Lutron switch."""
        self._data = data
        self._name = switch[CONF_NAME]
        self._area_name = None
        if CONF_AREA_NAME in switch:
            self._area_name = switch[CONF_AREA_NAME]
            # if available, prepend area name to switch
            self._name = switch[CONF_AREA_NAME] + " " + switch[CONF_NAME]
        self._integration = int(switch[CONF_ID])
        self._is_on = False
        self._mac = mac 
Example #10
Source File: config_flow.py    From Anniversaries with MIT License 5 votes vote down vote up
def _show_user_form(self, user_input):
        name = ""
        date = ""
        one_time = DEFAULT_ONE_TIME
        half_anniversary = DEFAULT_HALF_ANNIVERSARY
        date_format = DEFAULT_DATE_FORMAT
        unit_of_measurement = DEFAULT_UNIT_OF_MEASUREMENT
        id_prefix = DEFAULT_ID_PREFIX
        if user_input is not None:
            if CONF_NAME in user_input:
                name = user_input[CONF_NAME]
            if CONF_DATE in user_input:
                date = user_input[CONF_DATE]
            if CONF_ONE_TIME in user_input:
                one_time = user_input[CONF_ONE_TIME]
            if CONF_HALF_ANNIVERSARY in user_input:
                half_anniversary = user_input[CONF_HALF_ANNIVERSARY]
            if CONF_DATE_FORMAT in user_input:
                date_format = user_input[CONF_DATE_FORMAT]
            if CONF_UNIT_OF_MEASUREMENT in user_input:
                unit_of_measurement = user_input[CONF_UNIT_OF_MEASUREMENT]
            if CONF_ID_PREFIX in user_input:
                id_prefix = user_input[CONF_ID_PREFIX]
        data_schema = OrderedDict()
        data_schema[vol.Required(CONF_NAME, default=name)] = str
        data_schema[vol.Required(CONF_DATE, default=date)] = str
        data_schema[vol.Required(CONF_ONE_TIME, default=one_time)] = bool
        data_schema[vol.Required(CONF_HALF_ANNIVERSARY, default=half_anniversary)] = bool
        data_schema[vol.Required(CONF_DATE_FORMAT, default=date_format)] = str
        data_schema[vol.Required(CONF_UNIT_OF_MEASUREMENT, default=unit_of_measurement)] = str
        data_schema[vol.Optional(CONF_ID_PREFIX, default=id_prefix)] = str
        return self.async_show_form(step_id="user", data_schema=vol.Schema(data_schema), errors=self._errors) 
Example #11
Source File: device.py    From ShellyForHASS with MIT License 5 votes vote down vote up
def __init__(self, dev, instance):
        conf = instance.conf
        id_prefix = conf.get(CONF_OBJECT_ID_PREFIX)
        self._unique_id = id_prefix + "_" + dev.type + "_" + dev.id
        self.entity_id = "." + slugify(self._unique_id)
        entity_id = instance._get_specific_config(CONF_ENTITY_ID,
                                         None, dev.id, dev.block.id)
        if entity_id is not None:
            self.entity_id = "." + slugify(id_prefix + "_" + entity_id)
            self._unique_id += "_" + slugify(entity_id)
        self._show_id_in_name = conf.get(CONF_SHOW_ID_IN_NAME)
        self._name_ext = None
        #self._name = dev.type_name()
        #if conf.get(CONF_SHOW_ID_IN_NAME):
        #    self._name += " [" + dev.id + "]"  # 'Test' #light.name
        self._dev = dev
        self.hass = instance.hass
        self.instance = instance
        self._dev.cb_updated.append(self._updated)
        dev.shelly_device = self
        self._name = instance._get_specific_config(CONF_NAME, None,
                                          dev.id, dev.block.id)

        self._sensor_conf = instance._get_sensor_config(dev.id, dev.block.id)

        self._is_removed = False
        self._master_unit = False

        self._settings = instance.get_settings(dev.id, dev.block.id) 
Example #12
Source File: cover.py    From lutron-caseta-pro with Apache License 2.0 5 votes vote down vote up
def __init__(self, cover, data, mac):
        """Initialize a Lutron shade."""
        self._data = data
        self._name = cover[CONF_NAME]
        self._area_name = None
        if CONF_AREA_NAME in cover:
            self._area_name = cover[CONF_AREA_NAME]
            # if available, prepend area name to cover
            self._name = cover[CONF_AREA_NAME] + " " + cover[CONF_NAME]
        self._integration = int(cover[CONF_ID])
        self._position = 0
        self._mac = mac 
Example #13
Source File: config_flow.py    From wiserHomeAssistantPlatform with MIT License 5 votes vote down vote up
def async_step_user(self, user_input=None):
        """
        Handle a Wiser Heat Hub config flow start.

        Manage device specific parameters.
        """
        errors = {}
        if user_input is not None:
            try:
                validated = await validate_input(self.hass, user_input)
            except InvalidAuth:
                errors["base"] = "auth_failure"
            except CannotConnect:
                errors["base"] = "timeout_error"
            except UnknownError:
                _LOGGER.exception("Unexpected exception")
                errors["base"] = "unknown"

            if "base" not in errors:
                await self.async_set_unique_id(validated["unique_id"])
                self._abort_if_unique_id_configured()

                # Add hub name to config
                user_input[CONF_NAME] = validated["title"]
                return self.async_create_entry(
                    title=validated["title"], data=user_input
                )

        return self.async_show_form(
            step_id="user",
            data_schema=self.discovery_schema or DATA_SCHEMA,
            errors=errors,
        ) 
Example #14
Source File: config_schema.py    From climate.programmable_thermostat with The Unlicense 5 votes vote down vote up
def get_config_flow_schema(config: dict = {}, config_flow_step: int = 0) -> dict:
    if not config:
        config = {
            CONF_NAME: DEFAULT_NAME,
            CONF_HEATER: "",
            CONF_COOLER: "",
            CONF_SENSOR: "",
            CONF_TARGET: "",
            CONF_MAX_TEMP: DEFAULT_MAX_TEMP,
            CONF_MIN_TEMP: DEFAULT_MIN_TEMP,
            CONF_TOLERANCE: DEFAULT_TOLERANCE,
            CONF_RELATED_CLIMATE: "",
            CONF_HVAC_OPTIONS: DEFAULT_HVAC_OPTIONS,
            CONF_AUTO_MODE: DEFAULT_AUTO_MODE,
            CONF_INITIAL_HVAC_MODE: ""
        }
    if config_flow_step==1:
        return {
            vol.Optional(CONF_NAME, default=config.get(CONF_NAME)): str,
            vol.Optional(CONF_HEATER, default=config.get(CONF_HEATER)): str,
            vol.Optional(CONF_COOLER, default=config.get(CONF_COOLER)): str,
            vol.Required(CONF_SENSOR, default=config.get(CONF_SENSOR)): str,
            vol.Required(CONF_TARGET, default=config.get(CONF_TARGET)): str
        }
    elif config_flow_step==2:
        return {
            vol.Optional(CONF_MAX_TEMP, default=config.get(CONF_MAX_TEMP)): int,
            vol.Optional(CONF_MIN_TEMP, default=config.get(CONF_MIN_TEMP)): int,
            vol.Optional(CONF_TOLERANCE, default=config.get(CONF_TOLERANCE)): float
        }
    elif config_flow_step==3:
        return {
            vol.Optional(CONF_RELATED_CLIMATE, default=config.get(CONF_RELATED_CLIMATE)): str,
            vol.Optional(CONF_HVAC_OPTIONS, default=config.get(CONF_HVAC_OPTIONS)):  vol.In(range(MAX_HVAC_OPTIONS)),
            vol.Optional(CONF_AUTO_MODE, default=config.get(CONF_AUTO_MODE)): vol.In(AUTO_MODE_OPTIONS),
            vol.Optional(CONF_INITIAL_HVAC_MODE, default=config.get(CONF_INITIAL_HVAC_MODE)): vol.In(INITIAL_HVAC_MODE_OPTIONS)
        }

    return {} 
Example #15
Source File: __init__.py    From common_timer with Apache License 2.0 5 votes vote down vote up
def async_setup(hass, config):
    """Set up an input select."""
    component = hass.data[DOMAIN] = EntityComponent(_LOGGER, DOMAIN, hass)

    entities = []

    for object_id, cfg in config[DOMAIN].items():
        name = cfg.get(CONF_NAME)
        options = cfg.get(CONF_OPTIONS)
        initial = cfg.get(CONF_INITIAL)
        icon = cfg.get(CONF_ICON)
        entities.append(InputSelect(object_id, name, initial, options, icon))

    if not entities:
        return False

    component.async_register_entity_service(
        SERVICE_SELECT_OPTION, SERVICE_SELECT_OPTION_SCHEMA,
        'async_select_option'
    )

    component.async_register_entity_service(
        SERVICE_SELECT_NEXT, SERVICE_SELECT_NEXT_SCHEMA,
        lambda entity, call: entity.async_offset_index(1)
    )

    component.async_register_entity_service(
        SERVICE_SELECT_PREVIOUS, SERVICE_SELECT_PREVIOUS_SCHEMA,
        lambda entity, call: entity.async_offset_index(-1)
    )

    component.async_register_entity_service(
        SERVICE_SET_OPTIONS, SERVICE_SET_OPTIONS_SCHEMA,
        'async_set_options'
    )

    await component.async_add_entities(entities)
    return True 
Example #16
Source File: fan.py    From lutron-caseta-pro with Apache License 2.0 5 votes vote down vote up
def __init__(self, fan, data, mac):
        """Initialize a Lutron fan."""
        self._data = data
        self._name = fan[CONF_NAME]
        self._area_name = None
        if CONF_AREA_NAME in fan:
            self._area_name = fan[CONF_AREA_NAME]
            # if available, prepend area name to fan
            self._name = fan[CONF_AREA_NAME] + " " + fan[CONF_NAME]
        self._integration = int(fan[CONF_ID])
        self._is_on = False
        self._mac = mac
        self._speed = SPEED_OFF 
Example #17
Source File: scene.py    From lutron-caseta-pro with Apache License 2.0 5 votes vote down vote up
def __init__(self, scene, data, mac):
        """Initialize a Lutron scene."""
        self._data = data
        self._name = scene[CONF_NAME]
        self._integration = int(scene[CONF_ID])
        self._scene_id = int(scene[CONF_SCENE_ID])
        self._mac = mac 
Example #18
Source File: sensor.py    From SmartHouse with MIT License 5 votes vote down vote up
def setup_platform(hass, config, add_devices, discovery_info=None):
  city_card_id = config.get(CONF_CITY_CARD)
  identity_id = config.get(CONF_IDENTITY)
  name = config.get(CONF_NAME)

  add_devices([KKMSensor(hass, city_card_id, identity_id, name)]) 
Example #19
Source File: sensor.py    From SmartHouse with MIT License 5 votes vote down vote up
def setup_platform(hass, config, add_devices, discovery_info=None):
  username = config.get(CONF_USERNAME)
  password = config.get(CONF_PASSWORD)
  name = config.get(CONF_NAME)

  websession = async_get_clientsession(hass)

  add_devices([LunchingSensor(hass, websession, name, username, password)]) 
Example #20
Source File: sensor.py    From SmartHouse with MIT License 5 votes vote down vote up
def setup_platform(hass, config, add_devices, discovery_info=None):
  account_id = config.get(CONF_ACCOUNT_ID)
  token = config.get(CONF_TOKEN)
  name = config.get(CONF_NAME)

  websession = async_get_clientsession(hass)

  add_devices([HarvestSensor(hass, websession, account_id, token, name)]) 
Example #21
Source File: sensor.py    From SmartHouse with MIT License 5 votes vote down vote up
def setup_platform(hass, config, add_devices, discovery_info=None):
  stop_id = config.get(CONF_STOP_ID)
  direction = config.get(CONF_DIRECTION)
  name = config.get(CONF_NAME)

  _LOGGER.info("Initializing sensor for: {}".format(stop_id))
  add_devices([PublicTransportSensor(hass, name, stop_id, direction)]) 
Example #22
Source File: sensor.py    From SmartHouse with MIT License 5 votes vote down vote up
def setup_platform(hass, config, add_devices, discovery_info=None):
  entity_id = config.get(CONF_ENTITY_ID)
  name = config.get(CONF_NAME)

  add_devices([ItWillRain(hass, entity_id, name)]) 
Example #23
Source File: light.py    From ha-plejd with Apache License 2.0 5 votes vote down vote up
def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
    cryptokey = binascii.a2b_hex(config.get(CONF_CRYPTO_KEY).replace('-', ''))
    plejdinfo = {"key": cryptokey}

    hass.data[DATA_PLEJD] = plejdinfo

    async def _ping(now):
        pi = hass.data[DATA_PLEJD]
        if(await plejd_ping(pi) == False):
            await connect(pi)
        plejdinfo["remove_timer"] = async_track_point_in_utc_time(hass, _ping, dt_util.utcnow() + timedelta(seconds = 300))

    async def _stop_plejd(event):
        if "remove_timer" in plejdinfo:
            plejdinfo["remove_timer"]()

    hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _stop_plejd)

    plejdinfo["discovery_timeout"] = config[CONF_DISCOVERY_TIMEOUT]
    plejdinfo["dbus_address"] = config[CONF_DBUS_ADDRESS]

    await connect(plejdinfo)
    if plejdinfo["characteristics"] is not None:
        await _ping(dt_util.utcnow())
    else:
        raise PlatformNotReady

    devices = []
    for identity, entity_info in config[CONF_DEVICES].items():
        i = int(identity)
        _LOGGER.debug("Adding device %d (%s)" % (i, entity_info[CONF_NAME]))
        new = PlejdLight(entity_info[CONF_NAME], i)
        PLEJD_DEVICES[i] = new
        devices.append(new)

    async_add_entities(devices)
    _LOGGER.debug("All plejd setup completed") 
Example #24
Source File: switch.py    From sonoff-lan-mode-homeassistant with MIT License 5 votes vote down vote up
def async_setup_platform(hass, config, async_add_entities,
                               discovery_info=None):
    """Set up the Sonoff LAN Mode Switch platform."""
    host = config.get(CONF_HOST)
    name = config.get(CONF_NAME)
    icon = config.get(CONF_ICON)

    async_add_entities([HassSonoffSwitch(hass, host, name, icon)], True) 
Example #25
Source File: sensor.py    From sensor.plex_recently_added with Apache License 2.0 5 votes vote down vote up
def setup_platform(hass, config, add_devices, discovery_info=None):
    name = config.get(CONF_NAME)
    add_devices([PlexRecentlyAddedSensor(hass, config, name)], True) 
Example #26
Source File: sensor.py    From xknx with MIT License 5 votes vote down vote up
def async_add_entities_config(hass, config, async_add_entities):
    """Set up sensor for KNX platform configured within platform."""
    sensor = XknxSensor(
        hass.data[DATA_XKNX].xknx,
        name=config[CONF_NAME],
        group_address_state=config[CONF_STATE_ADDRESS],
        sync_state=config[CONF_SYNC_STATE],
        value_type=config[CONF_TYPE],
    )
    hass.data[DATA_XKNX].xknx.devices.add(sensor)
    async_add_entities([KNXSensor(sensor)]) 
Example #27
Source File: light.py    From xknx with MIT License 5 votes vote down vote up
def async_add_entities_config(hass, config, async_add_entities):
    """Set up light for KNX platform configured within platform."""
    group_address_tunable_white = None
    group_address_tunable_white_state = None
    group_address_color_temp = None
    group_address_color_temp_state = None
    if config[CONF_COLOR_TEMP_MODE] == ColorTempModes.absolute:
        group_address_color_temp = config.get(CONF_COLOR_TEMP_ADDRESS)
        group_address_color_temp_state = config.get(CONF_COLOR_TEMP_STATE_ADDRESS)
    elif config[CONF_COLOR_TEMP_MODE] == ColorTempModes.relative:
        group_address_tunable_white = config.get(CONF_COLOR_TEMP_ADDRESS)
        group_address_tunable_white_state = config.get(CONF_COLOR_TEMP_STATE_ADDRESS)

    light = XknxLight(
        hass.data[DATA_XKNX].xknx,
        name=config[CONF_NAME],
        group_address_switch=config[CONF_ADDRESS],
        group_address_switch_state=config.get(CONF_STATE_ADDRESS),
        group_address_brightness=config.get(CONF_BRIGHTNESS_ADDRESS),
        group_address_brightness_state=config.get(CONF_BRIGHTNESS_STATE_ADDRESS),
        group_address_color=config.get(CONF_COLOR_ADDRESS),
        group_address_color_state=config.get(CONF_COLOR_STATE_ADDRESS),
        group_address_rgbw=config.get(CONF_RGBW_ADDRESS),
        group_address_rgbw_state=config.get(CONF_RGBW_STATE_ADDRESS),
        group_address_tunable_white=group_address_tunable_white,
        group_address_tunable_white_state=group_address_tunable_white_state,
        group_address_color_temperature=group_address_color_temp,
        group_address_color_temperature_state=group_address_color_temp_state,
        min_kelvin=config[CONF_MIN_KELVIN],
        max_kelvin=config[CONF_MAX_KELVIN],
    )
    hass.data[DATA_XKNX].xknx.devices.add(light)
    async_add_entities([KNXLight(light)]) 
Example #28
Source File: scene.py    From xknx with MIT License 5 votes vote down vote up
def async_add_entities_config(hass, config, async_add_entities):
    """Set up scene for KNX platform configured within platform."""
    scene = XknxScene(
        hass.data[DATA_XKNX].xknx,
        name=config[CONF_NAME],
        group_address=config[CONF_ADDRESS],
        scene_number=config[CONF_SCENE_NUMBER],
    )
    hass.data[DATA_XKNX].xknx.devices.add(scene)
    async_add_entities([KNXScene(scene)]) 
Example #29
Source File: binary_sensor.py    From xknx with MIT License 5 votes vote down vote up
def async_add_entities_config(hass, config, async_add_entities):
    """Set up binary senor for KNX platform configured within platform."""
    name = config[CONF_NAME]

    binary_sensor = BinarySensor(
        hass.data[DATA_XKNX].xknx,
        name=name,
        group_address_state=config[CONF_STATE_ADDRESS],
        sync_state=config[CONF_SYNC_STATE],
        ignore_internal_state=config[CONF_IGNORE_INTERNAL_STATE],
        device_class=config.get(CONF_DEVICE_CLASS),
        significant_bit=config[CONF_SIGNIFICANT_BIT],
        reset_after=config.get(CONF_RESET_AFTER),
    )
    hass.data[DATA_XKNX].xknx.devices.add(binary_sensor)

    entity = KNXBinarySensor(binary_sensor)
    automations = config.get(CONF_AUTOMATION)
    if automations is not None:
        for automation in automations:
            counter = automation[CONF_COUNTER]
            hook = automation[CONF_HOOK]
            action = automation[CONF_ACTION]
            entity.automations.append(
                KNXAutomation(
                    hass=hass,
                    device=binary_sensor,
                    hook=hook,
                    action=action,
                    counter=counter,
                )
            )
    async_add_entities([entity]) 
Example #30
Source File: notify.py    From xknx with MIT License 5 votes vote down vote up
def async_get_service_config(hass, config):
    """Set up notification for KNX platform configured within platform."""
    notification = XknxNotification(
        hass.data[DATA_XKNX].xknx,
        name=config[CONF_NAME],
        group_address=config[CONF_ADDRESS],
    )
    hass.data[DATA_XKNX].xknx.devices.add(notification)
    return KNXNotificationService([notification])