0x5e / homebridge-tuya-platform

Make homebridge-tuya-platform great again.
MIT License
206 stars 58 forks source link

Garage Door Opener not reporting open state in homekit correctly #379

Open samralck opened 9 months ago

samralck commented 9 months ago

Prerequisite

Cache

Version

v1.7.0-beta.49

Device Infomation JSON File

{
    "active_time": 1671522995,
    "biz_type": 0,
    "category": "ckmkzq",
    "create_time": 1671520711,
    "icon": "smart/icon/ay1536534747810ekKBj/4aa444a268bf4c4657a7b0d31b4fac45.png",
    "id": "bf3062f8214b3f27d0jukx",
    "ip": "",
    "lat": "",
    "local_key": "",
    "lon": "",
    "model": "SWS102HA",
    "name": "Garage Door",
    "online": true,
    "owner_id": "74372133",
    "product_id": "3vd7ybbeh10llcdc",
    "product_name": "Smart Garage Door Opener ",
    "status": [
      {
        "code": "countdown_1",
        "value": 0
      },
      {
        "code": "countdown_alarm",
        "value": 600
      },
      {
        "code": "door_control_1",
        "value": "open"
      },
      {
        "code": "door_state_1",
        "value": "unclosed_time"
      },
      {
        "code": "doorcontact_state",
        "value": false
      },
      {
        "code": "switch_1",
        "value": false
      },
      {
        "code": "tr_timecon",
        "value": 25
      },
      {
        "code": "voice_control_1",
        "value": true
      }
    ],
    "sub": false,
    "time_zone": "+10:00",
    "uid": "eu1670850690387CmggV",
    "update_time": 1695133587,
    "uuid": "d032675720a6fa5a",
    "schema": [
      {
        "code": "countdown_1",
        "mode": "rw",
        "type": "Integer",
        "property": {
          "unit": "s",
          "min": 0,
          "max": 86400,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "countdown_alarm",
        "mode": "rw",
        "type": "Integer",
        "property": {
          "unit": "s",
          "min": 0,
          "max": 86400,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "door_control_1",
        "mode": "rw",
        "type": "Enum",
        "property": {
          "range": [
            "open",
            "close"
          ]
        }
      },
      {
        "code": "door_state_1",
        "mode": "rw",
        "type": "Enum",
        "property": {
          "range": [
            "unclosed_time",
            "close_time_alarm",
            "none"
          ]
        }
      },
      {
        "code": "doorcontact_state",
        "mode": "ro",
        "type": "Boolean",
        "property": {}
      },
      {
        "code": "switch_1",
        "mode": "rw",
        "type": "Boolean",
        "property": {}
      },
      {
        "code": "tr_timecon",
        "mode": "rw",
        "type": "Integer",
        "property": {
          "unit": "s",
          "min": 10,
          "max": 120,
          "scale": 0,
          "step": 1
        }
      },
      {
        "code": "voice_control_1",
        "mode": "rw",
        "type": "Boolean",
        "property": {}
      }
    ]
  },

Device Control Mode

Standard Instruction

Logs

2023-09-23T04:52:31.879Z HAP-NodeJS:EventedHTTPServer:Connection [] HTTP request: /prepare
2023-09-23T04:52:31.879Z HAP-NodeJS:HAPServer [0E:B3:CB:FC:41:14] HAP Request: PUT /prepare
2023-09-23T04:52:31.880Z HAP-NodeJS:HAPServer [0E:B3:CB:FC:41:14] Received prepare write request with pid 17731943923132393000 and ttl 5000
2023-09-23T04:52:31.883Z HAP-NodeJS:EventedHTTPServer:Connection [] HTTP Response is finished
2023-09-23T04:52:31.889Z HAP-NodeJS:EventedHTTPServer:Connection [] HTTP request: /characteristics
2023-09-23T04:52:31.889Z HAP-NodeJS:HAPServer [0E:B3:CB:FC:41:14] HAP Request: PUT /characteristics
2023-09-23T04:52:31.890Z HAP-NodeJS:Accessory [@0x5e/homebridge-tuya-platform 90C4] Processing characteristic set: {"characteristics":[{"aid":2,"iid":11,"value":0}],"pid":17731943923132393000}
2023-09-23T04:52:31.891Z HAP-NodeJS:Accessory [@0x5e/homebridge-tuya-platform 90C4] Timed write request got acknowledged for pid 17731943923132393000
2023-09-23T04:52:33.068Z HAP-NodeJS:EventedHTTPServer [] Muting event '2.11' notification for this connection since it originated here.
2023-09-23T04:52:33.069Z HAP-NodeJS:Accessory [@0x5e/homebridge-tuya-platform 90C4] Setting Characteristic "Target Door State" to value 0
2023-09-23T04:52:33.071Z HAP-NodeJS:EventedHTTPServer:Connection [] HTTP Response is finished
2023-09-23T04:52:33.321Z HAP-NodeJS:EventedHTTPServer:Connection [] Sending HAP event notifications [ { aid: 2, iid: 11, value: 0 } ]
2023-09-23T04:52:33.506Z HAP-NodeJS:EventedHTTPServer Currently 2 hap connections open: :50202, :51682
2023-09-23T04:52:36.087Z HAP-NodeJS:EventedHTTPServer Currently 2 hap connections open: :50203, :51683
2023-09-23T04:52:56.322Z HAP-NodeJS:EventedHTTPServer:Connection [] HTTP request: /characteristics?id=1.7
2023-09-23T04:52:56.323Z HAP-NodeJS:HAPServer [0E:B3:CB:FC:41:14] HAP Request: GET /characteristics?id=1.7
2023-09-23T04:52:56.324Z HAP-NodeJS:EventedHTTPServer:Connection [] HTTP request: /characteristics?id=1.7
2023-09-23T04:52:56.324Z HAP-NodeJS:HAPServer [0E:3D:6D:35:02:79] HAP Request: GET /characteristics?id=1.7
2023-09-23T04:52:56.326Z HAP-NodeJS:Accessory [Homebridge 0279 FB20] Got Characteristic "Firmware Revision" value: "1.6.1"
2023-09-23T04:52:56.324Z HAP-NodeJS:Accessory [@0x5e/homebridge-tuya-platform 90C4] Got Characteristic "Firmware Revision" value: "1.6.1"
2023-09-23T04:52:56.327Z HAP-NodeJS:EventedHTTPServer:Connection [] HTTP Response is finished
2023-09-23T04:52:56.330Z HAP-NodeJS:EventedHTTPServer:Connection [] HTTP Response is finished
2023-09-23T04:52:59.210Z HAP-NodeJS:EventedHTTPServer:Connection [] HTTP request: /prepare
2023-09-23T04:52:59.210Z HAP-NodeJS:HAPServer [0E:B3:CB:FC:41:14] HAP Request: PUT /prepare
2023-09-23T04:52:59.211Z HAP-NodeJS:HAPServer [0E:B3:CB:FC:41:14] Received prepare write request with pid 5522601623439090000 and ttl 5000
2023-09-23T04:52:59.213Z HAP-NodeJS:EventedHTTPServer:Connection [] HTTP Response is finished
2023-09-23T04:52:59.222Z HAP-NodeJS:EventedHTTPServer:Connection [] HTTP request: /characteristics
2023-09-23T04:52:59.222Z HAP-NodeJS:HAPServer [0E:B3:CB:FC:41:14] HAP Request: PUT /characteristics
2023-09-23T04:52:59.223Z HAP-NodeJS:Accessory [@0x5e/homebridge-tuya-platform 90C4] Processing characteristic set: {"characteristics":[{"aid":2,"iid":11,"value":1}],"pid":5522601623439090000}
2023-09-23T04:52:59.223Z HAP-NodeJS:Accessory [@0x5e/homebridge-tuya-platform 90C4] Timed write request got acknowledged for pid 5522601623439090000
2023-09-23T04:53:00.453Z HAP-NodeJS:EventedHTTPServer [] Muting event '2.11' notification for this connection since it originated here.
2023-09-23T04:53:00.453Z HAP-NodeJS:Accessory [@0x5e/homebridge-tuya-platform 90C4] Setting Characteristic "Target Door State" to value 1
2023-09-23T04:53:00.456Z HAP-NodeJS:EventedHTTPServer:Connection [] HTTP Response is finished
2023-09-23T04:53:00.704Z HAP-NodeJS:EventedHTTPServer:Connection [] Sending HAP event notifications [ { aid: 2, iid: 11, value: 1 } ]
2023-09-23T04:53:33.532Z HAP-NodeJS:EventedHTTPServer Currently 2 hap connections open: :50202, :51682
2023-09-23T04:53:36.088Z HAP-NodeJS:EventedHTTPServer Currently 2 hap connections open: :50203, :51683
2023-09-23T04:54:01.361Z HAP-NodeJS:EventedHTTPServer:Connection [] HTTP request: /characteristics?id=1.7
2023-09-23T04:54:01.361Z HAP-NodeJS:HAPServer [0E:B3:CB:FC:41:14] HAP Request: GET /characteristics?id=1.7
2023-09-23T04:54:01.363Z HAP-NodeJS:Accessory [@0x5e/homebridge-tuya-platform 90C4] Got Characteristic "Firmware Revision" value: "1.6.1"
2023-09-23T04:54:01.365Z HAP-NodeJS:EventedHTTPServer:Connection [] HTTP Response is finished
2023-09-23T04:54:01.376Z HAP-NodeJS:EventedHTTPServer:Connection [] HTTP request: /characteristics?id=1.7
2023-09-23T04:54:01.376Z HAP-NodeJS:HAPServer [0E:3D:6D:35:02:79] HAP Request: GET /characteristics?id=1.7
2023-09-23T04:54:01.379Z HAP-NodeJS:Accessory [Homebridge 0279 FB20] Got Characteristic "Firmware Revision" value: "1.6.1"
2023-09-23T04:54:01.382Z HAP-NodeJS:EventedHTTPServer:Connection [] HTTP Response is finished

Other Infomations

This device is the "Orion Grid Connect Smart Garage Door Controller With Sensor" sold in Australia. I have it connected to the tuya home app. Is working in homekit through homebridge, can correctly open and close it. However, the open/closed state does not display accurately in homekit. Sometimes it is correct, sometimes it is just plain wrong, sometimes it says "opening" or "closing" perpetually. Any help would be appreciated! feel free to email me :)

madtempest commented 8 months ago

This usually happens when the door is activated using the original controllers/remotes rather than using the HomeKit control.

From what I can tell, this particular plugin does not poll objects like Garage Doors on a regular basis and I suspect that is because this kind of solution/action would likely chew up your API credits per month that comes with the IoT Core subscription pack you get for free.

I can't think of another way to manage this without some kind of poll even though the controller does push the door state to the API. @0x5e is there another way without a poll, some kind of way of the plugin being notified in some other method that a state has changed?

This should possibly also be re-labeled an enhancement and not a bug given it's operating as expected within the parameters of the plugin and the constraints of the Tuya Cloud API for us non-commercial folks.