Python homeassistant.const.CONF_USERNAME Examples

The following are 11 code examples of homeassistant.const.CONF_USERNAME(). 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: midea.py    From midea-ac-py with MIT License 6 votes vote down vote up
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) 
Example #2
Source File: device_tracker.py    From audi_connect_ha with MIT License 6 votes vote down vote up
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 
Example #3
Source File: light.py    From example-custom-config with Apache License 2.0 6 votes vote down vote up
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()) 
Example #4
Source File: sure_petflap.py    From sure_petcare with GNU General Public License v3.0 5 votes vote down vote up
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)]) 
Example #5
Source File: my_sleepiq.py    From HomeAssistantConfig with MIT License 5 votes vote down vote up
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 
Example #6
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 #7
Source File: switch.py    From audi_connect_ha with MIT License 5 votes vote down vote up
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) 
Example #8
Source File: binary_sensor.py    From audi_connect_ha with MIT License 5 votes vote down vote up
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) 
Example #9
Source File: lock.py    From audi_connect_ha with MIT License 5 votes vote down vote up
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) 
Example #10
Source File: sensor.py    From audi_connect_ha with MIT License 5 votes vote down vote up
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) 
Example #11
Source File: __init__.py    From home-assistant-archive with MIT License 4 votes vote down vote up
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