ebaauw / homebridge-hue

Homebridge plugin for Philips Hue
Apache License 2.0
899 stars 91 forks source link

Support Thermostat #426

Closed ebaauw closed 5 years ago

ebaauw commented 5 years ago

See https://github.com/dresden-elektronik/deconz-rest-plugin/issues/1098.

ebaauw commented 5 years ago

I added support for ZHAThermostat and CLIPThermostat in the above commit, but cannot test it, as CLIPThermostat is not yet implemented in deCONZ (see https://github.com/dresden-elektronik/deconz-rest-plugin/pull/1003), and I don't have a thermostat myself.

ebaauw commented 5 years ago

In v0.11.7

ebaauw commented 5 years ago

Added (untested) support for Eve history in v0.11.8.

I would appreciate if some-one could post a screenshot of Eve, the full debug log (see https://github.com/ebaauw/homebridge-hue#debug-log-file), and the Eve history file, so I can check whether is works as intended.

thecem commented 5 years ago

Hi ebaauw which thermostat data do you need ? I have Netatmo and Tado....

ebaauw commented 5 years ago

I need the data homebridge-hue collects for a thermostat that talks Zigbee and connects to deCONZ, like the Bitron or the Eurotronic.

thecem commented 5 years ago

Ah OK, those one I dosn´t have.

tkintscher commented 5 years ago

I do not (yet) have a deCONZ/Zigbee thermostat to test this, but for my current integration of Z-Wave thermostats into HomeKit I set the characteristics as follows:

This shows in the Home app as follows: 7j52bbdkrccz6ea mq01yw_thumb_43f Orange circles indicate rooms where the thermostat is actually heating (device is configured to "Heat" and valve is >10% open), green circles indicate rooms where the mode in HomeKit is set to "Auto" (i.e. device mode = "Heat"), but the valve is currently closed, because the temperature is close to the target. (Not shown here but gray circles would show rooms where the thermostat is turned off)

Maybe this would be a nice addition here (provided that the current valve opening is reported, I don't know about that for the Zigbee thermostats).

dergreg commented 5 years ago

Additionally, is there any chance to display errors reported (such as valve adjustment failures etc.) within HomeKit? deConz recently added the necessary clusters, at least for the eurotronics thermostat.

tkintscher commented 5 years ago

I have now tested with the Eurotronic thermostat. Adjusting the setpoint and showing the current temperature works. For the setpoint however, I had to insert

targetTemperature = Math.round(targetTemperature / 0.5) * 0.5

at line 2152 in HueSensor.js, because even though the HomeKit-Apps only show 0.5 degree steps, at least the slider in Apple's Home app tends to return values in between.

The heating mode does not seem to be supported by this device at all. The only way to turn it off (e.g. when windows are opened) is by lowering the temperature. The minimum in the thermostat is 5°C, but the minimum in HomeKit is 10°C... However, I would not map "Off" -> 5°C, because there is no way to reverse it (e.g. switching from "Off" to "Heat", it's not clear what the temperature should be).

Mapping "Off" to a valve opening of 0% could be an alternative, but I also wouldn't recommend it, as this provides no anti-freeze protection (and is currently not exported through the REST API).

ebaauw commented 5 years ago

I have now tested with the Eurotronic thermostat. Adjusting the setpoint and showing the current temperature works.

So the Home app show the tiles as intended (as for the Z-Wave thermostats)?

but I call round(input*2)/2 to round to 0.5 degrees (values in between tend to be rejected by the thermostat) even though the HomeKit-Apps only show 0.5 degree steps, at least the slider in Apple's Home app tends to return values in between.

@tkintscher the best solution for this would be to set the minStep property of the TargetTemperature characteristic to 0.5. To be on the safe side, we would also need to round the value retrieved from deCONZ to 0.5°C (instead of to 0.1°C).

UPDATE: in v0.11.13.

tkintscher commented 5 years ago

I have now tested with the Eurotronic thermostat. Adjusting the setpoint and showing the current temperature works.

So the Home app show the tiles as intended (as for the Z-Wave thermostats)?

Yes, in v0.11.13 👍

but I call round(input*2)/2 to round to 0.5 degrees (values in between tend to be rejected by the thermostat) even though the HomeKit-Apps only show 0.5 degree steps, at least the slider in Apple's Home app tends to return values in between.

@tkintscher the best solution for this would be to set the minStep property of the TargetTemperature characteristic to 0.5. To be on the safe side, we would also need to round the value retrieved from deCONZ to 0.5°C (instead of to 0.1°C).

Right, minStep works even better. I wasn't aware of this feature.

Along these lines, we could also set minValue: 5, maxValue: 30 to match the range of this device.

ebaauw commented 5 years ago

Will include that in next version.

Did you try to control the thermostat from Eve? Does it show the temperature history?

tkintscher commented 5 years ago

Will include that in next version.

Many thanks for your effort and this great tool!

Did you try to control the thermostat from Eve? Does it show the temperature history?

Yes, the target temperature can be controlled from the Eve App as well. Eve also keeps a history of the local (measured) temperature (not much yet, because I reset it after some experimenting):

img_4cf86ec862f7-1

ebaauw commented 5 years ago

Hm, I expected Eve also to show the target temperature in the history, see https://github.com/simont77/fakegato-history/issues/11#issuecomment-357513406. What does it show when you expand the little triangle behind HEATING?

Could you please attach the history file (~/.homebridge/accessories/history_mac.json, where mac is the thermostat's Zigbee mac address, exposed as Serial Number in Eve under the Accessory Details), so I can check that homebridge-hue creates the right history entries?

tkintscher commented 5 years ago

That triangle doesn't show any history, there's an empty plot with no measurements: img_59cea34eab50-1

Here is the file, the setTemp entries exist: history_00158D000192D18D.json

Btw, what is "Mode" -- is it the "CurrentHeatingCoolingState" characteristic? I'm confused because the options for my other (Z-Wave, not using homebridge) thermostat are off-heat-cool-on. How did you hide the heat/cool options?

ebaauw commented 5 years ago

Thanks. The history file looks like what I expected. Re-reading the other topic, apparently there's a setting under the dots under the graph to select target temperature.

Btw, what is "Mode"

I map state.on to CurrentHeatingCoolingState and config.scheduleron to TargetHeatingCoolingState. Eve probably combines the two of them in Mode.

How did you hide the heat/cool options?

That shouldn't come as a surprise: https://github.com/ebaauw/homebridge-hue/blob/8d20dc94f7a0ec1cda3d33e840725278438e33ef/lib/HueSensor.js#L1267-L1268

I'm not sure why Eve is displaying the On|Off next to HEATING. I would expect to see Off and Heating. Maybe I should set validValues as well, maybe I should limit CurrentHeatingCoolingState as well, or maybe Eve doesn't like me limiting the values at all. I'm afraid this is going to be a bit of trial and error.

For the characteristic definitions, see https://github.com/KhaosT/HAP-NodeJS/blob/414cd96ca9708596b1f71304bd4e6dff5ab045fc/lib/gen/HomeKitTypes.js#L2325-L2345

tkintscher commented 5 years ago

I guess you're refering to that comment. The three dots lead to a larger version of the graph. There's a "compare" toggle switch, which adds another line. It seems to be the same graph but shifted in time (it is not the setpoint, because that was set to 20C for the last hours). Actually the "Compare" option is the same as for all other measurements (like the Xiaomi multisensor):

img_0920 img_0921

Thanks for the explanation about the characteristics. I've always had trouble finding out which properties are supported by which device classes. If I find some time later this week, I can play around with the options and see what works best here.

ebaauw commented 5 years ago

Supported in v0.11.4, but needs https://github.com/dresden-elektronik/deconz-rest-plugin/pull/1230.

Apple's Home app: img_0141 img_0142 img_0144 I linked Mode (TargetHeatingCoolingState) to TargetTemperature:

The Eve app shows history for Current Temperature and for valve position: img_0145 img_0146 img_0147 I cannot get Eve to show the history for Target Temperature without also showing the (not supported) schedule, which is more trouble than benefits. Also the history for valve position then seems to disappear. Somehow, Eve doesn't support setting Mode to Auto. Neither Off nor On are highlighted when Mode is Auto.

ebaauw commented 5 years ago

Found a bug in thermostat history, fixed in https://github.com/ebaauw/homebridge-hue/commit/a45beee0abc61a5236e591eeffc401caf428e55a, which will be included in the next version.

Closing this for now. Until the schedule for the Eve Thermo has been reverse engineered, there's nothing I can do.