Changing Thermostat HeatingSetpoint

Bill, it took me a while to realize that the binding of the 4 buttons to change the Thermostat setpoint temperatures “@Device.HeatingSetpoint” should be “@Device.HeatingSetpoint.Value”, otherwise the call to the POST fails and the App hangs, at least calling the Nest API.

In addition, I am using a Nest “leave” icon in green color to show that the thermostat is in Eco mode and it shows well in Android but in Windows it turns to white… I am using an icon in the ThermostatTile that shows this behaviour, although the ShowAsMonochrome is selected. Curiously, the icon in the ThermostatDetails tile shows well, with ShowAsMonochrome selected.

Many thanks!

That should not matter. You’re telling me the built-in templates did not work? They work for every other thermostat integration I have so I’m not sure why they wouldn’t work for you.

The ThermostatDetails template hangs the application if “.Value” is not included.

What I saw is that the value is actually changed in the thermostat ! So this makes me think that the problem might be with the Details form?

You shouldn’t have to do that. I just created a test plugin & it is still working fine for me. I don’t think there is anything wrong with the Details page. Perhaps your file is corrupted. Delete it & resync the templates.

Attached is my test plugin I put together. Please test this on your machine.
Plugin_HeatingSetpoint.hrp (125.4 KB)

Actually, without the call to the POST the form works well, the temperature changes in the App (not in the thermostat, of course) and it does not hang. When the POST is called it hangs, although the temperature is actually changed in the thermostat…
I used both, a new template from a new project and the template of your project and the problem persists.

What do you mean it hangs? How long does it hang?

When you use the “HeatingSetpoint”, not the “.Value” one, it will take an additional 2.5 seconds. It does that to try & limit the number of API requests that are sent out. That way if you are incrementing from 60 to 70 it only has to send 1 request vs 10. Most of these APIs have rate limits. There’s no point in sending every incremental value.

Are calling this additional 2.5 seconds a “hang”?

How long are you waiting after you finish clicking the increment button?

Actually the App freezes, in design mode, Windows and Android…

Would you emailing me this plugin so I can test it?

I won’t make any major setpoint changes to your thermostat. I’ll only raise & lower your thermostat 1 degree max. I just want to try & replicate what you are seeing on my PC.

Nevermind. I may have just found something.

Yeah, you are correct. I just put a simple HTTP request in that virtual example I shared & it hung just as you said. Thanks for reporting the issue. I’ll try to get this fixed in the next release. Yes, for the time being use the “.Value” variable.

Just an FYI, it is only the HeatingSetpoint & CoolingSetpoint attributes that use this new delayed set.

1 Like

Bill,
This is the plugin as I have it so far. To configure it you need to put the thermostat Nest ID in the Id field of the device. You also need to have the projectID, clientID, clientSecret and refreshToken defined in he collection settings. When HR starts it gets the accessToken from the refreshToken and puts it in a variable.

I use some resources for colors which I do not know how to export:
AccentBrush8, color {ThemeResource AccentColor}, opacity 0,8
AccentBrush8_heat, color #FFF78D20, opacity 0,8
AccentBrush8_eco, color #FF00B050, opacity 0,8

Right now everything works but it is very very slow, unfortunately.

In addition, not only the token is valid for only 1 hour, but, as you mentioned, there is a limit of calls you can make per minute. So I defined a PollingInterval = 30000 which should be ok if the first call defines all the HR data. Whenever you make a change in HR, I update HR fields and the problem is how to handle the Setpoint temperature.

It is very interesting that Nest has several Setpoints: for heat, cool, and eco, as well as when the thermostat is off, to prevent the house going to cold… That is quite hard to handle because all these temperatures are not defined (I made some attributes for the Eco setpoint and temperature), but the problem is if the thermostat is in Eco mode or Off, when you Get the parameters the heating Setpoint is not defined! So I tried to define a special field to update very fast the HR field by using the stored old Setpoint if defined, but I did not succeed. So I just wait until the onPoll does its job. I also thought about calling the onPoll after the onChangeRequest to force the update…

If you have some suggestions, and even examples I could learn from, especially about how to handle the PollingInterval, the onPoll and the refresh token I would really appreciate it. In addition if you have some suggestions about speeding up the loading proces… :wink:

Thank you so much!

GoogleNestThermostat.plugin (7.1 KB)
ThermostatDetails_Nest.xaml (18.1 KB)
ThermostatTile_Nest.xaml (10.2 KB)
NestLeaf

1 Like

By the way, I forgot to mention that when starting HR I always get the error of a non correct result 401(), then HR disconnects and reconnects again with no error? This might slow down the App as well.
The error code page (Errors  |  Cloud APIs  |  Google Cloud) shows this error as:
401 UNAUTHENTICATED Request not authenticated due to missing, invalid, or expired OAuth token.
I have no idea about why this happens systematically and how to avoid it?

You are making an unauthenticated request somewhere. If I had to guess, it’s at line 65. In the block above it you are only refreshing the token if “HasSubscribers” is active. You’re not including the check on line 65 so that code could very well be running with a null access token.

It’d seem to me that you probably should include the code from 65-112 in the same “HasSubscribers” block you are using for the access token.

Bill, you’re right! Nice catch!
What text editor are you using? It would be nice to have a dark background inside HR… :wink:

I’m using VS Code.

I also have it set up to use standard JavaScript syntax highlighting for the “.plugin” extension.

And how do you open the plugins fromHr? Do you click “Open in File Explorer” and then open with VS Code? In File Explorer the plugins don’t have the “.plugin” extension…

Yes. You can do that. The files in the File Explorer should have the same extension they have in Home Remote.

By the way, the app is still very slow…