PJCzx / homebridge-thermostat

Supports thermostat devices on HomeBridge Platform
Apache License 2.0
34 stars 71 forks source link

Cannot pair Homebridge bridge in Home app when homebridge-thermostat accessories are present in config.json #53

Open keithkml opened 4 years ago

keithkml commented 4 years ago

Hi, I've been struggling with this for hours. I wrote custom software to control the heating/cooling in our home. It was simple to implement the homebridge-thermostat HTTP API in my code, so I did that:

{"targetHeatingCoolingState":3,"targetTemperature":22.77777777777778,"currentHeatingCoolingState":0,"currentTemperature":23.059999999999995,"targetRelativeHumidity":30,"currentRelativeHumidity":30}

With Homebridge 0.x, I was able to set up homebridge-thermostat using the following settings:

 "accessories": [
        {
            "accessory": "Thermostat",
            "name": "Nursery Thermostat",
            "apiroute": "http://127.0.0.1:9269/api/nursery",
            "temperatureDisplayUnits": 1,
            "minTemp": 19.444444444,
            "maxTemp": 25.555555556
        },
        {
            "accessory": "Thermostat",
            "name": "Bedroom Thermostat",
            "apiroute": "http://127.0.0.1:9269/api/bedroom",
            "temperatureDisplayUnits": 1,
            "minTemp": 19.444444444,
            "maxTemp": 25.555555556
        },
        {
            "accessory": "Thermostat",
            "name": "Living Room Thermostat",
            "apiroute": "http://127.0.0.1:9269/api/living-room",
            "temperatureDisplayUnits": 1,
            "minTemp": 19.444444444,
            "maxTemp": 25.555555556
        },
        {
            "accessory": "Thermostat",
            "name": "Office Thermostat",
            "apiroute": "http://127.0.0.1:9269/api/office",
            "temperatureDisplayUnits": 1,
            "minTemp": 19.444444444,
            "maxTemp": 25.555555556
        }
    ],

This kinda worked. At first, all 4 accessories showed the proper temp and state, but said No response below the temperature. Sometimes, inexplicably, the No response would go away, and it would say Set to 74º or whatever. My wife, who is also a member of this HomeKit home, also saw the same behavior. We were happy, though confused about the No response.

However, a few hours later, the accessories stopped working on my phone. Then they stopped working on her phone. Then, no matter what I tried – restarting homebridge, re-pairing – it never worked again.

After poking around the Homebridge forums, I saw that Homebridge 1.0 was out, and it claimed to fix some issues with "No response" and multi-user homes. So I upgraded to Homebridge 1.1. Unfortunately this did not help. In fact, now I can't even pair Homebridge with my Home at all. I've tried everything they suggest – wiping the persist directory, etc. It turns out I can only get pairing to work if I remove the homebridge-thermostat accessories from config.json.

Here's what homebridge debug logging says when I try pairing with homebridge-thermostat accessories:

  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP request: /pair-setup +82ms
  HAP-NodeJS:HAPServer [0E:A1:1A:10:A8:54] HAP Request: POST /pair-setup +1s
  HAP-NodeJS:HAPServer [0E:A1:1A:10:A8:54] Pair step 2/5 +1ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP Response is finished +1s
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP request: /pair-setup +9ms
  HAP-NodeJS:HAPServer [0E:A1:1A:10:A8:54] HAP Request: POST /pair-setup +1s
  HAP-NodeJS:HAPServer [0E:A1:1A:10:A8:54] Pair step 3/5 +2ms
  HAP-NodeJS:HAPServer [0E:A1:1A:10:A8:54] Pair step 4/5 +7ms
  HAP-NodeJS:HAPServer [0E:A1:1A:10:A8:54] Pair step 5/5 +143ms
  HAP-NodeJS:Accessory [Homebridge A854] Paired with client FB7C4E9B-6733-44AB-8CA1-B1B83C487B6C +3m
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP Response is finished +233ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] Client connection closed +11ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP connection was closed +3ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP server was closed +0ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] New connection from client +3ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP server listening on port 44213 +1ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP request: /pair-verify +3ms
  HAP-NodeJS:HAPServer [0E:A1:1A:10:A8:54] HAP Request: POST /pair-verify +104ms
  HAP-NodeJS:HAPServer [0E:A1:1A:10:A8:54] Pair verify step 1/2 +2ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP Response is finished +103ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP request: /pair-verify +9ms
  HAP-NodeJS:HAPServer [0E:A1:1A:10:A8:54] HAP Request: POST /pair-verify +109ms
  HAP-NodeJS:HAPServer [0E:A1:1A:10:A8:54] Pair verify step 2/2 +2ms
  HAP-NodeJS:HAPServer [0E:A1:1A:10:A8:54] Client FB7C4E9B-6733-44AB-8CA1-B1B83C487B6C verification complete +84ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP Response is finished +90ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP request: /accessories +8ms
  HAP-NodeJS:HAPServer [0E:A1:1A:10:A8:54] HAP Request: GET /accessories +11ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP Response is finished +9ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP request: /pairings +25ms
  HAP-NodeJS:HAPServer [0E:A1:1A:10:A8:54] HAP Request: POST /pairings +35ms
  HAP-NodeJS:HAPServer [0E:A1:1A:10:A8:54] Pairings: successfully executed REMOVE_PAIRING +6ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP Response is finished +8ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] Client connection closed +12ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP connection was closed +1ms
  HAP-NodeJS:EventedHTTPServer [::ffff:192.168.0.165] HTTP server was closed +1ms

I found an ancient Homebridge issue https://github.com/homebridge/homebridge/issues/1245#issuecomment-292072658 where the authors claim that a plugin is "malfunctioning" and causing pairing to fail. This makes sense to me, as pairing seems to work, but then the Home app decides it "cannot connect" after getting the accessory list.

Any advice? Am I using the wrong settings?

PJCzx commented 4 years ago

Hello,

Did you tried with only on accessory ? And with the « fake api » to see if everything is working ?

Best