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

i have installed the plugin and added my email address and password. but all i get is 'account connected' no temp readings and no way to change temp??

Link to comment
Share on other sites

  • 0

Hi All,

 

I have Nest thermostat V2 and have the same issue, it is not updating the temperature and humidity. I came across this topic 

Please login or register to see this link.

 and it using a different  approach by using ifttt.   But I agree it should be nice if they can fix it or have a workaround.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • I made a scene by using the NEST API to read the temperature and humidity every 60 seconds and a VD puts the temp in the official NEST Plugin temperature VD value and the humidity in the official NEST Plugin humidity VD value.

    Off course if you want to do this, you have to get a NEST developer account, but it's free.

     

    So I'm happy for the moment

    Please login or register to see this image.

    /emoticons/default_icon_smile.gif" alt=":-)" />

    Link to comment
    Share on other sites

    • 0

    I made a scene by using the NEST API to read the temperature and humidity every 60 seconds and a VD puts the temp in the official NEST Plugin temperature VD value and the humidity in the official NEST Plugin humidity VD value.

    Off course if you want to do this, you have to get a NEST developer account, but it's free.

    So I'm happy for the moment

    Please login or register to see this image.

    /emoticons/default_icon_smile.gif" alt=":-)" />

    Can you share your code?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Sure, but remember, the API has you go through a few stages, so the code is kind of "incomplete" when you use it like this.

     

    First, get a developer account from NEST.

    Then you get a "ProductID" and a "Product Secret" and an "Authorization URL"

     

    Then you can use that data to get a PIN code.

     

    Using that PIN code, I got an "access_token" (which apparently lasts 10 years)

     

    You can find all the steps here: 

    Please login or register to see this link.

     

    This is the code for the scene. The URL I use is the one I got from a "307" explained here: 

    Please login or register to see this link.

    The scene fills up two global variables, which a VD uses to write the values of the NEST temp ... and the NEST humidity ...

    Please login or register to see this code.

    The VD (ID 123) has just 2 labels to show the temp and humidity and a main loop putting that data where I want it (the official NEST temperature VD (ID 112) and the official NEST humidity VD (ID 113)).

    Please login or register to see this code.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • I think so, the LUA VD's only with the Home Center 2.

     

    I would really recommend everyone with a Home Center 2 and a NEST thermostat to get a NEST developer account and use it with some VD's. By now, I use my motion sensors placed all over the house to set my NEST thermostat to away or home if there hasn't been any movement anywhere for about 30 minutes. With your own VD's and scenes you can do anything you want with your NEST thermostat (I have). At least once you have a token following the NEST API documentation.

     

    The only reason I still have the official plugin is because the VD's register correctly as temperature and humidity sensor. All other actions work perfectly fine with my own VD's and scenes. To bad the official NEST API rounds the humidity to the nearest 5%.

     

    Some code (it's not copy paste, just a way to show those who want to do it themselves how to do it

    My NEST VD (see image)

    Please login or register to see this code.

    My NEST refresh scene

    Please login or register to see this code.

    Scene to set NEST away (home is the same, only data = '{"away": "home"})

    Please login or register to see this code.

    Hope this helps someone trying to integrate their NEST thermostat into Fibaro Home Center 2.

    Happy to help.

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • That's not going to work.

     

    For the entire thing to work you need global variables, scenes and a VD and you need your own access token from your own NEST API account.

    Like I said it's not going to be copy paste or import... .

     

    You need to make this yourself I'm afraid.

    Link to comment
    Share on other sites

    • 0

    In the refresh scene on line 24 i get this error "[DEBUG] 11:22:19: [1;31m2016-10-14 11:22:19.532417 [ fatal] LUA error: /opt/fibaro/scenes/693.lua:24: attempt to index global 'result' (a nil value)"

     

    local temp = result["devices"]["thermostats"]["RgGratwwY3gjyxxxxxxxxxx"]["ambient_temperature_c"]

     

    what´s wrong?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • add a line to check if your request was accepted after the success = function(status). Like this:

     

    Please login or register to see this code.

     The line printed should be the status of your request. If it's not 200, then something is wrong. Try that.

    Link to comment
    Share on other sites

    • 0

    ok, mow i think it works (the scene). I get now no error.

    Can you make a screen of your VD (advanced).

    Has got the device 6 Labels, or 6 buttons?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Oh, great that it's working. All global variables are getting the correct values ? So you're not as stupid as you thought (your words, not mine :-P :-) ).

    It has 6 labels.

    see screens

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0

    hi

    im struggling a bit with this:

    here is my error message i get:

     

     

    [DEBUG] 16:58:47: [1;31m2016-10-14 16:58:47.827353 [ fatal] LUA error: /opt/fibaro/scenes/84.lua:25: attempt to index global 'result' (a nil value)

     

    any thoughts please?

     

    also i did the print(status.status) check and the avlue returned was 307

    i have (i think) put the correct URL in

     

    Please login or register to see this link.

    Edited by morpheus75
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Ah, good, glad that it's working.

     

    @ morpheus75

    The 307 ... . Actually, the correct URL is 

    Please login or register to see this link.

     , but you will probably first get a 307 to redirect you to another URL.

    The correct coding will probably be, try official URL and if returned status is 307, then use the redirect URL it provides.

    U just always use the redirect URL, because it hasen't given me any problems YET.

     

    So if you get a 307, it will be accompanied by the redirect URL, like this:

    Please login or register to see this code.

    From that moment on, you should use the new URL and port.

    Link to comment
    Share on other sites

    • 0

    hi 

    thanks for prompt reply

    i put the original URL in and i get the 307 error but with no additional extra info

    i am just trying using POSTMAN but getting authorisation errors so maybe i have made a mistake somewhere.

    Also under Product Details in the Nest Developer site do i need to do anything re Reviews and Nest Store?

    cheers mate

    Link to comment
    Share on other sites

    • 0

    @TW1979

    I have got another problem. Maybe you can help me.

    My Google Nest Thermostat is not in Room Living Room it is ca. 4 meters away from it. In the Living Room i have got a netatmo indoor sensor with the id 958.

    Now if i set the nest on 22 C°, the room has got 22 C° but the nest thermostat shows 20 C° because it is to far away. I have got an underfloor heating an the nest heat link control a fibaro relai with the id 945. The fibaro relai control the setting-drive.

    How can i compare the set point from the nest with the netatmo indoor sensor? If the netatmo indoor sensor has got the same or more temperature how the nest thermostat, they should to take the fibaro relai off. If the temperatur under the set point from the nest it takes the fibaro relai on.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • @morpheus75

    I didn't do anything with the Reviews and Nest Store, probably only if you want to really spread the app. To get the 307 URL, You could do something like print(status.headers.Location). If everything else was OK, then that should be the redirect URL.

     

    @malzbier

    You have the nest Setpoint and the netatmo temperature, so, it shouldn't be to hard. Have to think about it a bit, but wanted to answer morpheus75 :-)

     

    Link to comment
    Share on other sites

    • 0

    @morpheus75

    you make a developer account. After this you make a product. If you created an product, you get an Authorization URL, with this URL you get an PIN Code.

    About the PIN Code you get an access token.

    Look at the link:

    Please login or register to see this link.

     

    All steps are there.....

    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...