NEST Account migration

For heating/cooling related questions in Domoticz

Moderator: leecollings

Post Reply
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: NEST Account migration

Post by rolandbreedveld »

as requested by @Marcello1970 :

a new version 1.03, with a bugfix and support for both Away and ECO mode,
- nest_auth.php is renamed to nest_auth.php-example, so it won't overwrite your file.
- idx and devices are moved from the get_nest.sh script to a config file: nest_devices.cfg
- delivered as nest_devices.cfg-example, so it won't overwrite your file.

so if you want it, create a extra virtual device for the away-mode (see README.md)
important: before installing,write down the idx numbers from your current get_nest.sh
rename nest_devices.cfg-example to nest_devices.cfg, and change the IDX numbers to yours.
suc6!
Attachments
nest-api.tgz
(241.96 KiB) Downloaded 78 times
Last edited by rolandbreedveld on Monday 27 January 2020 11:24, edited 1 time in total.
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
Marcello1970
Posts: 9
Joined: Thursday 20 March 2014 15:33
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Hasselt, The Netherlands
Contact:

Re: NEST Account migration

Post by Marcello1970 »

Ho Roland,

I have tested the new version, there are some strange thinks.

The set / unset ECO mode command works, but I get a error message:

Code: Select all

PHP Warning:  file_put_contents(/tmp/nest_php_cache_9585540375c319a527bcca3b68e07fe2): failed to open stream: Permission denied in /home/pi/nest-api/nest.class.php on line 1191
bool(true)
The set / unset Away mode works strange and I get the same error message as above.
When I excute the command set Away mode, the ECO get set instead.
When I excute the command unset Away mode, the ECO gets unset, but the Away mode get set or stays set.
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: NEST Account migration

Post by rolandbreedveld »

Marcello1970 wrote: Sunday 26 January 2020 16:26 Ho Roland,

I have tested the new version, there are some strange thinks.

The set / unset ECO mode command works, but I get a error message:

Code: Select all

PHP Warning:  file_put_contents(/tmp/nest_php_cache_9585540375c319a527bcca3b68e07fe2): failed to open stream: Permission denied in /home/pi/nest-api/nest.class.php on line 1191
bool(true)
The set / unset Away mode works strange and I get the same error message as above.
When I excute the command set Away mode, the ECO get set instead.
When I excute the command unset Away mode, the ECO gets unset, but the Away mode get set or stays set.
looks like the file /tmp/nest_php_cache_9585540375c319a527bcca3b68e07fe2 is not allowed, is it possible you run it 1st as root and after that with another user?
remove it rm -rf /tmp/nest_php*, and try it again ?
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
Marcello1970
Posts: 9
Joined: Thursday 20 March 2014 15:33
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Hasselt, The Netherlands
Contact:

Re: NEST Account migration

Post by Marcello1970 »

rolandbreedveld wrote: Sunday 26 January 2020 16:32 looks like the file /tmp/nest_php_cache_9585540375c319a527bcca3b68e07fe2 is not allowed, is it possible you run it 1st as root and after that with another user?
remove it rm -rf /tmp/nest_php*, and try it again ?
With user root it's works all fine.
After that with the normal user (pi) I get a double error message and strange behavior.

Code: Select all

PHP Warning:  file_put_contents(/tmp/nest_php_cache_9585540375c319a527bcca3b68e07fe2): failed to open stream: Permission denied in /home/pi/nest-api/nest.class.php on line 1191
Setting away mode...
PHP Warning:  file_put_contents(/tmp/nest_php_cache_9585540375c319a527bcca3b68e07fe2): failed to open stream: Permission denied in /home/pi/nest-api/nest.class.php on line 1191
bool(true)
When I remove the two nest.php files, I get only one error message.

Code: Select all

PHP Warning:  file_put_contents(/tmp/nest_php_cache_9585540375c319a527bcca3b68e07fe2): failed to open stream: Permission denied in /home/pi/nest-api/nest.class.php on line 1191
extra:
I have manually extend the user user rights of the two files in the temp map and now the normal user also works also good.
Quiphainyr
Posts: 2
Joined: Monday 06 January 2020 22:06
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NEST Account migration

Post by Quiphainyr »

@rolandbreedveld
Man, you're a hero! I got my Nest Thermostat working in Domoticz again after migrating to a Google account :)
One question though... Do you have to update the cookie and issuetoken often in order to keep it running?

Many thanks for all your effort! Cheers!
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: NEST Account migration

Post by rolandbreedveld »

Quiphainyr wrote: Sunday 26 January 2020 18:07 @rolandbreedveld
Man, you're a hero! I got my Nest Thermostat working in Domoticz again after migrating to a Google account :)
One question though... Do you have to update the cookie and issuetoken often in order to keep it running?

