Exemplo n.º 1
0
def set_command(client, device_id, temp):
    """
    Set the configured command for an AC or refrigerator device.
    command is: temp, temp_freezer, turn
    """

    device = client.get_device(device_id)

    if command == 'temp':
        if device.type == wideq.client.DeviceType.AC:
            ac = wideq.ACDevice(client, _force_device(client, device_id))
            ac.set_fahrenheit(int(temp))
        elif device.type == wideq.client.DeviceType.REFRIGERATOR:
            refrigerator = wideq.RefrigeratorDevice(
                client, _force_device(client, device_id))
            refrigerator.set_temp_refrigerator_c(int(temp))
        else:
            raise InvalidUsage(
                'set-temp only suported for AC or refrigerator devices', 401)

    elif command == 'temp_freezer':
        if device.type == wideq.client.DeviceType.REFRIGERATOR:
            refrigerator = wideq.RefrigeratorDevice(
                client, _force_device(client, device_id))
            refrigerator.set_temp_freezer_c(int(temp))
        else:
            raise InvalidUsage(
                'set-temp-freezer only suported for refrigerator devices', 401)

    elif command == 'turn':
        _ac = wideq.ACDevice(client, _force_device(device_id))
        _ac.set_on(on_off == 'on')

    else:
        raise InvalidUsage('unsupported command: {}'.format(command), 401)
Exemplo n.º 2
0
def set_temp_freezer(client, device_id, temp):
    """Set the configured freezer temperature for a refrigerator device."""

    device = client.get_device(device_id)

    if device.type == wideq.client.DeviceType.REFRIGERATOR:
        refrigerator = wideq.RefrigeratorDevice(
            client, _force_device(client, device_id))
        refrigerator.set_temp_freezer_c(int(temp))
    else:
        raise UserError(
            "set-temp-freezer only suported for refrigerator devices")
Exemplo n.º 3
0
def set_temp(client, device_id, temp):
    """Set the configured temperature for an AC or refrigerator device."""

    device = client.get_device(device_id)

    if device.type == wideq.client.DeviceType.AC:
        ac = wideq.ACDevice(client, _force_device(client, device_id))
        ac.set_fahrenheit(int(temp))
    elif device.type == wideq.client.DeviceType.REFRIGERATOR:
        refrigerator = wideq.RefrigeratorDevice(
            client, _force_device(client, device_id))
        refrigerator.set_temp_refrigerator_c(int(temp))
    else:
        raise UserError(
            "set-temp only suported for AC or refrigerator devices")