Пример #1
0
async 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)
Пример #2
0
async 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)
    use_fan_only_workaround = config.get(CONF_USE_FAN_ONLY_WORKAROUND)

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

    async_add_entities(entities)
Пример #3
0
 def midea_session(self):
     self.midea_client = midea_client(config.MIDEA_API_KEY,
                                      config.MIDEA_USERNAME,
                                      config.MIDEA_PASSWORD)
     self.midea_client.setup()
Пример #4
0
def midea_init():
    global client_inst, devices
    client_inst = midea_client(settings.APPKEY, settings.EMAIL,
                               settings.PASSWORD)
    devices = client_inst.devices()