コード例 #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)
コード例 #2
0
    def return_ac_info(self, device_id):

        ac = wideq.ACDevice(self.client, self._force_device(device_id))

        retry_count = 10
        while retry_count:
            try:
                ac.monitor_start()
                state = ac.poll()
                if state:
                    return [
                        state.temp_cur_c, state.temp_cfg_c,
                        state.fan_speed.name
                    ]

                time.sleep(10)

            except wideq.NotLoggedInError:
                time.sleep(10)
                retry_count -= 1
                self.client.refresh()

        else:
            print("Session could not be extablished")
            sys.exit(0)
コード例 #3
0
    def turn_jet_mode(self, device_id, jet_opt):

        ac = wideq.ACDevice(self.client, self._force_device(device_id))

        retry_count = 5
        while retry_count:
            try:
                selected_jet_mode = JET_ARG.get(jet_opt.upper(), 'N/A')

                if (selected_jet_mode == 'N/A'):
                    print('INVALID MODE!...')
                    print('Please select one of ' + ', '.join(JET_ARG))
                    return False

                ac.set_jet_mode(selected_jet_mode)
                break

            except wideq.NotLoggedInError:
                time.sleep(10)
                retry_count -= 1
                self.client.refresh()

        else:
            print("Session could not be extablished")
            sys.exit(0)
コード例 #4
0
    def fan_speed(self, device_id, speed):

        ac = wideq.ACDevice(self.client, self._force_device(device_id))

        retry_count = 5
        while retry_count:
            try:
                selected_speed = SPEED_ARG.get(speed.upper(), 'N/A')

                if (selected_speed == 'N/A'):
                    print('INVALID SPEED!...')
                    print('Please select one of ' + ', '.join(SPEED_ARG))
                    return False

                ac.set_fan_speed(selected_speed)
                break

            except wideq.NotLoggedInError:
                time.sleep(10)
                retry_count -= 1
                self.client.refresh()

        else:
            print("Session could not be extablished")
            sys.exit(0)
コード例 #5
0
def ac_mon(client, device_id):
    """Monitor an AC/HVAC device, showing higher-level information about
    its status such as its temperature and operation mode.
    """

    device = client.get_device(device_id)
    if device.type != wideq.DeviceType.AC:
        print('This is not an AC device.')
        return

    ac = wideq.ACDevice(client, device)

    try:
        ac.monitor_start()
        while True:
            time.sleep(1)
            state = ac.poll()
            if state:
                print('{1}; '
                      '{0.mode.name}; '
                      'cur {0.temp_cur_f}°F; '
                      'cfg {0.temp_cfg_f}°F; '
                      'fan speed {0.fan_speed.name}'.format(
                          state, 'on' if state.is_on else 'off'))

    except KeyboardInterrupt:
        pass
    finally:
        ac.monitor_stop()
コード例 #6
0
    def turn(self, device_id, on_off):

        ac = wideq.ACDevice(self.client, self._force_device(device_id))

        retry_count = 5
        while retry_count:
            try:
                ac.monitor_start()
                state = ac.poll()
                if (state):
                    if (not state.is_on and on_off == 'on'):
                        ac.set_on(True)
                    elif (state.is_on and on_off == 'off'):
                        ac.set_on(False)
                    break

                time.sleep(10)

            except wideq.NotLoggedInError:
                time.sleep(10)
                retry_count -= 1
                self.client.refresh()

        else:
            print("Session could not be extablished")
            sys.exit(0)
コード例 #7
0
    def __init__(self, client, device, fahrenheit=False):
        self._client = client
        self._device = device
        self._fahrenheit = fahrenheit

        import wideq
        self._ac = wideq.ACDevice(client, device)
        self._ac.monitor_start()

        # The response from the monitoring query.
        self._state = None

        # Store a transient temperature when we've just set it. We also
        # store the timestamp for when we set this value.
        self._transient_temp = None
        self._transient_time = None

        # Store supported fan speeds
        device_info = device.load_model_info()
        supported_fan_speeds = device_info['Value']['SupportWindStrength'][
            'option']
        self._supported_fan_speeds = {
            v: k
            for k, v in supported_fan_speeds.items()
        }

        self.update()
