FilipDem / Domoticz-NEST-plugin

NEST Plugin for Domoticz using the Google credentials.
13 stars 4 forks source link

Every hour 401 error #24

Closed jvberlo closed 3 years ago

jvberlo commented 3 years ago

Every hour i see a error message in the domoticz log any idea on how to fix this?

Logging 2021-04-06 10:44:37.002 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-06 10:44:37.053 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-06 10:44:37.053 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-06 10:44:37.053 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 270.0 seconds to update devices 2021-04-06 10:44:47.021 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-06 10:44:47.071 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-06 10:44:47.072 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-06 10:44:47.072 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 260.0 seconds to update devices 2021-04-06 10:44:57.039 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-06 10:44:57.089 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-06 10:44:57.089 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-06 10:44:57.090 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 250.0 seconds to update devices 2021-04-06 10:45:07.015 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-06 10:45:07.065 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-06 10:45:07.065 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-06 10:45:07.068 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 240.0 seconds to update devices 2021-04-06 10:45:17.024 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-06 10:45:17.075 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-06 10:45:17.075 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-06 10:45:17.075 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 230.0 seconds to update devices 2021-04-06 10:45:27.043 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-06 10:45:27.096 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-06 10:45:27.096 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-06 10:45:27.097 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 220.0 seconds to update devices

Error Logging. 2021-04-06 05:53:29.567 Error: Nest Thermostaat plugin: (Nest Thermostaat plugin) API response status code 401 2021-04-06 06:58:29.561 Error: Nest Thermostaat plugin: (Nest Thermostaat plugin) API response status code 401 2021-04-06 08:03:29.587 Error: Nest Thermostaat plugin: (Nest Thermostaat plugin) API response status code 401 2021-04-06 09:08:29.625 Error: Nest Thermostaat plugin: (Nest Thermostaat plugin) API response status code 401 2021-04-06 10:13:29.533 Error: Nest Thermostaat plugin: (Nest Thermostaat plugin) API response status code 401

2nd thing the protect device was not created. Can this be done manual?

FilipDem commented 3 years ago

I see you activated the "debug" and your update interval is every 5 minutes... However in my opinion, there is not any update done. Could you confirm that the devices do not show the last/correct information. Normally there are messages in the logging when the update is done.

Typically a response code 401 is an authentication problem. So I think that the cookie and issue_token are not correct. You can do the test outside domoticz using the nest.py. It is explained in the readme (at the end of the section "Configuration"):

On linux:

export NEST_ISSUE_TOKEN='xxx'
export NEST_COOKIE='xxx'
python3 nest.py
jvberlo commented 3 years ago

Got nest devices 1: thermostats ['xxxxxxxxxxxxxxxxx'] - protects [] General Nest information: {'Name': 'Thuis', 'Away': False} Nest Thermostat xxxxxxxxxxxx: {'Target_temperature': 20.0, 'Current_temperature': 19.75, 'Temperature_scale': 'C', 'Humidity': 44, 'Eco': False, 'Heating': True, 'Target_mode': 'heat', 'Target_temperature_low': 20.0, 'Target_temperature_high': 24.0, 'Where': 'Living Room'} Temperature set to 20.0 Set Temperature: True Away set to False Set Away: True Eco set to mode manual-eco Set Ecomode: True Thermostat set to heat Set Thermostat heating: True All good

I can't find any error. It just generates a 401 every hour.

ridderr commented 3 years ago

Hi both Same pattern with me. I was just going to raise an issue and found someone was already before me. The update each 5 minutes works correct but every hour there is an error reported. Looks like something at nest.com ??

