PJCzx / homebridge-thermostat

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

Thermostat not working with Siri, but OK with Home app #32

Closed SupraJames closed 5 years ago

SupraJames commented 5 years ago

I set this all up over a year ago - but at some point something broke - I could no longer use Siri to set the desired temperature of my heating.

I found today that there is a difference in how Siri and the Home app work. On my iPhone running iOS 12.1.2 I can use the Home app to set the temperature and it works fine:

Jan 16 20:13:40 smartie homebridge[20463]: Wed, 16 Jan 2019 20:13:40 GMT HAPServer [CC:22:3D:E3:CE:30] HAP Request: PUT /characteristics
Jan 16 20:13:40 smartie homebridge[20463]: Wed, 16 Jan 2019 20:13:40 GMT Accessory [Homebridge] Processing characteristic set: [{"aid":17,"iid":13,"value":21}]
Jan 16 20:13:40 smartie homebridge[20463]: Wed, 16 Jan 2019 20:13:40 GMT Accessory [Homebridge] Setting Characteristic "Target Temperature" to value 21
Jan 16 20:13:40 smartie homebridge[20463]: [2019-1-16 20:13:40] [Heatmiser] setTargetTemperature from: http://localhost:4321/targetTemperature/21
Jan 16 20:13:40 smartie homebridge[20463]: [2019-1-16 20:13:40] [Heatmiser] response success

However, if I ask Siri to 'set the temperature to 21 degrees' then HomeKit seems to use a different Characteristic, which is not implemented:

Jan 16 19:54:15 smartie homebridge[476]: Wed, 16 Jan 2019 19:54:15 GMT HAPServer [CC:22:3D:E3:CE:30] HAP Request: PUT /characteristics
Jan 16 19:54:15 smartie homebridge[476]: Wed, 16 Jan 2019 19:54:15 GMT Accessory [Homebridge] Processing characteristic set: [{"aid":17,"iid":17,"value":5}]
Jan 16 19:54:15 smartie homebridge[476]: Wed, 16 Jan 2019 19:54:15 GMT Accessory [Homebridge] Setting Characteristic "Heating Threshold Temperature" to value 5
Jan 16 19:54:15 smartie homebridge[476]: Wed, 16 Jan 2019 19:54:15 GMT EventedHTTPServer [::ffff:192.168.100.143] Sending HTTP event '17.17' with data: {"characteristics":[{"aid":17,"iid":17,"value":5}]}
Jan 16 19:54:15 smartie homebridge[476]: Wed, 16 Jan 2019 19:54:15 GMT EventedHTTPServer [::ffff:192.168.100.176] Muting event '17.17' notification for this connection since it originated here.
Jan 16 19:54:15 smartie homebridge[476]: Wed, 16 Jan 2019 19:54:15 GMT EventedHTTPServer [::ffff:192.168.100.176] HTTP Response is finished

So, short story, Home app uses "Target Temperature" and Siri uses "Heating Threshold Temperature".

I have no idea when this change, presumably in iOS, occurred. Editing index.js for homebridge-thermostat and commenting out the following lines fixes the issue:

                this.service
                        .getCharacteristic(Characteristic.HeatingThresholdTemperature)
                        .on('get', this.getHeatingThresholdTemperature.bind(this));

We then don't register this characteristic with HomeKit, and it doesn't get called. Siri starts to work again.

I'm opening this as an issue, I think the simple fix would be just to delete these lines but don't want to break anything.

PJCzx commented 5 years ago

Thx @SupraJames for this feedback. I just roughly pushed and publish on NPN your feedback. Can you let me know if it's better ? Thx

PJCzx commented 5 years ago

15 days without feedback, I close the issue

phenotypic commented 5 years ago

@SupraJames I've found a solution to your issue. As you suggested, we can simply remove the HeatingThreshholdTemperature as having it caused Siri to use this to set the temperature instead of TargetTemperature.

Currently, my fork is too different to simply make a pull request, however, once I have solved a number of other issues with the plugin, I will do. If you are interested in making a pull request yourself or would like to make your own fork which adds this functionality, the steps to do it are fairly simple:

  1. Delete all sections which contain the word "threshold". This includes the this.service declaration, the getHeatingThresholdTemperature function as well as the functions relating to CoolingThresholdTemperature. Thus, you can also delete any variables related to this field located near the top.

Hopefully that helps you!

EDIT I have now made a pull request which will solve this issue.