コード例 #8
0
def ac_config(client, device_id):
    ac = wideq.ACDevice(client, client.get_device(device_id))
    print(ac.get_filter_state())
    print(ac.get_mfilter_state())
    print(ac.get_energy_target())
    print(ac.get_volume())
    print(ac.get_light())
コード例 #9
0
ファイル: example.py プロジェクト: wkd8176/wideq
def ac_power(client, device_id):
    ac = wideq.ACDevice(client, client.get_device(device_id))
    print(ac.get_outtotalinstantpower())
    print(ac.get_inoutinstantpower())
    print(ac.get_energy_usage_day())
    print(ac.get_energy_usage_week())
    print(ac.get_energy_usage_month())
コード例 #10
0
ファイル: example.py プロジェクト: ueilat/wideq
def ac_config(client, device_id):
    ac = wideq.ACDevice(client, _force_device(client, device_id))
    print(ac.get_filter_state())
    print(ac.get_mfilter_state())
    print(ac.get_energy_target())
    print(ac.get_power(), " watts")
    print(ac.get_outdoor_power(), " watts")
    print(ac.get_volume())
    print(ac.get_light())
    print(ac.get_zones())
コード例 #11
0
def set_speed(client, device_id, speed):
    ac = wideq.ACDevice(client, _force_device(client, device_id))
    speed_mapping = {
        '12.5': wideq.ACFanSpeed.SLOW, #Not supported
        '25': wideq.ACFanSpeed.SLOW_LOW, #Not supported
        '37.5': wideq.ACFanSpeed.LOW,
        '50': wideq.ACFanSpeed.LOW_MID,
        '62.5': wideq.ACFanSpeed.MID,
        '75': wideq.ACFanSpeed.MID_HIGH,
        '87.5': wideq.ACFanSpeed.HIGH,
        '100': wideq.ACFanSpeed.POWER #Not supported
    }
    ac.set_fan_speed(speed_mapping[speed])
コード例 #12
0
def ac_config(device_id):
    """
    config for Air Climatized device
    """
    _ac = wideq.ACDevice(client, _force_device(device_id))
    print(_ac.get_filter_state())
    print(_ac.get_mfilter_state())
    print(_ac.get_energy_target())
    print(_ac.get_power(), " watts")
    print(_ac.get_outdoor_power(), " watts")
    print(_ac.get_volume())
    print(_ac.get_light())
    print(_ac.get_zones())
コード例 #13
0
ファイル: example.py プロジェクト: yjh96/wideq
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")
コード例 #14
0
    def __init__(self, client, device, fahrenheit=True):
        self._client = client
        self._device = device
        self._fahrenheit = fahrenheit

        import wideq
        self._ac = wideq.ACDevice(client, device)
        self._ac.monitor_start()

        # The response from the monitoring query.
        self._state = None

        # Store a transient temperature when we've just set it. We also
        # store the timestamp for when we set this value.
        self._transient_temp = None
        self._transient_time = None
コード例 #15
0
    def set_temp(self, device_id, temp):

        ac = wideq.ACDevice(self.client, self._force_device(device_id))

        retry_count = 5
        while retry_count:
            try:
                ac.set_celsius(int(temp))
                break

            except wideq.NotLoggedInError:
                time.sleep(10)
                retry_count -= 1
                self.client.refresh()

        else:
            print("Session could not be extablished")
            sys.exit(0)
