I am trying to update my Nest Heat Set Point using a variable and AppleScript. Everything complies fine but the update doesn't happen. Any help would be great.
--Script--
set theSetPointHeat to heat setpoint of device "Hallway Thermostat" as integer
set theHeatPoint to value of variable "TempSetPointHot" as integer
set heat setpoint of device "Hallway Thermostat" to theHeatPoint
repeat 3 times -- theHeatPoint is not equal to theSetPointHeat
set heat setpoint of device "Hallway Thermostat" to theHeatPoint
end repeat
delay 5
set theSetPointHeat to heat setpoint of device "Hallway Thermostat" as integer
set theHeatPoint to value of variable "TempSetPointHot" as integer
if theSetPointHeat = theHeatPoint then
log "The Device Heat Point Is " & theSetPointHeat & " The Variable Heat Point Is " & theHeatPoint as text
else
log "The Device Heat Point Is " & theSetPointHeat & " AND DOESN'T Equal The Variable Heat Point Which Is " & theHeatPoint as text
end if
--End Script--
Nest Set Point Update with AppleScript
- jay (support)
- Site Admin
- Posts: 19232
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: Nest Set Point Update with AppleScript
[MODERATOR NOTE] moved to the 3rd party Nest Plugin forum.
Re: Nest Set Point Update with AppleScript
Thanks Jay - I'll try to help with my impressive zero knowledge of Applescript loljay (support) wrote:[MODERATOR NOTE] moved to the 3rd party Nest Plugin forum.
Anyway - sorry for the delay in replying it's been a busy few days....
I'd check out this post where Jay explained the use of AppleScript and Thermostats - it seemed quite good to me and gave me a starting point to explore your issue
http://forums.indigodomo.com/viewtopic.php?t=7934&f=4
I also answered a similar question for another user who was trying to do the same thing and he got it to work this way...
http://forums.indigodomo.com/viewtopic. ... 359#p98838
Still rather than just giving you links I had a go with my limited knowledge of AppleScript I got this to work:
Code: Select all
set currentHeatPoint to heat setpoint of device "Family Room"
set heatSet to value of variable "NESTTemp"
set heat setpoint of device "Family Room" to heatSet
set newHeatPoint to heat setpoint of device "Family Room"
if newHeatPoint * 1.0 = heatSet * 1.0 then
log "The Device Heat Point Is " & newHeatPoint & " The Variable Heat Point Is " & heatSet as text
else
log "The Device Heat Point Is " & newHeatPoint & " AND DOESN'T Equal The Variable Heat Point Which Is " & heatSet as text
end if- 1. I didn't use the integer part of the command because the NEST API uses float most of the time and I suspect that isn't helping
2. I used (variable*1.0) instead of just variable to make sure that we're comparing one float (x.x) with another
3. The NEST Home will update the Setpoint on the next refresh of the API using this approach. That means that a delay of 5 seconds may or may not be enough for the change to occur and so the result of the condition at the end may or may not be true depending on how long it takes for the refresh to happen. That's one of the issues using the NEST API because they don't like you calling the API more than once a min. In the actual plugin I force an update so the change appears to happen a lot quicker!
Hope that helps
Mike