当前位置: 首页>>代码示例>>Python>>正文


Python const.CONF_USERNAME属性代码示例

本文整理汇总了Python中homeassistant.const.CONF_USERNAME属性的典型用法代码示例。如果您正苦于以下问题:Python const.CONF_USERNAME属性的具体用法?Python const.CONF_USERNAME怎么用?Python const.CONF_USERNAME使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在homeassistant.const的用法示例。


在下文中一共展示了const.CONF_USERNAME属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: async_setup_platform

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_USERNAME [as 别名]
def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
    """Set up the Midea cloud service and query appliances."""

    from midea.client import client as midea_client

    app_key = config.get(CONF_APP_KEY)
    username = config.get(CONF_USERNAME)
    password = config.get(CONF_PASSWORD)
    temp_step = config.get(CONF_TEMP_STEP)
    include_off_as_state = config.get(CONF_INCLUDE_OFF_AS_STATE)

    client = midea_client(app_key, username, password)
    devices = client.devices()
    entities = []
    for device in devices:
        if(device.type == 0xAC):
            entities.append(MideaClimateACDevice(
                device, temp_step, include_off_as_state))
        else:
            _LOGGER.error(
                "Unsupported device type: 0x{:02x}".format(device.type))

    async_add_entities(entities) 
开发者ID:NeoAcheron,项目名称:midea-ac-py,代码行数:25,代码来源:midea.py

示例2: async_setup_entry

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_USERNAME [as 别名]
def async_setup_entry(hass, config_entry, async_add_entities):
    async def see_vehicle(instrument):
        """Handle the reporting of the vehicle position."""
        if instrument.vehicle_name in hass.data[DOMAIN]["devices"]:
            return

        hass.data[DOMAIN]["devices"].add(instrument.vehicle_name)

        async_add_entities([AudiDeviceTracker(instrument)])

    async_dispatcher_connect(hass, TRACKER_UPDATE, see_vehicle)

    account = config_entry.data.get(CONF_USERNAME)
    audiData = hass.data[DOMAIN][account]

    for config_vehicle in audiData.config_vehicles:
        for device_tracker in config_vehicle.device_trackers:
            async_dispatcher_send(hass, TRACKER_UPDATE, device_tracker)

    return True 
开发者ID:arjenvrh,项目名称:audi_connect_ha,代码行数:22,代码来源:device_tracker.py

示例3: setup_platform

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_USERNAME [as 别名]
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Awesome Light platform."""
    # Assign configuration variables.
    # The configuration check takes care they are present.
    host = config[CONF_HOST]
    username = config[CONF_USERNAME]
    password = config.get(CONF_PASSWORD)

    # Setup connection with devices/cloud
    hub = awesomelights.Hub(host, username, password)

    # Verify that passed in configuration works
    if not hub.is_valid_login():
        _LOGGER.error("Could not connect to AwesomeLight hub")
        return

    # Add devices
    add_entities(AwesomeLight(light) for light in hub.lights()) 
开发者ID:home-assistant,项目名称:example-custom-config,代码行数:20,代码来源:light.py

示例4: setup_platform

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_USERNAME [as 别名]
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the sensor platform."""
    username = config.get(CONF_USERNAME)
    password = config.get(CONF_PASSWORD)
    add_devices([SurePetConnect(username, password)]) 
开发者ID:rcastberg,项目名称:sure_petcare,代码行数:7,代码来源:sure_petflap.py

示例5: setup

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_USERNAME [as 别名]
def setup(hass, config):
    """Set up the SleepIQ component.

    Will automatically load sensor components to support
    devices discovered on the account.
    """
    # pylint: disable=global-statement
    global DATA

    from sleepyq import Sleepyq
    username = config[DOMAIN][CONF_USERNAME]
    password = config[DOMAIN][CONF_PASSWORD]
    client = Sleepyq(username, password)
    try:
        DATA = SleepIQData(client)
        DATA.update()
    except HTTPError:
        message = """
            SleepIQ failed to login, double check your username and password"
        """
        _LOGGER.error(message)
        return False

    discovery.load_platform(hass, 'sensor', DOMAIN, {}, config)
    discovery.load_platform(hass, 'binary_sensor', DOMAIN, {}, config)

    return True 