Many thanks for all your effort! Cheers!
I never had to change it, I think when it runs frequently, it won't be an issue.
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
Quiphainyr
Posts: 2
Joined: Monday 06 January 2020 22:06
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NEST Account migration

Post by Quiphainyr »

rolandbreedveld wrote: Monday 27 January 2020 11:21 I never had to change it, I think when it runs frequently, it won't be an issue.
Awesome! So far everything works again. Really happy! Thanks again!
romain1206
Posts: 2
Joined: Thursday 05 December 2019 14:54
Target OS: Linux
Domoticz version:
Contact:

Re: NEST Account migration

Post by romain1206 »

hello

it's possible to have the same device for the Temp + Humidity (WTGR800)

many thanks
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: NEST Account migration

Post by rolandbreedveld »

romain1206 wrote: Monday 27 January 2020 22:53 hello

it's possible to have the same device for the Temp + Humidity (WTGR800)

many thanks
I don't know which one is the WTGR800, but if you create a virtual device "Tem+Hum", it will create a "THGN122/123/132, THGR122/228/238/268"

actually I think you'r request is more elegant than my 2 different sensors, so thanxz for the idea romain1206

I added it to the script, both solutions are possible,
add the virtual "Temp+Hum" device,
add "TEMPHUM 511" (with your IDX) to nest_devices.cfg
you can use them both, or if you don't, remove or place a # for the lines you don't use.

good luck
Attachments
nest-api_104.tgz
(242.19 KiB) Downloaded 85 times
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
joost81
Posts: 4
Joined: Wednesday 22 July 2015 12:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NEST Account migration

Post by joost81 »

Awesome! Took some time, but I got it to work perferctly! Thanks

Please not that you'll need to install php 7.3 on Raspbian Buster
blackie
Posts: 5
Joined: Tuesday 19 November 2019 14:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NEST Account migration

Post by blackie »

Thank you guys for this solution,
I have finally decided to migrate my account, but have a mixed result.
UPDATED:
Configuration went OK, SetPoint and Temp/Humi devices are working - status updates via cron job, but HEAT switch doesn't work.
My nest-api directory path is a bit different from default, but was updated in all files according to README.

Domoticz Nest devices are:
105 Dummy Nest_TempHumi Temp + Humidity THGN122/123/132, THGR122/228/238/268
106 Dummy Nest_SetPoint Thermostat SetPoint
107 Dummy Nest_ECO Light/Switch Switch Off - -
108 Dummy Nest_Away Light/Switch Switch Closed - -
109 Dummy Nest_Heating Light/Switch Switch Off - -
110 Dummy Nest_Protect Light/Switch Switch Off - -

file nest_devices.cfg was updated with correct device_idx codes:
Device idx
============
SETPOINT 106
AWAYMODE 108
ECOMODE 107
HEAT 109
TEMPHUM 105
PROTECT 110

OS is Raspbian Stretch from OpenMediaVault 4.1 with php 7.0.33 that resists to upgrade to 7.3.
Any suggestions where the HEAT switch problem reason could be?
What about Nest Protect sensor, is it supported in nest_devices.cfg via some code (PROTECT, or else)?

Thanks in advance
P.S. Away and ECO switches started to work after I changed Away switch type from "Door contact" to "On/Off" (used "Door contact" before because of icon). But HEATING switch still refuses to update it's status from Nest or control heating (switch type is "On/Off" and nest_devices.cfg line is "HEAT 109")...
Joncho
Posts: 2
Joined: Thursday 14 November 2019 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Netherlands
Contact:

Re: NEST Account migration

Post by Joncho »

Thanks Roland, took the leap and managed to get it to work.

It took some time, because I hadn't added 127.0.0.* to the whitelist in the Domoticz settings, just my local network 192.168.1.*. Before adding the local IP, I could only set temperature, Away and Eco Mode and couldn't get the status of the Nest hardware.
Cloudwraith
Posts: 6
Joined: Thursday 08 March 2018 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NEST Account migration

Post by Cloudwraith »

So, after a bit of work, I too have this working with my Nest Gen2.

One issue I ran into was that, here in the USA, my temperatures are in F. Domoticz is set to show my units in F. I'm not sure if the issue is with Domoticz or the updating script (get_nest.sh) but my nest returns a F number and the script passes this on to Domoticz which then assumes this is a C number and converts it to F leaving me with something like 160F for a room temperature.

I solved this temporarily by converting the F number received from the Nest to C in the get_nest.sh script before it updates Domoticz.

You should install bc (sudo apt-get install bc) if you don't have it installed as bc will help with fractional numbers.

Clearly I'm not the best bash script writer in the world and this is admittedly a complete hack but it got the job done for me and may help others.

Line 88 of get_nest.sh

