nVuln / homebridge-lg-thinq

A Homebridge plugin for controlling/monitoring LG ThinQ device via their ThinQ platform.
https://github.com/nVuln/homebridge-lg-thinq
Apache License 2.0
212 stars 48 forks source link

Support for Dehumidifier, Washer, & Dryer #4

Closed town3r closed 2 years ago

town3r commented 3 years ago

Is your feature request related to a problem? Please describe: Currently only supports Refrigerator and Air Purifiers. Other devices don't show up.

Describe the solution you'd like: Ability to monitor status & possibly control additional devices. ie

Describe alternatives you've considered: Looks like an older version (wideq) used to have the ability to do this. https://github.com/ssut/wideq-js

Additional context: Example of LG devices that you might be able to add support for from wideq-js: Device Implementation Status Control
Dehumidifier ✔️ ✔️ ✔️
AC ✔️ ⚠️ needs testing ⚠️ needs testing
Refrigerator ✔️ ✔️ ✔️
Dishwasher ✔️ ⚠️ needs testing
Dryer ✔️ ⚠️ needs testing
Washer ✔️ ⚠️ needs testing
nVuln commented 3 years ago

their new API is really different, that why I created new repository instead of make PR to wideq-js I'm trying implement as much as possible, my priority is my owned device (air purifier, refrigerator, and next is washer dryer)

nVuln commented 3 years ago

@town3r when you turn debug mode on, you can see device data of Washer and Dryer and Dehumidifier (in case your device using thinq v2), please upload it here and I'll try my best to implement it thank you so much

town3r commented 3 years ago

Looks like both use v2. (I think)

Let me know if you need anything else or there's something i shouldn't have included.

LG ThinQ HomeBridge logs.txt

town3r commented 3 years ago

:O They're showing up!

[27/04/2021, 10:42:10] [LGThinQ] Found device:  xxxxx: Washer (WASHER T1789EFH_F)
[27/04/2021, 10:42:10] [LGThinQ] Restoring existing accessory from cache: Washer
[27/04/2021, 10:42:10] [LGThinQ] Found device:  xxxxx: Dehumidifier (DEHUMIDIFIER DHUM_056905_WW)
[27/04/2021, 10:42:10] [LGThinQ] Restoring existing accessory from cache: Dehumidifier
[27/04/2021, 10:42:10] [LGThinQ] Found device:  xxxxx: Dryer (DRYER RV13U6AM8W_D_US_WIFI)
[27/04/2021, 10:42:10] [LGThinQ] Restoring existing accessory from cache: Dryer
town3r commented 3 years ago

I'm not really seeing any Debug logs from the devices communicating w/ HomeKit or LG regarding their current status.

nVuln commented 3 years ago

I'm not really seeing any Debug logs from the devices communicating w/ HomeKit or LG regarding their current status.

yep, I write log for not supported device only Is their showing correct status ?

town3r commented 3 years ago

Dehumidifier needs some work. This is what I see within the Home app.

IMG_1113

This is what the LG app shows normally: IMG_1114

I was thinking you might be able to setup current humidity level as a humidityAccessory. Similar to how the homebridge-dyson-pure-cool plugin works.

dyson-pure-cool-device.txt

nVuln commented 3 years ago

I updated a bit, added humidity threshold control

town3r commented 3 years ago

Nice!

Has the update been pushed out? I saw the plugin jumped from v0.1.9 to v0.1.10 but didn't notice any changes on the devices.

It would be kind of cool if the Plugin Settings would update w/ the list of devices and let you enable/disable which are added to HomeKit or even enable/disable which specific toggle options are visible

ie: The Child Lock & Door Lock toggles for both Washer/Dryer.

For the Dehumidifier: Are you able to remove the "Humidify" option? It really should just be: Auto (Smart), On, & Off Would be really cool if it also displayed current Humidity level & it sounds like you're working on adding the desired humidity % control.

Really impressed so far! Keep up the awesome work. :)

nVuln commented 3 years ago

I'm planning remove child lock and door lock option in Washer (until Homekit completed support Washer) For the dehumidifier, at latest version (v0.1.10), current humidity level not showing on Homekit? I just added it in v0.1.10, and humidity desired also

town3r commented 3 years ago

Oh nice! I had installed v0.1.10 last night but didn't see the change. Had to downgraded back to v0.1.9 and upgraded back to v0.1.10 This is what I'm seeing in the Home app now. IMG_1124

town3r commented 3 years ago

I'm noticing the following error in the debug logs:

(node:26577) UnhandledPromiseRejectionWarning: Error: Request failed with status code 400
    at createError (/usr/local/lib/node_modules/homebridge-lg-thinq/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/usr/local/lib/node_modules/homebridge-lg-thinq/node_modules/axios/lib/core/settle.js:17:12)
    at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/homebridge-lg-thinq/node_modules/axios/lib/adapters/http.js:260:11)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
(node:26577) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1897)
nVuln commented 3 years ago

thanks for your report i'll investigate it carefully

town3r commented 3 years ago

v0.1.11 seems to have resolved the error messages. :)

town3r commented 3 years ago

If possible, could you enable debug logs for the dehumidifier devices? I'd like to watch and see which API values change when I make changes to the devices current state. ie: Fan on Low or High, When the water bucket becomes full.

A few things to note about the Dehumidifier device status and toggles.

It currently has Auto, Humidify, & Off. The device it self can't humidify the air, it can only Dehumidify it. Could be just Auto & Off or Smart & Off or On & Off.

The current humidity level also isn't being displayed yet. A Temperature is displayed but it is stuck at -11 which I know the room it's in isn't that cold. I also do not think my device really has any TemperatureSensor for the Air. It should have a HumiditySensor tho.

I found some of the following, sadly i don't know enough to really modify your awesome work to see which would work or not.

Let me know if there's anything on my side that could help.

"airState.humidity.current" = public.hap.characteristic.relative-humidity.current

HAP-Specification-Non-Commercial-Version.pdf

8.20 Humidity Sensor 9.34 Current Relative Humidity 9.76 Relative Humidity Dehumidifier Threshold 9.81 Rotation Speed

A dehumidifier must include ”9.76 Relative Humidity Dehumidifier Threshold” (page 194). 9.81 Rotation Speed” (page 197) to control fan speed if the fan cannot be independently controlled.

nVuln commented 3 years ago

I already implemented Current Relative Humidity but I don't know why it's not showing up I'll remove TemperatureSensor in next release for Rotation Speed, homekit only support 0 - 100% speed

town3r commented 3 years ago

image

Power options seem to be fixed..

Temp is still being displayed instead of current humidity.

town3r commented 3 years ago

Getting closer!

The room environment button now has current humidity but it's tiny under the broken temp sensor. image

Also looks like it no longer says what the desired humidity level is anymore. image

The two accessories that are added: -Temperature -Dehumidifier -Current Relative Humidity

image

Are you able to add a Humidity Sensor as third accessory?

8.20 Humidity Sensor (page 145) public.hap.service.sensor.humidity

And as always thank you for all your hard work on this!

nVuln commented 3 years ago

Yes I can add Humidity Sensor but it's will be duplicated (I think), because HumidifierDehumidifier already have CurrentRelativeHumidity characteristic (your home app is showing up current humidity, I think we remove temperature and it will be fine)

For temperature sensor, I think it's got cached in Home App, try manual "Reset Homebridge Accessory", remove and re-add Homebridge in Home App

town3r commented 3 years ago

Nice!

The Remove Single Cached Accessory from Homebridge worked and now the temperature sensor accessory is gone.

This is what it's displaying now:

Random Temp is gone! Yay. Missing Target Humidity % value. image

Single Accessory that includes current humidity image

A separate accessory for just the humidity sensor would allow it to display the current humidity level under the Climate dashboard. image

town3r commented 3 years ago

Oh just saw the new update. Installing and clearing cached device real quick.

town3r commented 3 years ago

Desired humidity % is back! :)

image

image

Looks like a separate humidity accessory is needed if we want the current humidity to be included/displayed under climate. image

nVuln commented 3 years ago

I added HumiditySensor in new release How about controlling humidity desired and turn on/off from Homekit ? it's work ?

town3r commented 3 years ago

Great work!

Any idea if it's possible to detect when the device is actually running and dehumidifying vs sitting idle waiting for the humidity % to go past the desired level?

nVuln commented 3 years ago

on LG app is showing idle status? I just looked at model specification but nothing related "idle" status

I think when "current humidity" higher than desired, it's actually running and dehumidifying to lower "current humidity", otherwise it's idle waiting, that right?

town3r commented 3 years ago

The device status icon changed depending on if it's idle or actively running.

Idle image

Running image

town3r commented 3 years ago

I'd be happy to grab the debug logs of from the device when it's status changes if you're able to enable debug/verbose logging for devices that aren't technically experiencing errors.

nVuln commented 3 years ago

I'd be happy to grab the debug logs of from the device when it's status changes if you're able to enable debug/verbose logging for devices that aren't technically experiencing errors.

I'll insert debug logging for dehumidifier data in 0.2.2-test.1, data will write once at homebridge startup, when you see device changed status to idle, just restart homebridge to get new device data I'll compare to find which is different, hope that help