2021-04-07 13:23:28.930  Nest: (Nest) Debug logging mask set to: NONE
2021-04-07 14:23:37.631  Error: Nest: (Nest) API response status code 401
2021-04-07 15:24:37.592  Error: Nest: (Nest) API response status code 401
2021-04-07 16:25:37.628  Error: Nest: (Nest) API response status code 401
2021-04-07 17:26:37.595  Error: Nest: (Nest) API response status code 401
2021-04-07 18:27:37.627  Error: Nest: (Nest) API response status code 401
2021-04-07 19:28:37.618  Error: Nest: (Nest) API response status code 401
2021-04-07 20:29:37.635  Error: Nest: (Nest) API response status code 401
2021-04-07 21:30:37.554  Error: Nest: (Nest) API response status code 401
2021-04-07 22:31:37.615  Error: Nest: (Nest) API response status code 401
2021-04-07 23:32:37.614  Error: Nest: (Nest) API response status code 401
2021-04-08 00:33:37.588  Error: Nest: (Nest) API response status code 401
2021-04-08 01:34:37.597  Error: Nest: (Nest) API response status code 401
2021-04-08 02:35:37.624  Error: Nest: (Nest) API response status code 401
2021-04-08 03:36:37.608  Error: Nest: (Nest) API response status code 401
2021-04-08 04:37:37.608  Error: Nest: (Nest) API response status code 401
2021-04-08 05:38:37.605  Error: Nest: (Nest) API response status code 401
2021-04-08 06:28:39.322  Error: Nest: (Nest) API response status code 502
2021-04-08 06:39:37.602  Error: Nest: (Nest) API response status code 401
2021-04-08 07:40:37.600  Error: Nest: (Nest) API response status code 401
2021-04-08 08:41:37.608  Error: Nest: (Nest) API response status code 401
2021-04-08 09:42:37.602  Error: Nest: (Nest) API response status code 401
2021-04-08 10:43:37.598  Error: Nest: (Nest) API response status code 401
2021-04-08 11:44:37.603  Error: Nest: (Nest) API response status code 401
2021-04-08 12:45:37.595  Error: Nest: (Nest) API response status code 401
FilipDem commented 3 years ago

@jvberlo The fact that it works outside Domoticz means that your credentials should be OK. Very strange... In my case it works like a charm... Running already for years...

Do you have other debug messages in the status log? If not, it is the very first command that fails already... Stupid question: I suppose you entered the Cookie and the Issue_token in Hardware settings of the device, right? Domoticz don't use environment variables... Thanks to confirm.

Second info that would be interesting: when you took the cookie and issue_token from an active session (on a browser)... You did NOT logoff/logout from that session afterwards? You can close the browser, but should not logout/logoff... Could you confirm this? I think I didn't mention this specifically in the instructions...

Let me know, in the meantime I will do some code reading...

Filip

jvberlo commented 3 years ago

Hello Filip,

I did a fresh install of Domoticz beta build 13149 and added your plugin. I still the error every 1 hour and 5 minutes. The error is always exact after 65 mins. I added more logging i hope it helps to resolve the error. I replaced some text with "secret". The error message is at the end in bold.

I did not logoff from the Nest site.