Code: Select all

  if [ ! -z "${IDX}" ]
  then
    if [ "${TYPE}" == "TEMP" ]
    then
      VALC=$(echo "scale=2;(5/9)*($VALUE-32)"|bc)
      curl -X GET "http://127.0.0.1:8080/json.htm?type=command&param=udevice&idx=${IDX}&nvalue=0&svalue=${VALC}" >/dev/null 2>&1
      echo "Update ${TYPE} to $VALC"
    fi
This only changes the value for Temperature, not the setpoint or temp+humid. I did notice that get_nest.php returns a "Scale" parameter. Perhaps the original author could check this value and, if F, convert all numbers to C before updating Domoticz. If the value is C then just send the numbers as is.
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: NEST Account migration

Post by rolandbreedveld »

blackie wrote: Friday 31 January 2020 16:59 Any suggestions where the HEAT switch problem reason could be?
What about Nest Protect sensor, is it supported in nest_devices.cfg via some code (PROTECT, or else)?
Heat wasn't updated, a bug, enclosed the fix

PROTECT can be added, if it gives no output from my account
please do:
php nest-api.php
if it's correct it should give more info than on my account:

Devices list (Nest Protect):
[]
Attachments
nest-api_105.tgz
(239.46 KiB) Downloaded 46 times
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: NEST Account migration

Post by rolandbreedveld »

Cloudwraith wrote: Thursday 06 February 2020 3:52 One issue I ran into was that, here in the USA, my temperatures are in F. Domoticz is set to show my units in F. I'm not sure if the issue is with Domoticz or the updating script (get_nest.sh) but my nest returns a F number and the script passes this on to Domoticz which then assumes this is a C number and converts it to F leaving me with something like 160F for a room temperature.
Never understand why you US-people use Fahrenheit and inches .... ;)
so if you use temp+hum, and not separate devices it works without modifications?
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: NEST Account migration

Post by rolandbreedveld »

cause of changes, bugfixes, and user requests, my nest-api scripts are on github now:

https://github.com/rolandbreedveld/nest-api
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
Cloudwraith
Posts: 6
Joined: Thursday 08 March 2018 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NEST Account migration

Post by Cloudwraith »

rolandbreedveld wrote: Friday 07 February 2020 15:21 so if you use temp+hum, and not separate devices it works without modifications?
No, I just didn't modify the temp+humid part of the script. I use Temp and Humidity separately so for me, just modifying the temp was enough for a quick fix. I guess the best thing to do would be to check the scale returned from the nest and modify all temps to C (if the scale is F) before sending on to domoticz.
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: NEST Account migration

Post by rolandbreedveld »

Cloudwraith wrote: Friday 07 February 2020 17:14
rolandbreedveld wrote: Friday 07 February 2020 15:21 so if you use temp+hum, and not separate devices it works without modifications?
No, I just didn't modify the temp+humid part of the script. I use Temp and Humidity separately so for me, just modifying the temp was enough for a quick fix. I guess the best thing to do would be to check the scale returned from the nest and modify all temps to C (if the scale is F) before sending on to domoticz.
I can change it in the code, wit a setting parameter, if you like
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
blackie
Posts: 5
Joined: Tuesday 19 November 2019 14:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NEST Account migration

Post by blackie »

rolandbreedveld wrote: Friday 07 February 2020 15:07
blackie wrote: Friday 31 January 2020 16:59 Any suggestions where the HEAT switch problem reason could be?
What about Nest Protect sensor, is it supported in nest_devices.cfg via some code (PROTECT, or else)?
Heat wasn't updated, a bug, enclosed the fix

PROTECT can be added, if it gives no output from my account
please do:
php nest-api.php
if it's correct it should give more info than on my account:

Devices list (Nest Protect):
[]
Thank you Roland for the fix, Heating switch is working fine in the latest version.
If I run "php get_nest.php" I can see device ID for my Nest Protect device in the output:
Devices list (Nest Protect):
[
"06?????????????"
]
But there is no section "Device information" for Protect device like there is for Thermostat device...
I can't test the protect sensor switch in Domoticz right now but I plan to do it later.
Thanks a lot for your good work
jeroenkl
Posts: 113
Joined: Sunday 14 July 2013 22:00
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: NL
Contact:

Re: NEST Account migration

Post by jeroenkl »

Hmmm need help,
This is what I get:

pi@raspberrypi:~/nest-api $ ./get_nest.sh
PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /home/pi/nest-api/nest.class.php:1256
Stack trace:
#0 /home/pi/nest-api/nest.class.php(1224): Nest->doRequest('GET', 'https://account...', NULL, true, Array)
#1 /home/pi/nest-api/nest.class.php(1089): Nest->doGET('https://account...', Array)
#2 /home/pi/nest-api/nest.class.php(124): Nest->login()
#3 /home/pi/nest-api/get_nest.php(19): Nest->__construct(NULL, NULL, 'https://account...', 'OCAK=xxxxxxxx..')
#4 {main}
thrown in /home/pi/nest-api/nest.class.php on line 1256

thanks in advance.

Jeroen
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest