From f34c1a693669ca7e687a54e0a68b40f75ebba695 Mon Sep 17 00:00:00 2001 From: Kevin Van den Abeele Date: Thu, 9 Jul 2020 13:44:13 +0200 Subject: [PATCH] Updated wideq (jet mode) & hoepfully fixed issue with corrupted state file --- README.md | 1 + package-lock.json | 2 +- package.json | 2 +- resources/wideq/example.py | 2 +- resources/wideq/wideq/ac.py | 25 +++++++++++++++++++++++++ src/lg/wideq-adapter.ts | 2 +- 6 files changed, 30 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 791ba5c..78a0531 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ After that an update of the state is performed every minute. - Open a terminal on the device where you installed this plugin and type: `cd "$(npm root -g)" && cd homebridge-lg-airco/resources/wideq` - Your terminal should navigate to the folder, if any error comes up the plugin was not installed correctly! +- Make sure requests has been installed, if not execute: `sudo python3 -m pip install requests` - Execute the command `python3 example.py -c country-code -l language-code -p path-to-wideq-file-in-homebridge-folder` where you should replace `country-code`, `language-code` and `path-to-homebridge-folder` with the respective values. For example: `python3 example.py -c BE -l en-UK -p /home/pi/.homebridge/wideq_state.json` - Make sure the wideq_state.json does not exist yet! If the file is corrupted, delete it before executing the command again! diff --git a/package-lock.json b/package-lock.json index c33c589..546f2c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "homebridge-lg-airco", - "version": "0.1.0-beta4", + "version": "0.1.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index c8fecd1..b61a442 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-lg-airco", - "version": "0.1.3", + "version": "0.1.4", "description": "Homebridge plugin to control a Smart Thinq enabled LG airco unit. Makes use of WideQ => https://github.com/sampsyo/wideq", "main": "src/index.js", "scripts": { diff --git a/resources/wideq/example.py b/resources/wideq/example.py index 18e1d3f..04dc72a 100755 --- a/resources/wideq/example.py +++ b/resources/wideq/example.py @@ -105,7 +105,7 @@ def ac_mon(client, device_id): 'on' if state.is_on else 'off' ) ) - + break except KeyboardInterrupt: pass finally: diff --git a/resources/wideq/wideq/ac.py b/resources/wideq/wideq/ac.py index c6252eb..1a08070 100644 --- a/resources/wideq/wideq/ac.py +++ b/resources/wideq/wideq/ac.py @@ -7,6 +7,24 @@ from .core import FailedRequestError +class ACJetMode(enum.Enum): + """JET mode puts your AC into highest cooling or dry or + heat mode(for a certain amount of time) depending on what you choose + + This mode Overrides following setting: + 1. Vertical swing is set to @100 + 2. Temperature gets set to 18 after jet mode turns off + 3. Fan speed is set to HIGH (@AC_MAIN_WIND_STRENGTH_HIGH_W) + after jet mode turns off + """ + + OFF = "@OFF" + COOL = "@COOL_JET" + HEAT = "@HEAT_JET" + DRY = "@DRY_JET_W" + HIMALAYAS = "@HIMALAYAS_COOL" + + class ACVSwingMode(enum.Enum): """The vertical swing mode for an AC/HVAC device. @@ -235,6 +253,13 @@ def get_zones(self): return self._get_config('DuctZone') + def set_jet_mode(self, jet_opt): + """Set jet mode to a value from the `ACJetMode` enum. + """ + + jet_opt_value = self.model.enum_value('Jet', jet_opt.value) + self._set_control('Jet', jet_opt_value) + def set_fan_speed(self, speed): """Set the fan speed to a value from the `ACFanSpeed` enum. """ diff --git a/src/lg/wideq-adapter.ts b/src/lg/wideq-adapter.ts index 0c87e92..5d2688f 100644 --- a/src/lg/wideq-adapter.ts +++ b/src/lg/wideq-adapter.ts @@ -51,7 +51,7 @@ export class WideqAdapter { public async getStatus(deviceId: string): Promise { try { - const data: string = await PythonUtils.executePython3(WideqAdapter.wideqFolder, WideqAdapter.wideqScriptFile, ['-c', this.country, '-l', this.language, '-p', this.storagePath, this.debug ? '-v' : null, 'ac-mon', deviceId], true); + const data: string = await PythonUtils.executePython3(WideqAdapter.wideqFolder, WideqAdapter.wideqScriptFile, ['-c', this.country, '-l', this.language, '-p', this.storagePath, this.debug ? '-v' : null, 'ac-mon', deviceId]); this.logDebug(data); const dataPieces: string[] = data.split(';').map(s => s.trim());