2021-04-11 16:46:39.042 "target_temperature_type": "heat", 2021-04-11 16:46:39.042 "hvac_cool_x2_state": false, 2021-04-11 16:46:39.042 "hvac_alt_heat_state": false 2021-04-11 16:46:39.042 } 2021-04-11 16:46:39.042 }, 2021-04-11 16:46:39.042 { 2021-04-11 16:46:39.042 "object_key": "structure.14669073-5710-11e9-a7cb-0e482f88e506", 2021-04-11 16:46:39.042 "object_revision": 5529, 2021-04-11 16:46:39.042 "object_timestamp": 1618151378851, 2021-04-11 16:46:39.042 "value": { 2021-04-11 16:46:39.042 "swarm": [ 2021-04-11 16:46:39.042 "device.09AA01AC25170MVM" 2021-04-11 16:46:39.042 ], 2021-04-11 16:46:39.042 "manual_away_timestamp": 1578647, 2021-04-11 16:46:39.042 "geofence_enhanced_autoaway": { 2021-04-11 16:46:39.042 "enabled": false, 2021-04-11 16:46:39.042 "is_set": true 2021-04-11 16:46:39.042 }, 2021-04-11 16:46:39.042 "city": "Secret", 2021-04-11 16:46:39.042 "name": "Secret", 2021-04-11 16:46:39.042 "eta_preconditioning_active": false, 2021-04-11 16:46:39.042 "creation_time": 1554406218488, 2021-04-11 16:46:39.042 "location": "Secret, Overste", 2021-04-11 16:46:39.042 "touched_by": { 2021-04-11 16:46:39.042 "touched_by": 1, 2021-04-11 16:46:39.042 "touched_id": "", 2021-04-11 16:46:39.042 "touched_user_id": "" 2021-04-11 16:46:39.042 }, 2021-04-11 16:46:39.042 "measurement_scale": "metric", 2021-04-11 16:46:39.042 "away_timestamp": 1617958711, 2021-04-11 16:46:39.042 "structure_area": 175.0, 2021-04-11 16:46:39.042 "topaz_hush_key": "xXLGmJ7MLAGz3/wA6CwMvw==", 2021-04-11 16:46:39.042 "enable_goose": false, 2021-04-11 16:46:39.042 "away_setter": 1, 2021-04-11 16:46:39.042 "phone_hush_enable": true, 2021-04-11 16:46:39.042 "hvac_safety_shutoff_enabled": true, 2021-04-11 16:46:39.042 "house_type": "family", 2021-04-11 16:46:39.042 "demand_charge_enabled": true, 2021-04-11 16:46:39.042 "rcs_sensor_swarm": [], 2021-04-11 16:46:39.042 "topaz_enhanced_auto_away_enabled": false, 2021-04-11 16:46:39.042 "address_lines": [ 2021-04-11 16:46:39.042 "Secret", 2021-04-11 16:46:39.042 "" 2021-04-11 16:46:39.042 ], 2021-04-11 16:46:39.042 "country_code": "Secret", 2021-04-11 16:46:39.042 "hvac_smoke_safety_shutoff_enabled": false, 2021-04-11 16:46:39.042 "topaz_away": false, 2021-04-11 16:46:39.042 "tou_enabled": true, 2021-04-11 16:46:39.042 "renovation_date": "1980", 2021-04-11 16:46:39.042 "vacation_mode": false, 2021-04-11 16:46:39.042 "fabric_ids": [], 2021-04-11 16:46:39.042 "postal_code": "Secret", 2021-04-11 16:46:39.042 "num_thermostats": "1", 2021-04-11 16:46:39.042 "entitlements": {}, 2021-04-11 16:46:39.042 "dr_reminder_enabled": true, 2021-04-11 16:46:39.042 "members": [ 2021-04-11 16:46:39.042 { 2021-04-11 16:46:39.042 "user": "user.14316972", 2021-04-11 16:46:39.042 "roles": [ 2021-04-11 16:46:39.042 "owner" 2021-04-11 16:46:39.042 ] 2021-04-11 16:46:39.042 } 2021-04-11 16:46:39.042 ], 2021-04-11 16:46:39.042 "manual_eco_all": false, 2021-04-11 16:46:39.042 "goose_sensor_events_enabled": true, 2021-04-11 16:46:39.042 "time_zone": "Europe/Amsterdam", 2021-04-11 16:46:39.042 "user": "user.14316972", 2021-04-11 16:46:39.042 "clutches": [], 2021-04-11 16:46:39.042 "away": false, 2021-04-11 16:46:39.042 "devices": [ 2021-04-11 16:46:39.042 "device.09AA01AC25170MVM" 2021-04-11 16:46:39.042 ] 2021-04-11 16:46:39.042 } 2021-04-11 16:46:39.042 } 2021-04-11 16:46:39.042 ], 2021-04-11 16:46:39.042 "service_urls": { 2021-04-11 16:46:39.042 "urls": { 2021-04-11 16:46:39.042 "rubyapi_url": "https://home.nest.com/", 2021-04-11 16:46:39.042 "czfe_url": "https://czfe68-front01-iad01.transport.home.nest.com", 2021-04-11 16:46:39.042 "log_upload_url": "https://logsink.home.nest.com/upload/user", 2021-04-11 16:46:39.042 "transport_url": "https://czfe68-front01-iad01.transport.home.nest.com", 2021-04-11 16:46:39.042 "weather_ur 2021-04-11 16:46:39.042 Nest Thermostaat plugin: (Nest Thermostaat plugin) >> l": "https://apps-weather.nest.com/weather/v1?query=", 2021-04-11 16:46:39.042 "support_url": "https://nest.secure.force.com/support/webapp?", 2021-04-11 16:46:39.042 "direct_transport_url": "https://transport02-rts05-iad01.transport.home.nest.com:443" 2021-04-11 16:46:39.042 }, 2021-04-11 16:46:39.042 "limits": { 2021-04-11 16:46:39.042 "thermostats_per_structure": 20, 2021-04-11 16:46:39.042 "structures": 5, 2021-04-11 16:46:39.042 "smoke_detectors_per_structure": 18, 2021-04-11 16:46:39.042 "smoke_detectors": 54, 2021-04-11 16:46:39.042 "thermostats": 60 2021-04-11 16:46:39.042 }, 2021-04-11 16:46:39.042 "weave": { 2021-04-11 16:46:39.042 "service_config": "Secret” 2021-04-11 16:46:39.042 "pairing_token": "Secret” 2021-04-11 16:46:39.042 "access_token": "Secret” 2021-04-11 16:46:39.042 } 2021-04-11 16:46:39.042 }, 2021-04-11 16:46:39.042 "weather_for_structures": { 2021-04-11 16:46:39.042 "structure.14669073-5710-11e9-a7cb-0e482f88e506": { 2021-04-11 16:46:39.042 "current": { 2021-04-11 16:46:39.042 "icon": "mostlycloudy", 2021-04-11 16:46:39.042 "temp_c": "7.2", 2021-04-11 16:46:39.042 "sunrise": "1618116480", 2021-04-11 16:46:39.042 "sunset": "1618165560" 2021-04-11 16:46:39.042 }, 2021-04-11 16:46:39.042 "location": { 2021-04-11 16:46:39.042 "city": "Secret", 2021-04-11 16:46:39.042 "state": "Secret", 2021-04-11 16:46:39.042 "zip": "Secret", 2021-04-11 16:46:39.042 "country": "Secret" 2021-04-11 16:46:39.042 } 2021-04-11 16:46:39.042 } 2021-04-11 16:46:39.042 }, 2021-04-11 16:46:39.042 "2fa_enabled": true 2021-04-11 16:46:39.042 } 2021-04-11 16:46:39.043 Nest Thermostaat plugin: (Nest Thermostaat plugin) >> Got nest devices 1: thermostats ['09AA01AC25170MVM'] - protects [] 2021-04-11 16:46:39.043 Nest Thermostaat plugin: (Nest Thermostaat plugin) > Exit update thread 2021-04-11 16:46:48.024 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:46:48.075 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:46:48.075 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:46:48.080 Nest Thermostaat plugin: (Nest Thermostaat plugin) > {"Target_temperature": 20.0, "Current_temperature": 20.23999, "Temperature_scale": "C", "Humidity": 50, "Eco": false, "Heating": false, "Target_mode": "heat", "Target_temperature_low": 20.0, "Target_temperature_high": 24.0, "Where": "Living Room"} 2021-04-11 16:46:48.086 Nest Thermostaat plugin: (Nest Thermostaat plugin) > {"Name": "Thuis", "Away": false} 2021-04-11 16:46:48.088 Nest Thermostaat plugin: (Nest Thermostaat plugin) Updated 5 units for 1 device(s) 2021-04-11 16:46:48.088 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 290.0 seconds to update devices 2021-04-11 16:46:58.234 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:46:58.285 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:46:58.285 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:46:58.285 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 280.0 seconds to update devices 2021-04-11 16:47:08.006 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:47:08.057 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:47:08.057 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:47:08.057 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 270.0 seconds to update devices 2021-04-11 16:47:18.013 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:47:18.064 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:47:18.064 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:47:18.065 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 260.0 seconds to update devices 2021-04-11 16:47:28.254 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:47:28.304 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:47:28.304 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:47:28.305 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 250.0 seconds to update devices 2021-04-11 16:47:38.047 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:47:38.097 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:47:38.097 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:47:38.098 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 240.0 seconds to update devices 2021-04-11 16:47:48.040 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:47:48.093 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:47:48.093 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:47:48.093 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 230.0 seconds to update devices 2021-04-11 16:47:58.178 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:47:58.228 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:47:58.229 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:47:58.229 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 220.0 seconds to update devices 2021-04-11 16:48:08.017 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:48:08.067 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:48:08.068 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:48:08.068 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 210.0 seconds to update devices 2021-04-11 16:48:18.025 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:48:18.076 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:48:18.076 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:48:18.076 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 200.0 seconds to update devices 2021-04-11 16:48:28.146 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:48:28.196 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:48:28.196 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:48:28.197 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 190.0 seconds to update devices 2021-04-11 16:48:38.007 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:48:38.057 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:48:38.057 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:48:38.057 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 180.0 seconds to update devices 2021-04-11 16:48:48.042 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:48:48.093 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:48:48.093 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:48:48.093 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 170.0 seconds to update devices 2021-04-11 16:48:58.152 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:48:58.202 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:48:58.202 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:48:58.202 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 160.0 seconds to update devices 2021-04-11 16:49:08.049 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:49:08.099 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:49:08.099 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:49:08.100 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 150.0 seconds to update devices 2021-04-11 16:49:18.029 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:49:18.080 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:49:18.080 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:49:18.080 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 140.0 seconds to update devices 2021-04-11 16:49:28.209 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:49:28.260 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:49:28.260 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:49:28.261 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 130.0 seconds to update devices 2021-04-11 16:49:38.056 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:49:38.106 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:49:38.106 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:49:38.107 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 120.0 seconds to update devices 2021-04-11 16:49:48.045 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:49:48.096 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:49:48.096 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:49:48.097 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 110.0 seconds to update devices 2021-04-11 16:49:58.252 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:49:58.302 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:49:58.303 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:49:58.303 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 100.0 seconds to update devices 2021-04-11 16:50:00.449 Dummy Switch: Light/Switch (APC Line power) 2021-04-11 16:50:00.500 Sending SetPoint to device.... 2021-04-11 16:50:00.501 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onCommandCallback' on to queue 2021-04-11 16:50:00.501 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'CPluginMessageBase' on to queue 2021-04-11 16:50:00.516 (Nest Thermostaat plugin) Processing 'onCommandCallback' message 2021-04-11 16:50:00.517 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onCommand'. 2021-04-11 16:50:00.522 Nest Thermostaat plugin: (Nest Thermostaat plugin) > Living Room - Nest Thermostaat plugin - Living Room Heating Temp 2021-04-11 16:50:00.526 Nest Thermostaat plugin: (Nest Thermostaat plugin) > Entering push thread 2021-04-11 16:50:00.535 Nest Thermostaat plugin: (Nest Thermostaat plugin) Processed Set Level to 20.0 for unit 5 2021-04-11 16:50:00.535 (Nest Thermostaat plugin) Processing 'CPluginMessageBase' message 2021-04-11 16:50:00.541 Nest Thermostaat plugin: (Nest Thermostaat plugin) Message handler 'onDeviceModified' not callable, ignored. 2021-04-11 16:50:01.302 Nest Thermostaat plugin: (Nest Thermostaat plugin) >> Temperature set to 20.0 2021-04-11 16:50:01.307 Nest Thermostaat plugin: (Nest Thermostaat plugin) > Exit push thread 2021-04-11 16:50:08.035 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:50:08.085 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:50:08.086 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:50:08.086 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 90.0 seconds to update devices 2021-04-11 16:50:18.019 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:50:18.070 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:50:18.070 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:50:18.070 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 80.0 seconds to update devices 2021-04-11 16:50:28.171 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:50:28.221 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:50:28.222 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:50:28.222 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 70.0 seconds to update devices 2021-04-11 16:50:38.028 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:50:38.079 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:50:38.079 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:50:38.079 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 60.0 seconds to update devices 2021-04-11 16:50:48.010 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:50:48.060 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:50:48.061 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:50:48.061 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 50.0 seconds to update devices 2021-04-11 16:50:58.229 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:50:58.279 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:50:58.280 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:50:58.280 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 40.0 seconds to update devices 2021-04-11 16:51:08.027 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:51:08.078 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:51:08.078 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:51:08.078 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 30.0 seconds to update devices 2021-04-11 16:51:18.021 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:51:18.072 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:51:18.072 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:51:18.072 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 20.0 seconds to update devices 2021-04-11 16:51:28.181 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:51:28.231 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:51:28.232 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:51:28.232 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 10.0 seconds to update devices 2021-04-11 16:51:38.029 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:51:38.079 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:51:38.079 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:51:38.081 Nest Thermostaat plugin: (Nest Thermostaat plugin) > Entering update thread 2021-04-11 16:51:38.091 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 300.0 seconds to update devices 2021-04-11 16:51:38.693 Nest Thermostaat plugin: (Nest Thermostaat plugin) >> Got nest devices 0: thermostats [] - protects [] 2021-04-11 16:51:38.694 Nest Thermostaat plugin: (Nest Thermostaat plugin) > Update unit 1: Nest Thermostaat plugin - Living Room Heating - 0 - 0 2021-04-11 16:51:38.694 (Nest Thermostaat plugin - Living Room Heating) Updating device from 0:'0' to have values 0:'0'. 2021-04-11 16:51:38.729 Nest Thermostaat plugin: (Nest Thermostaat plugin) > Update unit 2: Nest Thermostaat plugin - Living Room Away - 0 - 0 2021-04-11 16:51:38.729 (Nest Thermostaat plugin - Living Room Away) Updating device from 0:'0' to have values 0:'0'. 2021-04-11 16:51:38.748 Nest Thermostaat plugin: (Nest Thermostaat plugin) > Update unit 3: Nest Thermostaat plugin - Living Room Eco Mode - 0 - 0 2021-04-11 16:51:38.748 (Nest Thermostaat plugin - Living Room Eco Mode) Updating device from 0:'0' to have values 0:'0'. 2021-04-11 16:51:38.767 Nest Thermostaat plugin: (Nest Thermostaat plugin) > Update unit 4: Thermostaat - Living Room Temp/Hum - 20 - 20.2;50;0 2021-04-11 16:51:38.768 (Thermostaat - Living Room Temp/Hum) Updating device from 20:'20.2;50;0' to have values 20:'20.2;50;0'. 2021-04-11 16:51:38.785 Nest Thermostaat plugin: (Nest Thermostaat plugin) > Update unit 5: Nest Thermostaat plugin - Living Room Heating Temp - 20 - 20.0 2021-04-11 16:51:38.785 (Nest Thermostaat plugin - Living Room Heating Temp) Updating device from 20:'20.0' to have values 20:'20.0'. 2021-04-11 16:51:38.803 Nest Thermostaat plugin: (Nest Thermostaat plugin) > Exit update thread 2021-04-11 16:51:38.694 Error: Nest Thermostaat plugin: (Nest Thermostaat plugin) API response status code 401 2021-04-11 16:51:48.015 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:51:48.066 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:51:48.066 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:51:48.066 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 290.0 seconds to update devices 2021-04-11 16:51:58.221 Nest Thermostaat plugin: (Nest Thermostaat plugin) Pushing 'onHeartbeatCallback' on to queue 2021-04-11 16:51:58.271 (Nest Thermostaat plugin) Processing 'onHeartbeatCallback' message 2021-04-11 16:51:58.271 Nest Thermostaat plugin: (Nest Thermostaat plugin) Calling message handler 'onHeartbeat'. 2021-04-11 16:51:58.271 Nest Thermostaat plugin: (Nest Thermostaat plugin) Wait 280.0 seconds to update devices

jvberlo commented 3 years ago

Hello Filip,

is my previous logging any good for troubleshooting?

Greetings Jeroen

FilipDem commented 3 years ago

No I didn't had time and very complex to debug as I cannot simulate the problem. I think at a certain moment there is indeed an error 401 coming back from the server. This I cannot solve. I am now puzzled that the subsequent errors are just a repetition... could you check there is real message send to the NEST server (and answer received) while the same error is appearing in the Domoticz log? This would conform my idea that the error is just repeated with trying to recover towards the server... I fear it will be more for this weekend to look at it... Filip

kitopopo commented 3 years ago

Dear friends,

Same problem for me. The error NEST GOOGLE: (NEST GOOGLE) API response status code 401 appears sometimes every hour and some times 2 o 3 hours. I hope you could solve the problem, we would be very grateful. Thanks in advance. Best regards

jvberlo commented 3 years ago

Hello Filip,

How can i check the message send to and received from the NEST server? Is there a log file somewhere?

Greetings Jeroen

FilipDem commented 3 years ago

Hey Jeroen, Looking into the problem this weekend... The log in domoticz shows only a part... You can see the complete log if you consult immediately the file (depends your configuration, I have set DAEMON_ARGS="$DAEMON_ARGS -log /tmp/domoticz.txt" in the domoticz.sh).

To avoid that lot of lines are lost with the information from Nest, you can comment out one line of code: in function "GetStatusUserBuckets" comment out " log('Status: {}'.format(json.dumps(self._status, indent=2)))". The dump of all the information from Nest won't happen then... You need to "update" the hardware to take into account the new code.

Come back to you when I am able to debug and find something.

FilipDem commented 3 years ago

Hi Jeroen and @ridderr,

I think that I am a step further in the analysis... Let me explain first: I didn't understood why every hour this is coming up... Now I understand! The generated nest credentials are valid for one hour. As long as the credentials are valid, I get the information from nest using these credentials. If the current time exceeds the validation time, I re-generate new credentials. In my opinion, the only possibility is that these credentials are NOT update at your side. So I try to get the new nest information with the old (expired) credentials.

To check if the credentials are valid, I just compare the current time with the time of credential validity. However one is probably in local time, the other in the utc time. Normally this should have been covered already in my code (it is working at my side).

I did not yet completely understood why it is not working at your side, however I think it has sth to do with timezone settings on your device. Attached you find a new nest.py file. I did already a small improvement on the timezone conversion, but I am not yet sure this will solve the problem. This file contains some more debug information about the date and time around the credentials generation (and I removed the big debug information dumping all the nest information).

So if one of you could use this file and give me the debug output, it would help me further. Sorry to bother you, but as I cannot reproduce the problem, it is the only possibility to progress.

nest.py.txt (you need to remove the .txt extension... I only added it to be able to upload)

Thanks, Filip

ridderr commented 3 years ago

Installed, will update you tomorrow

ridderr commented 3 years ago

Only had one 401 this period. See the attached log for details.

2021-04-24 03:11:17.065 Nest: (Nest) > Entering update thread 2021-04-24 03:11:17.069 Nest: (Nest) >> Credentials validation: current date/time 2021-04-24 03:11:17.069085+02:00 - expiry date/time 2021-04-24 03:32:17+02:00 2021-04-24 03:11:17.070 Nest: (Nest) Wait 60.0 seconds to update devices 2021-04-24 03:11:19.680 Nest: (Nest) >> Got nest devices 0: thermostats [] - protects [] 2021-04-24 03:11:19.680 Error: Nest: (Nest) API response status code 401 nest.log

FilipDem commented 3 years ago

This is already better... I was running it also and had now 4 times the error (never had it before)... So we are on the good way :-). I suppose your devices are well updated in all other cases, right? Now I have the problem also at my side I can debug better... However will take time as it takes hours to reproduce... But very strange that the current time is still before the expiry time... Filip

jvberlo commented 3 years ago

Hello Filip.

Thanks for the effort, I will install the new nest.py right away. Does it help you if i tell you the timezone configured in my pi is Europe/Amsterdam?

FilipDem commented 3 years ago

Mine is Brussels. So should be the same... I already did a change and @ridderr had only once the problem this night... So it is already and improvement. All feedback is welcome of course.

@ridderr: I would like to know if the you had is really exceptional or comes back regularly (normally the credentials were still valid for 20min). I could understand if it was on the edge of being expired (therefore I made just an improvement - this were my cases). So please give back any information (with the extract of the log as you did) when the problem comes up again. No need to have the whole log. I am only interested in all the lines 2021-04-24 03:11:17.069 Nest: (Nest) >> Credentials validation: current date/time 2021-04-24 03:11:17.069085+02:00 - expiry date/time 2021-04-24 03:32:17+02:00

F

kitopopo commented 3 years ago

Dear friends,

I think that i don´t have problem with hourly or credentials, this is my errors log before 401 error:

2021-04-24 14:34:38.020 NEST GOOGLE: (NEST GOOGLE) Pushing 'onHeartbeatCallback' on to queue 2021-04-24 14:34:38.071 (NEST GOOGLE) Processing 'onHeartbeatCallback' message 2021-04-24 14:34:38.071 NEST GOOGLE: (NEST GOOGLE) Calling message handler 'onHeartbeat'. 2021-04-24 14:34:38.073 NEST GOOGLE: (NEST GOOGLE) > Entering update thread 2021-04-24 14:34:38.082 NEST GOOGLE: (NEST GOOGLE) Wait 60.0 seconds to update devices 2021-04-24 14:34:38.619 NEST GOOGLE: (NEST GOOGLE) >> Got nest devices 0: thermostats [] - protects [] 2021-04-24 14:34:38.619 Error: NEST GOOGLE: (NEST GOOGLE) API response status code 401

I could test if with the previous plugin version this error is produced also. do you want that i test this? thanks in advanced. Best regards

ridderr commented 3 years ago

@FilipDem , Hi Filip, Some more logging. It occuring often than last night. See logfile for details. I hope this helps. nest.2.log

FilipDem commented 3 years ago

This is very reasonable.. I analysed the logfile and almost all the cases are easily explainable. The current time and the expiry date is more or less the same... So the time to access the server etc can make it expired (esp. in case retries are required). I will make a small change and upload then a new file. This should take away all those cases and probably most of the 401 errors will disappear. I hope all, but I cannot explain one case: ie the credentials are still 20 minutes valid, but are received. I don't have this case (and even before your problem description, I never had access problems).

You will soon the new version here (and remove most logs - will just keep them in case of error).

FilipDem commented 3 years ago

Attached a temporary update... This should solve normally the topic. It reduces also the log already; more information is logged when the error 401 occurs.

plugin.py has changed because I pass the parameter about the update frequency... This parameter is used to refresh the credentials a bit upfront they expire (sooner if the update time is longer).

I have running this already some hours on 2 instances without any error generation... So if you give me the same feedback, I will make these changes official.

Thank you both for your help to improve the plugin!

temp_update.zip

ridderr commented 3 years ago

Installed, will update you tomorrow

ridderr commented 3 years ago

Hi @FilipDem , Problem solved at my side. Great job !!

FilipDem commented 3 years ago

Thanks @jvberlo and @ridderr. Also running the whole night without problem at my side. I updated the main with the update.

Feel free for a small contribution to my time spent on this plugin (you can find it at the beginning of the readme). I think this development is a good workaround for using the NEST devices. No obligation, however always welcome!

Filip

kitopopo commented 3 years ago

Dear friends, congratulations, all errors has been disappeared. Thanks very much