コード例 #16
0
ファイル: LGACServerNew.py プロジェクト: stingone/LGAC_SmartT
def ac_commands_handler(acDevNum, token, q):
    client = wideq.Client.from_token(token)
    device = client.get_device(acDevNum)
    if device.type != wideq.DeviceType.AC:
        logger.debug('This is not an AC device.')
        return
    ac = wideq.ACDevice(client, device)
    connRefresh = 0
    try:
        ac.monitor_start()
        while True:
            msg = q.get()
            try:
                cmd = msg.pop(0)
                if hasattr(ACCommand, cmd):
                    connRefresh += 1
                    result = getattr(ACCommand, cmd)(ac, *msg)
                    if 'exception' in result:
                        if result['exception'] == 'no response':
                            print('Client refreshing')
                            client.refresh()
                            ac.monitor_start()
                    if connRefresh > 10:
                        print('Monitor restart')
                        ac.monitor_stop()
                        client.refresh()
                        ac.monitor_start()
                        connRefresh = 0
                else:
                    result = {'exception': 'command [%s] not found' % cmd}
            except (Exception) as e:
                result = {'exception': 'python-LGAC: %s' % e}
                continue
            finally:
                result.update({'cmd': cmd})
                logger.debug('ac result %s', result)
                send.put(OutMsg(result, msg.to))
    except KeyboardInterrupt:
        pass
    finally:
        ac.monitor_stop()
        print('AC connection STOP')
コード例 #17
0
    def __init__(self, client, device, celsius=True):
        """initialize a LGE HAVC Device."""
        LGEDevice.__init__(self, client, device)
        self._celsius = celsius

        import wideq
        self._ac = wideq.ACDevice(client, device)

        self._ac.monitor_start()
        self._ac.monitor_start()
        self._ac.delete_permission()
        self._ac.delete_permission()

        # The response from the monitoring query.
        self._state = None
        # Store a transient temperature when we've just set it. We also
        # store the timestamp for when we set this value.
        self._transient_temp = None
        self._transient_time = None

        self.update()
コード例 #18
0
def turn(client, device_id, on_off):
    """Turn on/off an AC device."""

    ac = wideq.ACDevice(client, client.get_device(device_id))
    ac.set_on(on_off == 'on')
コード例 #19
0
def set_mode(client, device_id, mode):
    ac = wideq.ACDevice(client, _force_device(client, device_id))
    ac.set_mode(wideq.ACMode[mode])
コード例 #20
0
def set_fan_speed(client, device_id, speed):
    ac = wideq.ACDevice(client, _force_device(client, device_id))
    ac.set_fan_speed(wideq.ACFanSpeed[speed])
コード例 #21
0
def set_swing_mode_v(client, device_id, swing_mode_v):
    ac = wideq.ACDevice(client, _force_device(client, device_id))
    ac.set_vert_swing(wideq.ACVSwingMode[swing_mode_v])
コード例 #22
0
def set_swing_mode_h(client, device_id, swing_mode_h):
    ac = wideq.ACDevice(client, _force_device(client, device_id))
    ac.set_horz_swing(wideq.ACHSwingMode[swing_mode_h])
コード例 #23
0
def get_power_draw(client, device_id):
    ac = wideq.ACDevice(client, _force_device(client, device_id))
    print(ac.get_power())
コード例 #24
0
def set_temp(client, device_id, temp):
    """Set the configured temperature for an AC device."""

    ac = wideq.ACDevice(client, _force_device(client, device_id))
    ac.set_celsius(int(temp))
コード例 #25
0
ファイル: example.py プロジェクト: FattusMannus/wideq-gb
def ac_power(client, device_id):
    ac = wideq.ACDevice(client, client.get_device(device_id))
    print(ac.get_energy_usage())
コード例 #26
0
ファイル: example.py プロジェクト: FattusMannus/wideq-gb
def set_vstep(client, device_id, value):
    """Set the configured temperature for an AC device."""

    ac = wideq.ACDevice(client, client.get_device(device_id))
    ac.set_wdirvstep(value)
コード例 #27
0
ファイル: example.py プロジェクト: wkd8176/wideq
def ac_outdoor_temp(client, device_id):
    ac = wideq.ACDevice(client, client.get_device(device_id))
    print(ac.get_outdoor_temp())
コード例 #28
0
def set_temp(client, device_id, temp):
    """Set the configured temperature for an AC device."""

    ac = wideq.ACDevice(client, client.get_device(device_id))
    ac.set_fahrenheit(int(temp))
コード例 #29
0
ファイル: example.py プロジェクト: yjh96/wideq
def turn(client, device_id, on_off):
    """Turn on/off an AC device."""

    ac = wideq.ACDevice(client, _force_device(client, device_id))
    ac.set_on(on_off == "on")