0x5e / homebridge-tuya-platform

Make homebridge-tuya-platform great again.
MIT License
222 stars 67 forks source link

Help with support for adding Kogan Portable Air Conditioner #201

Open Sparoney opened 1 year ago

Sparoney commented 1 year ago

Hi, I recently I got this Portable Air Conditioner from Kogan.

In HomeBridge, I get a message saying I am missing the schema for mode and work_status.

[08/01/2023, 14:41:44] [TuyaPlatform] [Portable Air Conditioner] Missing one of the required schema: [ 'mode' ]
[08/01/2023, 14:41:44] [TuyaPlatform] [Portable Air Conditioner] Please switch device control mode to "DP Insctrution", and set `deviceOverrides` manually.
[08/01/2023, 14:41:44] [TuyaPlatform] [Portable Air Conditioner] Detail information: https://github.com/0x5e/homebridge-tuya-platform#faq
[08/01/2023, 14:41:44] [TuyaPlatform] [Portable Air Conditioner] Missing one of the required schema: [ 'work_status', 'mode' ]
[08/01/2023, 14:41:44] [TuyaPlatform] [Portable Air Conditioner] Please switch device control mode to "DP Insctrution", and set `deviceOverrides` manually.
[08/01/2023, 14:41:44] [TuyaPlatform] [Portable Air Conditioner] Detail information: https://github.com/0x5e/homebridge-tuya-platform#faq

So I went to the Tuya website and set it from Standard Instruction to DP Instruction. These are the available options it gives me:

With DP Instruction mode selected

DP Instruction Standard Instruction
Power Power
temp_set temp_set
temp_current temp_current
mode mode
windspeed windspeed
C_F C_F
Timer Timer
coutdown coutdown
Alarm Alarm
SLEEP SLEEP

With Standard Instruction mode selected

DP Instruction Standard Instruction
Power switch
temp_set temp_set
temp_current temp_current
mode -
windspeed windspeed
C_F -
Timer -
coutdown -
Alarm -
SLEEP -

I added mode to my schema override but there is no option for "work_status".

Here is the device info from MQTT/Logs:

{
    "active_time": 1673064933,
    "biz_type": 18,
    "category": "kt",
    "create_time": 1673064933,
    "icon": "smart/icon/ay15253387844269Sg99/d5401b2b8f67cffe2a26530c926f4876.png",
    "id": "71770814483fda388a71",
    "ip": "",
    "lat": "",
    "local_key": "",
    "lon": "",
    "model": "KAWFPAC09YA",
    "name": "Portable Air Conditioner",
    "online": true,
    "owner_id": "",
    "product_id": "mhod7aykax0wbivn",
    "product_name": "Kogan Smarter Home™ 2.6kW Portable Air Conditioner",
    "status": [
      {
        "code": "switch",
        "value": false
      },
      {
        "code": "temp_current",
        "value": 25
      },
      {
        "code": "temp_set",
        "value": 24
      },
      {
        "code": "windspeed",
        "value": "1"
      }
    ],
    "sub": false,
    "time_zone": "+10:00",
    "uid": "",
    "update_time": 1673102913,
    "uuid": "71770814483fda388a71",
    "schema": [
      {
        "code": "switch",
        "mode": "rw",
        "type": "Boolean",
        "property": {}
      },
      {
        "code": "temp_current",
        "mode": "ro",
        "type": "Integer",
        "property": {
          "unit": "℃ ℉",
          "min": -7,
          "max": 98,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "temp_set",
        "mode": "rw",
        "type": "Integer",
        "property": {
          "unit": "℃ ℉",
          "min": 16,
          "max": 86,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "windspeed",
        "mode": "rw",
        "type": "Enum",
        "property": {
          "range": [
            "1",
            "2"
          ]
        }
      }
    ]
  }

Using Debug in Homebridge I noticed that when changing between the three modes (Dry, Cool, and Fan) it sends this:

[08/01/2023, 14:44:05] [TuyaPlatform] [TuyaOpenMQ] onMessage:
topic = cloud/token/in/83c3ca57652a51a0b0cd48b937c0917c
protocol = 4
message = {
  "dataId": "c96f450c-1def-4b9c-a539-08a6ad81c93c",
  "devId": "71770814483fda388a71",
  "productKey": "mhod7aykax0wbivn",
  "status": [
    {
      "4": "FAN"
    }
  ]
}
t = 1673149444
[08/01/2023, 14:44:15] [TuyaPlatform] [TuyaOpenMQ] onMessage:
topic = cloud/token/in/83c3ca57652a51a0b0cd48b937c0917c
protocol = 4
message = {
  "dataId": "36ce2748-4a56-4f19-b87b-3c080ab0c5ca",
  "devId": "71770814483fda388a71",
  "productKey": "mhod7aykax0wbivn",
  "status": [
    {
      "105": 117
    }
  ]
}
t = 1673149453
[08/01/2023, 14:44:17] [TuyaPlatform] [TuyaOpenMQ] onMessage:
topic = cloud/token/in/83c3ca57652a51a0b0cd48b937c0917c
protocol = 4
message = {
  "dataId": "e22747a7-ed29-4cca-b265-fbb36473d089",
  "devId": "71770814483fda388a71",
  "productKey": "mhod7aykax0wbivn",
  "status": [
    {
      "4": "DRY"
    }
  ]
}
t = 1673149456
[08/01/2023, 14:44:27] [TuyaPlatform] [TuyaOpenMQ] onMessage:
topic = cloud/token/in/83c3ca57652a51a0b0cd48b937c0917c
protocol = 4
message = {
  "dataId": "ca05df45-fa25-4901-af04-7f552bf2d892",
  "devId": "71770814483fda388a71",
  "productKey": "mhod7aykax0wbivn",
  "status": [
    {
      "4": "COOL"
    }
  ]
}
t = 1673149465

And here is my override schema I created (hoping it is correct!):

"deviceOverrides": [
                    {
                        "id": "71770814483fda388a71",
                        "schema": [
                            {
                                "oldCode": "switch",
                                "code": "Power",
                                "type": "Boolean"
                            },
                            {
                                "oldCode": "SLEEP",
                                "code": "SLEEP",
                                "type": "Boolean",
                                "property": {
                                    "range": [
                                        "true",
                                        "false"
                                    ]
                                }
                            },
                            {
                                "oldCode": "temp_current",
                                "code": "temp_current",
                                "type": "Integer",
                                "property": {
                                    "min": -5,
                                    "max": 50,
                                    "scale": 0,
                                    "step": 1
                                }
                            },
                            {
                                "oldCode": "temp_set",
                                "code": "temp_set",
                                "type": "Integer",
                                "property": {
                                    "min": 16,
                                    "max": 30,
                                    "scale": 0,
                                    "step": 1
                                }
                            },
                            {
                                "oldCode": "windspeed",
                                "code": "windspeed",
                                "type": "Enum",
                                "property": {
                                    "range": [
                                        "1",
                                        "2"
                                    ]
                                }
                            },
                            {
                                "oldCode": "mode",
                                "code": "mode",
                                "type": "Enum",
                                "property": {
                                    "range": [
                                        "COOL",
                                        "FAN",
                                        "DRY"
                                    ]
                                }
                            }
                        ]
                    }
                ]

I had also set work_status to be the same as mode but that didn't work. I still get the message that both mode and work_status are missing from the schema.

Was wondering if you could assist in how I can fix this? Or is this something that needs to be changed in the plugin? I'm unsure if there's a way in the Tuya API to get all the DP instruction modes and their values.

Thanks!

0x5e commented 1 year ago

there's no need to add all schema into the config, just keep those you want to modify. mode is the fallback of work_status, its okay without it. Can you describe how it didn't work?

Sparoney commented 1 year ago

I added the other schema in the config as I wanted to change the temperature min/max values as I only use celsius.

The issue I'm having is that after making the custom schema it still says that mode is missing from the schema. The aircon also doesn't appear in the list of HomeBridge Accessories and in HomeKit it says Not Supported.

I am wondering if my custom schema might just be getting ignored, as it seems like it should work?

0x5e commented 1 year ago

after switch to dp mode, did you restart the homebridge? from your device info json, there's still missing mode.

Sparoney commented 1 year ago

Yeah I was restarting it everytime I changed the config but it appears to be working now, its properly registering as DP mode and after overriding Power to switch.

Now I have two new issues: [09/01/2023, 01:27:10] [TuyaPlatform] [Portable Air Conditioner] Invalid mode range for TargetHeaterCoolerState: [ 'COOL', 'FAN', 'DRY' ] but I can ignore this as it still works.

In the HomeKit app or on the HomeBridge Accessories page, after turning on the air conditioner, about two seconds later it'll appear as offline and just display the current room temprature. (Could this be because I had to change Power DP to switch?)

The fan modes in HomeKit also show as "OFF, COOL, HEAT, AUTO" instead of "COOL, DRY, FAN". Are these modes able to be changed or is that a limitation by the HomeKit app? My Air Conditioner is for cooling only, it doesn't do heating as well.

Thanks!!

0x5e commented 1 year ago

Please post your original mode schema. your config of these part:

{
                                "oldCode": "mode",
                                "code": "mode",
                                "type": "Enum",
                                "property": {
                                    "range": [
                                        "COOL",
                                        "FAN",
                                        "DRY"
                                    ]
                                }
                            }

is useless and invalid. Here you can find the AC schema definition: https://developer.tuya.com/cn/docs/iot/f?id=K9gf46qujdmwb

Everytime you editing deviceOverrides, better clean the accessory cache. If a AC have cooling only, fan and dehumidifier won't appear then.

Sparoney commented 1 year ago

The original mode schema is the exact same.

      {
        "code": "mode",
        "mode": "rw",
        "type": "Enum",
        "property": {
          "range": [
            "COOL",
            "FAN",
            "DRY"
          ]
        }
      },

Which is invalid.

I have overridden it to:

                            {
                                "oldCode": "mode",
                                "code": "mode",
                                "type": "Enum",
                                "property": {
                                    "range": [
                                        "cold",
                                        "wind",
                                        "wet"
                                    ]
                                }
                            }

After clearing cashe and restarting this then shows no mode options in HomeKit and shows 2 power buttons and a slider (for fan speed) with a power button in it.

Sparoney commented 1 year ago

The AC has cooling, fan, and dehumidifer modes (COOL, FAN, DRY)

K0rayy commented 1 year ago

@Sparoney hello,

Can you please help me how to change device code on Tuya. I can not find any detailed information on google.

Edit: I changed device type as "DP instruction" from Tuya Iot platform. But I can not find how to change the code.

Thank you!!