Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Reorder the mapping / support Model: MS-Q12SWDZ #70

Open
bluefangs opened this issue Apr 16, 2021 · 17 comments
Open

Reorder the mapping / support Model: MS-Q12SWDZ #70

bluefangs opened this issue Apr 16, 2021 · 17 comments
Labels
enhancement New feature or request

Comments

@bluefangs
Copy link

bluefangs commented Apr 16, 2021

LG Air Conditioner Model
MS-Q12SWDZ

Homekit Model number
RAC_056905_WW

  1. This model has a HC option (high cooling, where in it tries to max out the cooling for a short period to bring down the temps rapidly). In the thinq app, it's called as Jet mode. There is a toggle button for the same. Is there any way to map this?
    Say for example, Cool it to < 18 degree Celsius with max fan should toggle this mode. Is something like this possible?

  2. Similar to TargetHeaterCoolerStateCharacteristic: Error parsing state Error: Unsupported API value: 4 #22, Homebridge error log #27, Is it possible to redo the mapping? Current mapping is as follows -

Homekit Mode Thinq Mode TargetHeaterCoolerStateCharacteristic Proposed Homekit mode
Cool cool 0 Cool
-- Dry 1 Heat
Auto Fan 2 None, a toggle perhaps?
-- Auto 3 Auto
@sman591 sman591 added new model New model to implement enhancement New feature or request labels Apr 16, 2021
@sman591
Copy link
Owner

sman591 commented Apr 16, 2021

Nice! Should be doable

@bluefangs
Copy link
Author

bluefangs commented Apr 17, 2021

Update - For my testing alone, I have modified the getStateFromApiValue method. But I feel that if something like this needs to be incorporated in the main branch, we will need to expose settings to the user where he can configure what mode is what. Or else Heat/DRY will have conflicts. It's rather very unfortunate that the API only exposes the internal model number and nothing else :(

  1. I've for now eleminated the fan mode. (Is there a way to make it appear as a switch like Oscillate?, If so, where do I do that?)
  2. Auto in ThinQ is Auto in HomeKit
  3. Dry in ThinQ is Heat in HomeKit
type ApiValue = 0 | 1 | 2 | 3 | 4
...
...
...
 getStateFromApiValue(apiValue: ApiValue): State {
    if (this.deviceSupportsHeat) {

      this.logError("getStateFromApiValue: " + "getStateFromApiValue" + "\n" + 
        "this.deviceSupportsHeat: " + this.deviceSupportsHeat + "\n" + 
        "apiValue: " + apiValue
       )
      switch (apiValue) {
        case 0:
          return this.characteristic.COOL
          // for LG MS-Q12SWDZ represented as RAC_056905_WW,
          // DRY MODE in ThinQ will be represented as HEAT in HomeKit
        case 1: 
        case 4:
          this.logError("Case 4, HEAT")
          return this.characteristic.HEAT
        // case 2:
        //   this.logError("Case 2, AUTO")
        //   return this.characteristic.AUTO

        // for LG MS-Q12SWDZ represented as RAC_056905_WW,
        // AUTO MODE in ThinQ will be represented as AUTO in HomeKit
        case 3:
          return this.characteristic.AUTO
        default:
          throw new Error('Unsupported API value: ' + JSON.stringify(apiValue))
      }
    } else {
      ...
     ...
    }
  }


