Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Nest Thermostat v3 Fibaro Plugin not updating [Workaround found!]


TW1979

Question

Hi,
 
This is an update of the first post which now contains the workaround I created (with code found all over the net). Makes it easier to find what you are looking for when you open this thread :-).
This is more a replacement / edit for the original plugin. I still use the original Plugin, so I have a device that is registered in the system as a Thermometer and an Humidity Sensor (devices 112 and 113, whose values are updatet by the VD). For the moment, I don’t think this can be done with a VD alone.
 
Worth mentioning: don’t make too many calls in a short timeframe to the Nest API, it will just slow down everything.
I did it this way, but you can change whatever you like, this makes programming fun :-) .

Getting started: (For easy first steps to get to your access token, use something like “Postman”)

  • Get a Nest developer account. (documented here:

    Please login or register to see this link.

  • Create a new product with these permissions: 
    • Thermostat read/write v6 (if your Nest thermostat is running the most recent version)
    • Away read/write v2
    • You will eventually get
      • A Product ID
      • A Product Secret
      • An Authorization URL
    • You will get a PIN code when you follow all steps
    • You will eventually get an access token, which is what we’ll be using for everything else ;-)
  • Use your access token to get your ID’s
    • Do a GET to

      Please login or register to see this link.

      using something like Postman (I did it using Fibaro scenes, but Postman is easier).
      • You have to set the Headers
        • “Authorization” with “Bearer <<your access token>>”
        • “Content-Type” “application/json”
    • This will give you all the data you want, including your thermostat(s) ID(s) and your structures ID(s)

I made these Global variables:

  • NESTawaytemp
  • NESThome
  • NESThumidity
  • NESTnewTemp
  • NESTstate
  • NESTtarget
  • NESTtargeteta
  • NESTtemp

I made a VD with some labels and buttons. I also did a VD with a slider to set the temperature, but that didn’t work the way I wanted it to. The slider is always 0 - 100. I edited it to be able to choose a temperature between 10°C and 30°C, but when you move the slider, the value isn’t visible “on the fly”. Changes to the slider are only possible with reload of page, for as far as I know. The new temperature did come in a label, but I found it to sluggish to use. Look at the attached images for more info.
 
The main loop for the VD (I like "," as decimal seperator, not ".", you can delete all that off course):

Please login or register to see this code.

The code for my button Temp +

Please login or register to see this code.

The code for button Temp -

Please login or register to see this code.

The code for button "Instellen" (you eventually have to push that button, to set Nest to your new wanted temp, I did this to limit the API calls) Scene 66 will follow

Please login or register to see this code.

The other buttons are readable in the images.

The Nest Refresh scene, which updates the global variables. Runs once a minute, don’t run it too fast. Just change the << >> values to your own. 

Please login or register to see this code.

The Scene to set Nest to "Home" (scene 65)

Please login or register to see this code.

The scene to set Nest "Away" or "Eco" (scene 64)

Please login or register to see this code.

The scene that sets the new temperature to Nest (scene 66)

Please login or register to see this code.

Hope some more people can be helped by this :-)

 

Please login or register to see this attachment.

Please login or register to see this attachment.

Please login or register to see this attachment.

Please login or register to see this attachment.

Please login or register to see this attachment.

Please login or register to see this attachment.

Please login or register to see this attachment.

Please login or register to see this attachment.

Edited by TW1979
New first post
Link to comment
Share on other sites

Recommended Posts

  • 0

hi

all working now.

thanks

 

I re-did the whole process and this time got it right.

 

I used POSTMAN to get the NEST id as there was no mention of how to get the ID in the quick guide unless i missed it somewhere?

 

anyway thanks guys for your help

