0x5e / homebridge-tuya-platform

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

Fan Reverses when Running Automation #474

Open isaiahfranco opened 3 months ago

isaiahfranco commented 3 months ago

Prerequisite

Cache

Version

v1.7.0-beta.53

Device Infomation JSON File

[
  {
    "active_time": 1719177042,
    "biz_type": 0,
    "category": "fsd",
    "create_time": 1719177042,
    "icon": "smart/icon/bay1600841688777XlLe/9d4aa94081c8708dcb1f3b7627c15482.png",
    "id": "ebd94bb811d9316c6ai4ga",
    "ip": "172.251.196.191",
    "lat": "33.8999",
    "local_key": "WU>~5`xeG:aJQp5N",
    "lon": "-117.2548",
    "model": "",
    "name": "Isaiah Office Fan",
    "online": true,
    "owner_id": "153524645",
    "product_id": "kalvc8dhkwy1aj6b",
    "product_name": "YuHao DC FAN II",
    "status": [
      {
        "code": "bright_value",
        "value": 1000
      },
      {
        "code": "countdown_left_fan",
        "value": 0
      },
      {
        "code": "fan_direction",
        "value": "forward"
      },
      {
        "code": "fan_speed",
        "value": 3
      },
      {
        "code": "fan_switch",
        "value": true
      },
      {
        "code": "switch_led",
        "value": false
      },
      {
        "code": "temp_value",
        "value": 0
      },
      {
        "code": "work_mode",
        "value": "white"
      }
    ],
    "sub": false,
    "time_zone": "-07:00",
    "uid": "az16819676857230dMJY",
    "update_time": 1719218141,
    "uuid": "08b8437b32dea135",
    "schema": [
      {
        "code": "bright_value",
        "mode": "rw",
        "type": "Integer",
        "property": {
          "min": 10,
          "max": 1000,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "countdown_left_fan",
        "mode": "rw",
        "type": "Integer",
        "property": {
          "unit": "min",
          "min": 0,
          "max": 540,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "fan_direction",
        "mode": "rw",
        "type": "Enum",
        "property": {
          "range": [
            "forward",
            "reverse"
          ]
        }
      },
      {
        "code": "fan_speed",
        "mode": "rw",
        "type": "Integer",
        "property": {
          "unit": "",
          "min": 1,
          "max": 6,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "fan_switch",
        "mode": "rw",
        "type": "Boolean",
        "property": {}
      },
      {
        "code": "switch_led",
        "mode": "rw",
        "type": "Boolean",
        "property": {}
      },
      {
        "code": "temp_value",
        "mode": "rw",
        "type": "Integer",
        "property": {
          "min": 0,
          "max": 1000,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "work_mode",
        "mode": "rw",
        "type": "Enum",
        "property": {
          "range": [
            "white",
            "colour",
            "scene",
            "music"
          ]
        }
      }
    ]
  },

Device Control Mode

Standard Instruction

Logs

[6/24/2024, 12:55:59 PM] [Tuya] [TuyaOpenAPI] Request:
method = post
endpoint = https://openapi.tuyaus.com
path = /v1.0/devices/ebd94bb811d9316c6ai4ga/commands
query = null
headers = {
  "t": "1719258959011",
  "client_id": "gsjgr5faxdh7datumsvd",
  "nonce": "449628e8-8d2e-4647-9d68-2aeab943a523",
  "Signature-Headers": "client_id",
  "sign": "EEAD626E8E6FDD15702E1C6662EE1AB67B8131A1E09EB7ABC29A7DF08E7C9CBA",
  "sign_method": "HMAC-SHA256",
  "access_token": "e72cd1e5369fbf5f0641289415778bd3",
  "lang": "en",
  "dev_lang": "javascript",
  "dev_channel": "homebridge",
  "devVersion": "1.7.0-beta.53"
}
body = {
  "commands": [
    {
      "code": "fan_direction",
      "value": "forward"
    }
  ]
}
[6/24/2024, 12:55:59 PM] [Tuya] [TuyaOpenAPI] Response:
path = /v1.0/devices/ebd94bb811d9316c6ai4ga/commands
data = {
  "result": true,
  "success": true,
  "t": 1719258959071,
  "tid": "c6cf3307326311ef9c7442b1fe1466b5"
}
[6/24/2024, 12:55:59 PM] [Tuya] [TuyaOpenAPI] Request:
method = post
endpoint = https://openapi.tuyaus.com
path = /v1.0/devices/ebd94bb811d9316c6ai4ga/commands
query = null
headers = {
  "t": "1719258959111",
  "client_id": "gsjgr5faxdh7datumsvd",
  "nonce": "73ebe1be-f312-4d3d-befb-4f1d22571bf5",
  "Signature-Headers": "client_id",
  "sign": "4EA6EC8B5DBCF390FA110B7BAAF6F3A1F523C6B02B66E81E9FB9AD032C8645C9",
  "sign_method": "HMAC-SHA256",
  "access_token": "e72cd1e5369fbf5f0641289415778bd3",
  "lang": "en",
  "dev_lang": "javascript",
  "dev_channel": "homebridge",
  "devVersion": "1.7.0-beta.53"
}
body = {
  "commands": [
    {
      "code": "fan_switch",
      "value": true
    },
    {
      "code": "fan_speed",
      "value": 2
    }
  ]
}
[6/24/2024, 12:55:59 PM] [Tuya] [TuyaOpenAPI] Response:
path = /v1.0/devices/ebd94bb811d9316c6ai4ga/commands
data = {
  "result": true,
  "success": true,
  "t": 1719258959186,
  "tid": "c6defbad326311efb9130e1a774ae1f3"
}
[6/24/2024, 12:55:59 PM] [Tuya] [Isaiah Office Fan] [Fan/undefined/RotationDirection] Update value: 0 => 1
[6/24/2024, 12:55:59 PM] [Tuya] [Isaiah Office Fan] [Fan/undefined/RotationSpeed] Update value: 2 => 1
[6/24/2024, 12:55:59 PM] [Tuya] [Isaiah Office Fan] [Fan/undefined/RotationSpeed] Update value: 1 => 2

Other Infomations

I'm trying to create an automation that controls my fan speed. Whenever the automation is triggered, it reverses the fan direction. I can't figure out why and would love some help getting this working. Thanks!