getStateFromApiValue(apiValue: ApiValue): State {
    if (this.deviceSupportsHeat) {

      this.logError("getStateFromApiValue: " + "getStateFromApiValue" + "\n" + 
        "this.deviceSupportsHeat: " + this.deviceSupportsHeat + "\n" + 
        "apiValue: " + apiValue
       )
      switch (apiValue) {
        case 0:
          return this.characteristic.COOL
          // for LG MS-Q12SWDZ represented as RAC_056905_WW,
          // DRY MODE in ThinQ will be represented as HEAT in HomeKit
        case 1: 
        case 4:
          this.logError("Case 4, HEAT")
          return this.characteristic.HEAT
        // case 2:
        //   this.logError("Case 2, AUTO")
        //   return this.characteristic.AUTO

        // for LG MS-Q12SWDZ represented as RAC_056905_WW,
        // AUTO MODE in ThinQ will be represented as AUTO in HomeKit
        case 3:
          return this.characteristic.AUTO
        default:
          throw new Error('Unsupported API value: ' + JSON.stringify(apiValue))
      }
    } else {
      ...
      ...
  }

@bluefangs
Copy link
Author

bluefangs commented Apr 17, 2021

Also, Filter Change Indicator: Chance Soon is being indicated in the HomeKit app. What governs this property? I believe it is incorrect for this model since only 14h is being used out of 700+ hours

How can I make use of :

     'airState.filterMngStates.maxTime': number
      'airState.filterMngStates.useTime': number

@sman591
Copy link
Owner

sman591 commented Apr 20, 2021

Also, Filter Change Indicator: Chance Soon is being indicated in the HomeKit app. What governs this property? I believe it is incorrect for this model since only 14h is being used out of 700+ hours

Did you pull a copy of #40 for this? The filter status is not supported by this plugin yet, it was tentatively introduced in #40

@sman591
Copy link
Owner

sman591 commented Apr 20, 2021

Added official filter support now, please upgrade to the latest version of the plugin

@sman591
Copy link
Owner

sman591 commented Apr 20, 2021

Jet

For "Jet" mode, do you think it would make sense to replace "heat" with "jet" instead of "dry"?

The HomeKit controls here are unfortunately extremely limited. Another option could be exposing a separate "switch" accessory that toggles the "jet" mode on by itself.

I'm hesitant to say we should "drop to X degrees and auto-enable Jet"... maybe that makes sense? Does Jet let you set a temperature when enabled, or is it a mode-only mode?

@sman591
Copy link
Owner

sman591 commented Apr 20, 2021

Mapping

Could you clarify what your desire would be?

Based on RAC_056905_WW right now, this should be what is happening:

  • HomeKit: Cool, ThinQ: Cool
  • HomeKit: Heat, ThinQ: Heat
  • HomeKit: Auto, ThinQ: Fan

(if that's not currently happening, please let me know because that is a bug)

It should be reasonable to expose toggles for this, though -- e.g. override options of:

  • (use plugin defaults)
  • Heat: Dry, Auto: Fan
  • Heat: Dry, Auto: Auto
  • Heat: Fan, Auto: Auto

@sman591 sman591 removed the new model New model to implement label Apr 20, 2021
@bluefangs
Copy link
Author

bluefangs commented Apr 20, 2021

Also, Filter Change Indicator: Chance Soon is being indicated in the HomeKit app. What governs this property? I believe it is incorrect for this model since only 14h is being used out of 700+ hours

Did you pull a copy of #40 for this? The filter status is not supported by this plugin yet, it was tentatively introduced in #40

Hmm... I was experementing with just the dist/ dir from both the versions.

Added official filter support now, please upgrade to the latest version of the plugin

I shall install the latest version and test run it today evening when I get home. (~5h from now)

Jet

For "Jet" mode, do you think it would make sense to replace "heat" with "jet" instead of "dry"?

The HomeKit controls here are unfortunately extremely limited. Another option could be exposing a separate "switch" accessory that toggles the "jet" mode on by itself.

I completely agree with homekit limitations :( sadly we cannot have TV input like mechanism and we're only left to deal with cool, heat and auto.

I'm hesitant to say we should "drop to X degrees and auto-enable Jet"... maybe that makes sense? Does Jet let you set a temperature when enabled, or is it a mode-only mode?

I skimmed thorugh the user manual earlier this week. Basically jet mode sets the temp to 18C, sets fan to high, disables energy saver functionality, and enables virtical swing. It maintains this for about 30 mins and then switches to cool. Jet will not allow you to set a temperature, (neight will dry or fan more) I will confirm this in a few hours time.

Update
HC feature (on the remote) / Jet mode (in the thinq app):

Screenshot from 2021-04-20 14-02-35

It does make sense to have it separate as a switch. However, there are a couple of questions --

  1. WIll the switch be as a separate accessory? Or will it be found inside the AC accessory (long press)
  2. If the switch is an external accessory, when the switch is "on", what will the AC accssory indicate?

Can we have a toggle inside the AC accessory itself for jet, similir to how "Oscillate" is exposed as a switch?

Mapping

Could you clarify what your desire would be?

Based on RAC_056905_WW right now, this should be what is happening:

  • HomeKit: Cool, ThinQ: Cool
  • HomeKit: Heat, ThinQ: Heat
  • HomeKit: Auto, ThinQ: Fan

(if that's not currently happening, please let me know because that is a bug)

This behaviour is correct. This is what was happening when I installed the plugin as-is. Except the temprature slider in Auto(fan) and Heat(dry) mode used to behave oddly. As in both from and to used to be at 18C or 20C at times. I think this beause you cannot set a temprature for these modes in thinq. However, for my personal use, I just modified Hk.AUTO -> TQ.AUTO, HK.COOL -> TQ.COOl and HK.Heat -> TQ.Dry/ (Monsoon is what it's called in this model). I removed the fan mode as I feel that it will be seldom used. Again, this is just for me.

It should be reasonable to expose toggles for this, though -- e.g. override options of:

  • (use plugin defaults)
  • Heat: Dry, Auto: Fan
  • Heat: Dry, Auto: Auto
  • Heat: Fan, Auto: Auto

This would cater to what I'm doing, but supported by the plugin you've built directly.

@bluefangs
Copy link
Author

Updated to the latest version.

For the filter, I see this in the logs:

[4/20/2021, 9:44:06 PM] [homebridge-lg-thinq-ac] This plugin generated a warning from the characteristic 'Filter Life Level': characteristic value expected valid finite number and received "NaN" (number). See https://git.io/JtMGR for more info.
[4/20/2021, 9:44:13 PM] [homebridge-lg-thinq-ac] This plugin generated a warning from the characteristic 'Filter Life Level': characteristic value expected valid finite number and received "NaN" (number). See https://git.io/JtMGR for more info.

HK shows:
Filter Condition: Change Soon
FIlter Life: 0

@sman591
Copy link
Owner

sman591 commented Apr 22, 2021

Ahhh thanks for flagging this, it sounds like your unit has slightly different data for its filter.

Thanks for the other info -- I'll dig into some options and let you know.

In the meantime, could you provide a copy of the snapshot for your device when this happens?

  1. Turn on "debug" mode for Homebridge (start Homebridge with -D or in the Homebridge UI, go to "Homebridge Settings" and turn on "Homebridge Debug Mode")
  2. Restart Homebridge
  3. Follow the logs and wait for ~60 seconds
  4. Find the line that starts with device response.result.snapshot and copy & paste its contents

@bluefangs
Copy link
Author

Please let me know if this is helpful.
Strange that the response has numeric 0 for both airState.filterMngStates.maxTime and airState.filterMngStates.useTime
The filter mgmt in the thinq app seem to report correctly.

IMG_1686

[4/22/2021, 10:58:02 PM] [LgThinqAirConditioner] device response.result.snapshot {
  'airState.windStrength': 2,
  'airState.wMode.lowHeating': 0,
  'airState.diagCode': 0,
  'airState.lightingState.displayControl': 1,
  'airState.wDir.hStep': 3,
  mid: 26988582,
  'airState.energy.onCurrent': 50,
  'airState.wMode.airClean': 0,
  'airState.quality.sensorMon': 0,
  'airState.miscFuncState.antiBugs': 0,
  'airState.tempState.target': 25,
  'airState.operation': 0,
  'airState.wMode.jet': 0,
  'airState.wDir.vStep': 100,
  timestamp: 1619112391741,
  'airState.powerSave.basic': 0,
  'airState.quality.PM10': 0,
  static: { deviceType: '401', countryCode: 'IN' },
  'airState.quality.overall': 0,
  'airState.tempState.current': 27,
  'airState.miscFuncState.extraOp': 0,
  'airState.reservation.sleepTime': 0,
  'airState.miscFuncState.autoDry': 0,
  'airState.reservation.targetTimeToStart': 0,
  meta: { allDeviceInfoUpdate: false, messageId: 'wbg8yXgWSRiShOvzRaSHIw' },
  'airState.quality.PM1': 0,
  'airState.wMode.smartCare': 0,
  'airState.quality.PM2': 0,
  online: true,
  'airState.opMode': 0,
  'airState.reservation.targetTimeToStop': 0,
  'airState.filterMngStates.maxTime': 0,
  'airState.filterMngStates.useTime': 0
}
[4/22/2021, 10:58:02 PM] [LgThinqAirConditioner] ActiveCharacteristic: handleUpdatedSnapshot 0
[4/22/2021, 10:58:02 PM] [LgThinqAirConditioner] SwingModeCharacteristic: handleUpdatedSnapshot 100
[4/22/2021, 10:58:02 PM] [LgThinqAirConditioner] RotationSpeedCharacteristic: handleUpdatedSnapshot 2
[4/22/2021, 10:58:02 PM] [LgThinqAirConditioner] CoolingThresholdCharacteristic: handleUpdatedSnapshot 25
[4/22/2021, 10:58:02 PM] [LgThinqAirConditioner] HeatingThresholdCharacteristic: Target state is not "heat", ignoring snapshot update
[4/22/2021, 10:58:02 PM] [LgThinqAirConditioner] HeatingThresholdCharacteristic: handleUpdatedSnapshot 25
[4/22/2021, 10:58:02 PM] [LgThinqAirConditioner] TargetHeaterCoolerStateCharacteristic: handleUpdatedSnapshot 0
[4/22/2021, 10:58:02 PM] [LgThinqAirConditioner] CurrentHeaterCoolerStateCharacteristic: handleUpdatedSnapshot 0
[4/22/2021, 10:58:02 PM] [LgThinqAirConditioner] CurrentTemperatureCharacteristic: handleUpdatedSnapshot 27
[4/22/2021, 10:58:02 PM] [LgThinqAirConditioner] FilterChangeCharacteristic: handleUpdatedSnapshot true
[4/22/2021, 10:58:02 PM] [LgThinqAirConditioner] FilterLifeCharacteristic: handleUpdatedSnapshot NaN
[4/22/2021, 10:58:02 PM] [LgThinqAirConditioner] FilterLifeCharacteristic: apiValue:  NaN number
[4/22/2021, 10:58:02 PM] [homebridge-lg-thinq-ac] This plugin generated a warning from the characteristic 'Filter Life Level': characteristic value expected valid finite number and received "NaN" (number). See https://git.io/JtMGR for more info.
[4/22/2021, 10:58:02 PM] [homebridge-lg-thinq-ac] Error: 
    at FilterLifeLevel.Characteristic.characteristicWarning (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2038:105)
    at FilterLifeLevel.Characteristic.validateUserInput (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1931:16)
    at FilterLifeLevel.Characteristic.updateValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1379:20)
    at HeaterCooler.Service.updateCharacteristic (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Service.ts:465:35)
    at FilterLifeCharacteristic.handleUpdatedSnapshot (/homebridge/node_modules/homebridge-lg-thinq-ac/src/characteristic/abstractCharacteristic.ts:71:20)
    at FilterLifeCharacteristic.handleUpdatedSnapshot (/homebridge/node_modules/homebridge-lg-thinq-ac/src/characteristic/filterLifeCharacteristic.ts:39:11)
    at LgAirConditionerPlatformAccessory.updateCharacteristics (/homebridge/node_modules/homebridge-lg-thinq-ac/src/platformAccessory.ts:114:26)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    ```

@sman591
Copy link
Owner

sman591 commented Apr 23, 2021

Huh that's very strange indeed. Maybe the LG app is caching something, or calling a different API? Are you familiar with debugging the APIs an app calls?

Otherwise I can just try to safely handle the case where it is 0 / 0

@bluefangs
Copy link
Author

I'm not familiar with debugging the API calls, but if you could guide me or if there is some documentation that I can read up on, I should be able to do something about it. You could handle the case, but I'm curious why 0 is being interpreted as NaN

@sman591
Copy link
Owner

sman591 commented Apr 23, 2021

0 is likely causing NaN because 0 / 0 results in NaN for JavaScript

I've used Charles Proxy on Mac before, though most "mitm" (man in the middle) proxy solutions should do the trick (take care that they're trustworthy, though). This might be useful but I haven't used it before / can't necessarily vouch for it: https://medium.com/testvagrant/intercept-ios-android-network-calls-using-mitmproxy-4d3c94831f62

@bluefangs
Copy link
Author

bluefangs commented Apr 23, 2021

Thanks!

The request is hitting this endpoint: https://kic-service.lgthinq.com:56030/v1/service/devices/<<device_id>>/control-sync
Here is the req / resp for filter mgmt:

Request

{
    "command": "Get",
    "ctrlKey": "filterMngStateCtrl",
    "dataGetList": [
        "airState.filterMngStates.useTime",
        "airState.filterMngStates.maxTime"
    ]
}

Response

    "result": {
        "data": {
            "airState.filterMngStates.changeDate": 0.0,
            "airState.filterMngStates.maxTime": 720.0,
            "airState.filterMngStates.useTime": 55.0
        }
    },
    "resultCode": "0000"
}

@bluefangs
Copy link
Author

I noticed the below logs while looking at another issue. Does this have anything to do with the filter rerpoting 0 issue?

[Bedroom 2 AC@@Filter Change Indication] Characteristic not in required or optional characteristic section for service HeaterCooler. Adding anyway.
[Bedroom 2 AC@@Filter Life Level] Characteristic not in required or optional characteristic section for service HeaterCooler. Adding anyway.

@sman591
Copy link
Owner

sman591 commented Feb 3, 2022

Aha, that's very useful, thank you!

Looks like it is a different API indeed. Let me see if we can add that in

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants