當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。