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


Python const.CONF_PASSWORD属性代码示例

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


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

示例1: async_setup_platform

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_PASSWORD [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: setup_platform

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_PASSWORD [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

示例3: setup_platform

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_PASSWORD [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

示例4: setup

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_PASSWORD [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

示例5: setup_platform

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_PASSWORD [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

示例6: validate_input

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_PASSWORD [as 别名]
def validate_input(hass, data):
    """Validate the user input allows us to connect.

    Data has the keys from DATA_SCHEMA with values provided by the user.
    """

    try:
        wiser = await hass.async_add_executor_job(
            wiserHub, data[CONF_HOST], data[CONF_PASSWORD]
        )
        wiser_id = await hass.async_add_executor_job(wiser.getWiserHubName)

    except WiserHubTimeoutException:
        raise CannotConnect
    except WiserHubAuthenticationException:
        raise InvalidAuth
    except WiserRESTException:
        raise UnknownError
    except requests.exceptions.ConnectionError:
        raise CannotConnect
    except RuntimeError:
        raise UnknownError

    unique_id = str(f"{DOMAIN}-{wiser_id}")
    name = wiser_id

    return {"title": name, "unique_id": unique_id} 
开发者ID:asantaga,项目名称:wiserHomeAssistantPlatform,代码行数:29,代码来源:config_flow.py

示例7: setup_account

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_PASSWORD [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

示例8: async_setup_entry

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_PASSWORD [as 别名]
def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
    """Set up OpenSprinkler from a config entry."""
    hass.data.setdefault(DOMAIN, {})

    url = entry.data.get(CONF_URL)
    password = entry.data.get(CONF_PASSWORD)
    try:
        controller = OpenSprinkler(url, password)
        controller.refresh_on_update = False

        async def async_update_data():
            """Fetch data from OpenSprinkler."""
            _LOGGER.debug("refreshing data")
            async with async_timeout.timeout(TIMEOUT):
                try:
                    await hass.async_add_executor_job(controller.refresh)
                except Exception as exc:
                    raise UpdateFailed("Error fetching OpenSprinkler state") from exc

                if not controller._state:
                    raise UpdateFailed("Error fetching OpenSprinkler state")

                return controller._state

        scan_interval = entry.options.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)
        coordinator = DataUpdateCoordinator(
            hass,
            _LOGGER,
            name="OpenSprinkler resource status",
            update_method=async_update_data,
            update_interval=timedelta(seconds=scan_interval),
        )

        # initial load before loading platforms
        await coordinator.async_refresh()

        hass.data[DOMAIN][entry.entry_id] = {
            "coordinator": coordinator,
            "controller": controller,
        }

    except (OpenSprinklerAuthError, OpenSprinklerConnectionError) as exc:
        _LOGGER.error("Unable to connect to OpenSprinkler controller: %s", str(exc))
        raise ConfigEntryNotReady

    for component in PLATFORMS:
        hass.async_create_task(
            hass.config_entries.async_forward_entry_setup(entry, component)
        )

    return True 
开发者ID:vinteo,项目名称:hass-opensprinkler,代码行数:53,代码来源:__init__.py


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