开发者ID:Teagan42,项目名称:HomeAssistantConfig,代码行数:29,代码来源:my_sleepiq.py

示例6: setup_platform

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_USERNAME [as 别名]
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)]) 
开发者ID:macbury,项目名称:SmartHouse,代码行数:10,代码来源:sensor.py

示例7: async_setup_entry

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_USERNAME [as 别名]
def async_setup_entry(hass, config_entry, async_add_entities):

    sensors = []
    account = config_entry.data.get(CONF_USERNAME)
    audiData = hass.data[DOMAIN][account]

    for config_vehicle in audiData.config_vehicles:
        for switch in config_vehicle.switches:
            sensors.append(AudiSwitch(config_vehicle, switch))

    async_add_entities(sensors) 
开发者ID:arjenvrh,项目名称:audi_connect_ha,代码行数:13,代码来源:switch.py

示例8: async_setup_entry

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_USERNAME [as 别名]
def async_setup_entry(hass, config_entry, async_add_entities):

    sensors = []
    account = config_entry.data.get(CONF_USERNAME)
    audiData = hass.data[DOMAIN][account]

    for config_vehicle in audiData.config_vehicles:
        for binary_sensor in config_vehicle.binary_sensors:
            sensors.append(AudiSensor(config_vehicle, binary_sensor))

    async_add_entities(sensors) 
开发者ID:arjenvrh,项目名称:audi_connect_ha,代码行数:13,代码来源:binary_sensor.py

示例9: async_setup_entry

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_USERNAME [as 别名]
def async_setup_entry(hass, config_entry, async_add_entities):

    sensors = []
    account = config_entry.data.get(CONF_USERNAME)
    audiData = hass.data[DOMAIN][account]

    for config_vehicle in audiData.config_vehicles:
        for lock in config_vehicle.locks:
            sensors.append(AudiLock(config_vehicle, lock))

    async_add_entities(sensors) 
开发者ID:arjenvrh,项目名称:audi_connect_ha,代码行数:13,代码来源:lock.py

示例10: async_setup_entry

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_USERNAME [as 别名]
def async_setup_entry(hass, config_entry, async_add_entities):
    sensors = []

    account = config_entry.data.get(CONF_USERNAME)
    audiData = hass.data[DOMAIN][account]

    for config_vehicle in audiData.config_vehicles:
        for sensor in config_vehicle.sensors:
            sensors.append(AudiSensor(config_vehicle, sensor))

    async_add_entities(sensors, True) 
开发者ID:arjenvrh,项目名称:audi_connect_ha,代码行数:13,代码来源:sensor.py

示例11: setup_account

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_USERNAME [as 别名]
def setup_account(account_config: dict, hass, name: str) \
        -> 'BMWConnectedDriveAccount':
    """Set up a new BMWConnectedDriveAccount based on the config."""
    username = account_config[CONF_USERNAME]
    password = account_config[CONF_PASSWORD]
    region = account_config[CONF_REGION]
    read_only = account_config[CONF_READ_ONLY]
    _LOGGER.debug('Adding new account %s', name)
    cd_account = BMWConnectedDriveAccount(username, password, region, name,
                                          read_only)

    def execute_service(call):
        """Execute a service for a vehicle.

        This must be a member function as we need access to the cd_account
        object here.
        """
        vin = call.data[ATTR_VIN]
        vehicle = cd_account.account.get_vehicle(vin)
        if not vehicle:
            _LOGGER.error('Could not find a vehicle for VIN "%s"!', vin)
            return
        function_name = _SERVICE_MAP[call.service]
        function_call = getattr(vehicle.remote_services, function_name)
        function_call()
    if not read_only:
        # register the remote services
        for service in _SERVICE_MAP:
            hass.services.register(
                DOMAIN, service,
                execute_service,
                schema=SERVICE_SCHEMA)

    # update every UPDATE_INTERVAL minutes, starting now
    # this should even out the load on the servers
    now = datetime.datetime.now()
    track_utc_time_change(
        hass, cd_account.update,
        minute=range(now.minute % UPDATE_INTERVAL, 60, UPDATE_INTERVAL),
        second=now.second)

    return cd_account 
开发者ID:gerard33,项目名称:home-assistant-archive,代码行数:44,代码来源:__init__.py


注:本文中的homeassistant.const.CONF_USERNAME属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。