Link to comment
Share on other sites

  • 0
  • Inquirer
  • @malzbier

     

    Something like this might work, but if your Heat-Link also switches your relay, I'm not entirely sure what can go wrong.

    Scene:

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    • 0

    --[[
    %% properties
    958 value
    %% globals
    --]]

    local NestSP = fibaro:getGlobalValue("NESTtargetWHZ") --assuming that is what you call your NEST setpoint
    if (tonumber(fibaro:getValue(958, "value") >= (NestSP - 2))) then
        fibaro:call(945,"turnOff")
    else
        fibaro:call(945,"turnOn")
    end
     

     

    i get an error "[DEBUG] 19:36:31: line 8: attempt to compare number with string"

    Link to comment
    Share on other sites

    • 0

    hi

    i think you need to do the following change only

     

    local NestSP = tonumber(fibaro:getGlobalValue("NESTtargetWHZ"))

    as you were trying a mathematical sum on a string value

    Link to comment
    Share on other sites

    • 0

    ive just tried this and it worked....

     

    Please login or register to see this code.

     

    the response is here:

     

    [DEBUG] 19:09:15: 21 variable temp
    [DEBUG] 19:09:15: 24.5
    [DEBUG] 19:09:15: yes

     

     

    i think you may too many close brackets when you did the 'if' statement

    Edited by morpheus75
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Hey, small update handling the 307, because sometimes the scene stops because there is another redirect.

     

    Please login or register to see this code.

     

    Edited by TW1979
    first post was a question :-), so no update
    Link to comment
    Share on other sites

    • 0

    Thanks all! this is great - got it working...

     

    Two question: 

    1) Would it be possible to change the VD to also update the temp and the setpoint at the top of the main plugin (the thing that looks like a VD without Advanced tab). Think that's what you are trying to do with the reference to device 111 at the end of your VD - however that's not working for me (potentially because that main VD has many more labels than just temp). Any idea how to do that? 

    2) Do you know whether the built-in heating panel will adjust the setpoint of the Nest as laid out in the heating panel schedule or will I need to write a separate scene for that, replicating the schedule in LUA (using similar code to the Away/Home scene above)? 

     

    Thanks again!

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • @Kfruechtl

    Glad you got it working. Been too busy lately to get to your questions., sorry.

    Question 1: yes, you can update the values in the main plugin. Needed a bit of tweaking to get it to work. The ID of my main plugin is indeed 111.

    This sets the current temperature (first it didn't work, had trouble with the ' and "):

    Please login or register to see this code.

    This evening I will try to do the rest, but, you could find it yourself, because it's exactly the same, just replace "ui.Current..." with the correct property name.

     

    Link to comment
    Share on other sites

    • 0

    @TW1979

     

    This is great piece of work - much appreciated. 

     

    I am battling with Nest's API permissions. Whilst I am able to set home/away modes I can't set anything else.

     

    Did you have to change anything else in Product details in Nest's API apart from below?

    Please login or register to see this code.

    Got it working in the end... I was using wrong link, i.e. structure instead of devices/thermostats...

    Edited by mrtn
    Link to comment
    Share on other sites

    • 0

    @TW1979 Thanks a lot! I've got it to work last night! (The refresh Scene did stop around 01:50 at night, without any Debug info, but I've restarted it and it works fine now!)

     

    On 16-10-2016 at 7:44 PM, Kfruechtl said:

    1) Would it be possible to change the VD to also update the temp and the setpoint at the top of the main plugin (the thing that looks like a VD without Advanced tab). Think that's what you are trying to do with the reference to device 111 at the end of your VD - however that's not working for me (potentially because that main VD has many more labels than just temp). Any idea how to do that? 

    2) Do you know whether the built-in heating panel will adjust the setpoint of the Nest as laid out in the heating panel schedule or will I need to write a separate scene for that, replicating the schedule in LUA (using similar code to the Away/Home scene above)?

     

    @Kfruechtl You are asking the exact same questions I'm having!

     

     

    About the Heating Panel, I have some motion detectors and Danfoss Thermostats and I would like to make this:

    Please login or register to see this code.

    When the temperature is adjusted manually (on the Danfoss Thermostat or in the Fibaro GUI) the adjustment has to stick till the HeatingPanel says otherwise.

     

    Is is possible to add this to the HeatingPanelFunctionality?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • @Sardar

    The scene sometimes stops, I don't really know why, but I made a "watchdog" scene which checks my other continuous scenes every five minutes and if one has stopped, it restarts it :).

    Looks like this: (as you can see, scene 38 is my Smappee and scene 44 is my Nest)

    Please login or register to see this code.

     

    For the other questions, I don't use the heating panel, so I really can't answer that.

    I did however use all my Fibaro Motion detectors to set Nest to away or home.

    I have a VD which shows last breached device and how long ago and if it is still breached, ... . That VD could set the Nest to home or away, but I don't use that anymore. If i leave my house, I turn on the alarm, which (among others) sets the Nest to away.

     

    Here is the VD: (to be edited off course, if you want to use it, also uses different icons, so make your own :-P)

    Please login or register to see this code.

    And here is the Nest away scene (Home is the same, only data = '{"away": "home"}' (already posted this code, but this adapts to the 307))

    Please login or register to see this code.

    Last extra: Nest is changing away to Eco and stuff, so everything might need some small changes soon (see Nest documentation).

    Please login or register to see this attachment.

    Edited by TW1979
    Made an error
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Hi all,

     

    Don't forget that Nest is changing the API a bit. 

    Please login or register to see this link.

     and 

    Please login or register to see this link.

    If you want to use the new API you have to change the permissions of your app to " Thermostat read/write v6 ".

     

    I only changed the "away_temperature_low_c" to "eco_temperature_low_c" and added the new "time_to_target" to my VD (time when target temperature is reached".

     

    Anyway, check it out and have fun!

    looks like this now :-) .

     

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0
    5 hours ago, TW1979 said:

    Hi all,

     

    Don't forget that Nest is changing the API a bit. 

    Please login or register to see this link.

     and 

    Please login or register to see this link.

    If you want to use the new API you have to change the permissions of your app to " Thermostat read/write v6 ".

     

    I only changed the "away_temperature_low_c" to "eco_temperature_low_c" and added the new "time_to_target" to my VD (time when target temperature is reached".

     

    Anyway, check it out and have fun!

    looks like this now :-) .

     

    Nice!

     

     Maybe you can substitute "verwarming"  to "state" with the options [verwarmen,eco,uit]?

     

     

     By the way, do you know if it's possible to add a drop-down menu to a VD  so that we can change the temperature in the overview. Like this:

     

     

    pS: of you don't mind me asking, what do you do dor a living?

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • I could change it to state, but I use the "hvac_state" property, which is only either "heating", "cooling" or "off". The "hvac_mode" can be "heat", "cool", "heat-cool", "eco" and "off". But I like to know whether my central heater is "burning" or not :-) .

     

    A drop-down, I doubt it, I can't find it anyway. Perhaps if we could make a plug-in, it is possible.

    Changing the temperature would be a lot easier that way. Perhaps with a slider ... . I'm going to experiment with that :-) .

     

    I don't mind you asking. I'm a IT system-engineer / support technician, so no programming really, but I do make my own IT tools in VB Net, PowerShell, C#, ... .

    You ?

    Link to comment
    Share on other sites

    • 0
    On 5-11-2016 at 2:54 PM, TW1979 said:

    I could change it to state, but I use the "hvac_state" property, which is only either "heating", "cooling" or "off". The "hvac_mode" can be "heat", "cool", "heat-cool", "eco" and "off". But I like to know whether my central heater is "burning" or not :-) .\

     

    Ahh... I understand.

     

    On 5-11-2016 at 2:54 PM, TW1979 said:

    A drop-down, I doubt it, I can't find it anyway. Perhaps if we could make a plug-in, it is possible.

    Changing the temperature would be a lot easier that way. Perhaps with a slider ... . I'm going to experiment with that :-) .

     

    I haven't seen it before either... But keep us posted... :)

     

    On 5-11-2016 at 2:54 PM, TW1979 said:

    I don't mind you asking. I'm a IT system-engineer / support technician, so no programming really, but I do make my own IT tools in VB Net, PowerShell, C#, ... .

    You ?

    I'm a simple Locksmith [

    Please login or register to see this link.

    working on a new website

    Please login or register to see this link.

    ]

    But I've finished IT (Human Computer Interaction) at the University of Amsterdam. So ten years ago I learned C, C++, a bit of java and so some of the programming stuck..... So now I'm planning to code

    Please login or register to see this link.

    , which shouldn't be that hard... Just hope it's gonna work

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • @Sardar

    The slider thing didn't work the way I liked it.

    I changed first post to my most recent code (It says to do so in the Fibaro Forum rules :-) )

     

    I hope others can help you with your other plan in the other thread.

    Link to comment
    Share on other sites

    • 0
    On 10-11-2016 at 8:47 AM, TW1979 said:

    @Sardar

    I changed first post to my most recent code (It says to do so in the Fibaro Forum rules :-) )

     

    Thanks again for all your effort! I've run you scripts for a few days now.

     

    I've tried your new code from the first post but I get a " Number of instances of scene has been reduced due to high memory usage. "-message from Fibaro for all scene. I've added a 0 to all the sleeps and time-out's, but I still directly get the same message when I press "start".

     

    I've set the scene's to:

    Max. Running instances: 1

    Run Scene: Automatic

     

    I've done a complete reset, these are the only scene's I'm running and I got about 9 devices coupled.

     

    Any ideas?

     

    Never mind, solved with reboot

    Edited by Sardar
    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...