town3r commented 3 years ago

Here's a google sheet of the debug logs I collected. https://docs.google.com/spreadsheets/d/1caTTNeVThx1eECmGAoeDQmCvdGi4DuJb1o1kEuuqBdM/edit?usp=sharing

I think you're right.

Found this which shows no idle option 😢 Turning the device Off and On changes : airState.operation: from 0 to 1

"airState.operation": {
 "data_type": "enum",
 "default": "0",
 "value_mapping": {
   "0": "@operation_off",
   "1": "@operation_on"

Think it would be possible to utilize the values of airState.humidity.current:60, & airState.humidity.desired:75, to set the HomeKit status as Idle

If airState.humidity.current is less than airState.humidity.desired set public.hap.characteristic.humidifier-dehumidifier.state.current to 1 ”Idle”?

Also found that the airState.miscFuncState.watertankLight:, value doesn't seem to change when the water tank is full / empty. Even tho the app sends a notification and the bucket full light turns on when full. Nothing changed in the debug log.

For the fan speed found: "airState.windStrength":2, = Low "airState.windStrength":6, = High But as you mentioned public.hap.characteristic.rotation.speed utilizes 0-100% speed ranges.

town3r commented 3 years ago

Current State

Control

Status

nVuln commented 3 years ago

Here's a google sheet of the debug logs I collected. https://docs.google.com/spreadsheets/d/1caTTNeVThx1eECmGAoeDQmCvdGi4DuJb1o1kEuuqBdM/edit?usp=sharing

I think you're right.

Found this which shows no idle option 😢 Turning the device Off and On changes : airState.operation: from 0 to 1

"airState.operation": {
 "data_type": "enum",
 "default": "0",
 "value_mapping": {
   "0": "@operation_off",
   "1": "@operation_on"

Think it would be possible to utilize the values of airState.humidity.current:60, & airState.humidity.desired:75, to set the HomeKit status as Idle

If airState.humidity.current is less than airState.humidity.desired set public.hap.characteristic.humidifier-dehumidifier.state.current to 1 ”Idle”?

Also found that the airState.miscFuncState.watertankLight:, value doesn't seem to change when the water tank is full / empty. Even tho the app sends a notification and the bucket full light turns on when full. Nothing changed in the debug log.

For the fan speed found: "airState.windStrength":2, = Low "airState.windStrength":6, = High But as you mentioned public.hap.characteristic.rotation.speed utilizes 0-100% speed ranges.

I already request access to your drive, my email is ndh**@l***.com, for fan speed, I'll set it 3 state map to speed: 0 = AUTO, 1 = LOW, 2 = HIGH, but in homekit it may not showing AUTO, LOW, HIGH label (just scroll speed with 3 speed level: 0, 1, 2)

town3r commented 3 years ago

Done!

nVuln commented 3 years ago

can you look into airState.opMode ? normally opMode = 17, maybe it will change

   "airState.opMode": {
      "data_type": "enum",
      "default": "0",
      "value_mapping": {
        "0": "@AC_MAIN_OPERATION_MODE_COOL_W",
        "1": "@AC_MAIN_OPERATION_MODE_DRY_W",
        "2": "@AC_MAIN_OPERATION_MODE_FAN_W",
        "3": "@AC_MAIN_OPERATION_MODE_AI_W",
        "4": "@AC_MAIN_OPERATION_MODE_HEAT_W",
        "5": "@AC_MAIN_OPERATION_MODE_AIRCLEAN_W",
        "6": "@AC_MAIN_OPERATION_MODE_ACO_W",
        "7": "@AC_MAIN_OPERATION_MODE_AROMA_W",
        "8": "@AC_MAIN_OPERATION_MODE_ENERGY_SAVING_W",
        "9": "@AP_MAIN_MID_OPMODE_CLEAN_W",
        "10": "@AP_MAIN_MID_OPMODE_SLEEP_W",
        "11": "@AP_MAIN_MID_OPMODE_SILENT_W",
        "12": "@AP_MAIN_MID_OPMODE_HUMIDITY_W",
        "13": "@AP_MAIN_MID_OPMODE_CIRCULATOR_CLEAN_W",
        "14": "@AP_MAIN_MID_OPMODE_BABY_CARE_W",
        "15": "@AP_MAIN_MID_OPMODE_DUAL_CLEAN_W",
        "16": "@AP_MAIN_MID_OPMODE_AUTO_W",
        "17": "@AP_MAIN_MID_OPMODE_SMART_DEHUM_W",
        "18": "@AP_MAIN_MID_OPMODE_FAST_DEHUM_W",
        "19": "@AP_MAIN_MID_OPMODE_CILENT_DEHUM_W",
        "20": "@AP_MAIN_MID_OPMODE_CONCENTRATION_DRY_W",
        "21": "@AP_MAIN_MID_OPMODE_CLOTHING_DRY_W",
        "22": "@AP_MAIN_MID_OPMODE_IONIZER_W"
      },
      "label": "운전 모드"
    }
nVuln commented 3 years ago

in v0.2.2-test.2 , I'll write debug log when opMode not equal 17, please update and check it

town3r commented 3 years ago

Updated the google sheet. Columns 1-3 are new debug logs in the different states. Idle (not running, no fan, is silent, app icon doesn't show water droplets) Smart status message On (running, fan is on, not silent, app icon show water droplets), Smart status message Off (not running, fan off, silent.) Operation Off status message

The app itself doesn't let me change the opMode from what I've found so far. It remains set as 17 "Smart Mode" even when I turn the machine off via the LG app.

How does your plugin actually pull the status & control the device?

Does the device have it's own API that you're able to call? Similar to my TV (http://192.168.1.6:8001/api/v2/) or is it all in the cloud via an LG Thinq server?

I'm guessing in the cloud.

I have a feeling it has something to do with the increased network traffic to aic-service.lgthinq.com I've been seeing in PiHole.

nVuln commented 3 years ago

yup, cloud only (not sure dehumidifier has own api) I think you can use proxyman app to debug LG app, you can see all traffic

town3r commented 3 years ago

Hmm even proxyman seems to pull basically the same exact stuff as your debug logs.

I was curious, did you get lucky enough to be accepted as a partner?

nVuln commented 3 years ago

nop, LG only accept partnership as business, I try before but no luck

cknowles commented 3 years ago

Have a MD16GQSA1 dehumidifier available for testing. Let me know if/how I could help. I installed v0.2.2-test.10 and so far the status and settings for humidity target % plus current are working.

Logs show this repeatedly:

[homebridge-lg-thinq] This plugin generated a warning from the characteristic 'Current Humidifier-Dehumidifier State': characteristic value 1 is not contained in valid values array. See https://git.io/JtMGR for more info.

Other functions available in the LG app for this model which I could gain data on if needed:

town3r commented 3 years ago

😮 I wish the US had that model.

nVuln commented 3 years ago

Have a MD16GQSA1 dehumidifier available for testing. Let me know if/how I could help. I installed v0.2.2-test.10 and so far the status and settings for humidity target % plus current are working.

Logs show this repeatedly:

[homebridge-lg-thinq] This plugin generated a warning from the characteristic 'Current Humidifier-Dehumidifier State': characteristic value 1 is not contained in valid values array. See https://git.io/JtMGR for more info.

Other functions available in the LG app for this model which I could gain data on if needed:

  • Mode (smart, jet, silent, spot, laundry)
  • Speed (high, low)
  • Ionizer (on, off)
  • Schedule

yup, please install latest verison and turn on homebridge debug mode you can see your device data, please upload here

@town3r I already added speed control via home app, did you try it ?

cknowles commented 3 years ago

@nVuln here is my device data - https://gist.github.com/cknowles/7567a8e4553199e9b636d86ddb81ab33. Obfuscated a little as don't know the sec model for this.

town3r commented 3 years ago

Not seeing the speed control after updating and removing cached device.

lukebelz commented 2 years ago

Been looking for 7 hours now for a dehumidifier we can buy in the US that has any way of connecting to homekit. This is basically it. The only official homekit one is impossible to find in the US, the Xiaomi ones that have homebridge support are impossible to get in the US, the one where the guy created his own replacement mother board is impossible to find in the US, so I started looking at wifi dehumidifiers with a protocol shared amongst it's smart device lineup, and found LG's smartthinq.

Basically, THIS IS IT! You have the best, most working solution that doesn't require me to spend the time learning to write homebridge applications. So great work guys, you've come along way.

Now, that being said, it'd be great to see this get finished and for us to have a 100% working homekit dehumidifier option in the US.

Let me know if there's anything I can do to help. I'm ordering one right now. Thank you so much for all of this work. I promise you there will be thousands of people using this once it's completed.

town3r commented 2 years ago

What model did you end up getting?

Sadly the model I have just doesn't give the status of different things like if the tank is full or if it's actually on and running or it's just the fan or off waiting for it to get humid.

nVuln commented 2 years ago

What model did you end up getting?

Sadly the model I have just doesn't give the status of different things like if the tank is full or if it's actually on and running or it's just the fan or off waiting for it to get humid.

please install version v1.2.0-test.6 I added light bulb to showing airState.miscFuncState.watertankLight state, let try if it's changed over time DehumidifierState changed to IDLE when airState.humidity.current is less than airState.humidity.desired, check if it's worked

town3r commented 2 years ago

Tank is currently full and the light on the machine is on.

Current Debug logs from machine in state above:

"deviceType":403 "modelName":"DHUM_056905_WW" "subModelNm":null "sensorType":null "alias":"Dehumidifier" "deviceCode":"AI02" "networkType":"02" "tftYn":"N" "guideTypeYn":"Y" "guideType":"DHUM_TYPE1" "pccModelYn":"N" "autoOrderYn":"N" "drServiceYn":"N" "ssid":"Skynet" "timezoneCode":"America/Chicago" "timezoneCodeAlias":"USA/Chicago" "sdsGuide":"{\"deviceCode\":\"AI02\"}" "newRegYn":"N" "remoteControlType":"" "fareTarget":null "area":"331530" "sleep":null "deviceState":"E" "rmsClientId":null "regDtUtc":"20200810203648000" "regIndex":0 "blackboxYn":"Y" "groupableYn":"N" "controllableYn":"N" "combinedProductYn":"N" "masterYn":"Y" "snapshot":{"airState.windStrength":2 "airState.diagCode":0 "mid":286759479 "airState.miscFuncState.watertankLight":1 "airState.quality.sensorMon":1 "airState.humidity.current":65 "airState.operation":1 "airState.reservation.absoluteStopTime":0 "airState.wMode.humidification":0 "airState.humidity.desired":60 "timestamp":1630497188752 "airState.notification":256 "static":{"deviceType":"403" "countryCode":"US"} "airState.tempState.current":-20 "airState.miscFuncState.extraOp":0 "airState.miscFuncState.airRemoval":0 "airState.filterMngStates.desorption":0 "airState.reservation.absoluteStartTime":0 "airState.reservation.targetTimeToStart":0 "meta":{"allDeviceInfoUpdate":false "messageId":"uMIt01K0Q7mc2jr_ADsQ3g"} "online":true "airState.opMode":17 "airState.reservation.targetTimeToStop":0 "airState.notificationExt":1} "manufacture":null "online":true "platformType":"thinq2"

town3r commented 2 years ago

Empty Tank - Light off

"deviceType":403 "modelName":"DHUM_056905_WW" "subModelNm":null "sensorType":null "alias":"Dehumidifier" "deviceCode":"AI02" "networkType":"02" "tftYn":"N" "guideTypeYn":"Y" "guideType":"DHUM_TYPE1" "pccModelYn":"N" "autoOrderYn":"N" "drServiceYn":"N" "ssid":"Skynet" "timezoneCode":"America/Chicago" "timezoneCodeAlias":"USA/Chicago" "sdsGuide":"{\"deviceCode\":\"AI02\"}" "newRegYn":"N" "remoteControlType":"" "fareTarget":null "area":"331530" "sleep":null "deviceState":"E" "rmsClientId":null "regDtUtc":"20200810203648000" "regIndex":0 "blackboxYn":"Y" "groupableYn":"N" "controllableYn":"N" "combinedProductYn":"N" "masterYn":"Y" "snapshot":{"airState.windStrength":2 "airState.diagCode":0 "mid":289982786 "airState.miscFuncState.watertankLight":1 "airState.quality.sensorMon":1 "airState.humidity.current":60 "airState.operation":1 "airState.reservation.absoluteStopTime":0 "airState.wMode.humidification":0 "airState.humidity.desired":60 "timestamp":1630500336350 "airState.notification":256 "static":{"deviceType":"403" "countryCode":"US"} "airState.tempState.current":-17 "airState.miscFuncState.extraOp":0 "airState.miscFuncState.airRemoval":0 "airState.filterMngStates.desorption":0 "airState.reservation.absoluteStartTime":0 "airState.reservation.targetTimeToStart":0 "meta":{"allDeviceInfoUpdate":false "messageId":"4wCBnQOZSJyIGTzhVeVJ3w"} "online":true "airState.opMode":17 "airState.reservation.targetTimeToStop":0 "airState.notificationExt":0} "manufacture":null "online":true "platformType":"thinq2"

town3r commented 2 years ago

Unfortunately, the "airState.miscFuncState.watertankLight":1 doesn't change to match the current state of the hardware.

The app sends an alert similar to when the washer or dryer are done.

image

town3r commented 2 years ago

Also unfortunately the device icon in the LG app doesn't update with current tank state either.

image