jmbwell / homebridge-infinitive-thermostat

Homebridge plugin for thermostats supported by github.com/acd/infinitive
Apache License 2.0
3 stars 1 forks source link

Adding a thermometer using outdoor temperature #1

Open cheitzig opened 3 years ago

cheitzig commented 3 years ago

Hi,

Wondering if I might elicit your help in resolving an issue I’m having. I also posted to the parent project, which you've seen, but that doesn't match well to your current project. I also posted to the Homebridge plug-in development forum on Discord: https://discord.com/channels/432663330281226270/432672072859385856.

I tried to extend your plug-in to also expose a Temperature Sensor that represents the outside temperature. See: https://github.com/cheitzig/homebridge-infinitive-thermostat. FWIW, I think it ultimately should be a platform vs. an accessory because that'd allow, for example, the temperature sensor to be in a different room. The structure of the existing project is to expose the thermostat as a HomeKit accessory, so I added a second service to the Accessory with the idea that it would then expose the outside temperature within the same HomeKit tile. The code I added includes:

The relevant code line changes (my line numbers) include: 26, 39, 53, 219-248, and 706-717

So it appears correct, but doesn't work, so I must be doing something wrong. I started by writing my own function, getCurrentOutdoorTemperature, and call it on line 709 from the .on('get' of the TemperatureService. When I run it this way though, HomeKit gives an error that says "This accessory isn't responding". getCurrentOutdoorTemperature is almost identical to your existing getCurrentTemperature function with the exception of getting the outside vs. the inside temperature from my furnace API.

If I just hard-set the outdoor temperature (line 39), and update the TemperatureService’s CurrentTemperature characteristic to that value (lines 706-710), the Temperature Sensor shows up fine (granted, just showing the hard-coded temperature). Also, if I call the same “getter” that is used for the internal/house temperature (line 708, currently commented out), things also work fine (or rather, then outside temperature is listed as the inside temperature, which at least appears to work).

To answer your question on the parent GitHub, I don't get an error or dump other than "This accessory isn't responding", although maybe I'm not looking in the right place. It's weird that it works when hard-coded or even calling your existing function, but not when I call my nearly identical function.

cheitzig commented 3 years ago

Update: I think the issue was I wasn't setting Characteristic.TemperatureDisplayUnits for the Temperature Sensor. I figured that out by ripping everything else out and creating a new accessory name. I will eventually try to put back together again, although I think it might be better for it to be a platform so the Outside temperature can be in a separate room from the Thermostat. I will probably do that eventually too.

jmbwell commented 3 years ago

That might make sense. Glad you’re on to something.

I like the idea of making it a platform. I’ve had the idea to do that so that we can have a Thermostat service for the heating and cooling, along with a Fan service for the blower, and yeah it would make sense to add the outdoor temperature as a service. Probably could add indoor and outdoor humidity too.

cheitzig commented 3 years ago

I don't think it's a ton of work, but I FIRST wanted to just be able to get something working and it was driving me nuts that the Temperature Sensor wasn't working. Agree with your point on adding those other things. Interestingly, the humidity shows on the details of the Thermostat, which is kind of cool.