01-23-2023 10:12 AM
As per my previous post, since the Google Home app is inherently unreliable for detecting and reporting on the status of Google's pods, I've found that there are some APIs that worked with the first generation Google Wifi products that continue to work with the Nest Wifi pro pods. The most useful one appears to be:
There's information on this API here: https://gist.github.com/Zenexer/e1c03b87fee6236c71e4fefcb1ff73a9#request-9
It returns a JSON file in the format below (testwifi.here appears to resolve to the IP address of the pod that is acting as the router. You can substitute it with the IP addresses of your other pods and get a similar result. I've highlighted in bold two key attributes that are worth tracking. If you use Google Chrome, you can install an extension that makes it easy to call this API and get the status: https://github.com/semenko/chrome-status-monitor-for-google-wifi
{
"dns": {
"mode": "custom",
"servers": [ "1.1.1.1", "1.0.0.1" ]
},
"setupState": "GWIFI_OOBE_COMPLETE",
"software": {
"blockingUpdate": 1,
"softwareVersion": "1.63.327820",
"updateChannel": "stable-channel",
"updateNewVersion": "0.0.0.0",
"updateProgress": 0.0,
"updateRequired": false,
"updateStatus": "idle"
},
"system": {
"countryCode": "us",
"groupRole": "root",
"hardwareId": "SIROCCO MP-MP-SAMS3130461501-SAMS3130752900",
"lan0Link": true,
"ledAnimation": "CONNECTED",
"ledIntensity": 30,
"modelId": "SIROCCO",
"oobeDetailedStatus": "OOBE_COMPLETE",
"uptime": 32179
},
"vorlonInfo": {
"migrationMode": "voobed"
},
"wan": {
"captivePortal": false,
"ethernetLink": true,
"gatewayIpAddress": "172.125.76.1",
"invalidCredentials": false,
"ipAddress": true,
"ipMethod": "dhcp",
"ipPrefixLength": 22,
"leaseDurationSeconds": 600,
"localIpAddress": "172.125.76.132",
"nameServers": [ "192.168.1.254" ],
"online": true,
"pppoeDetected": false,
"vlanScanAttemptCount": 0,
"vlanScanComplete": true
}
}
Here is a Python script that will poll your pods every minute, writing the status result (and a timestamp) to a log file (change {yourid} to where you want to run the script & have the log files be stored). Update the device_ips to the IP addresses of your pods (if not running this on a Mac, then you can comment out the line that sends a Notification (osascript😞
#
# Nest Monitoring
#
import requests
import json
import schedule
import time
import sys
import subprocess
from datetime import datetime
import os
log_folder = "/Users/{yourid}/Documents/Programming/Python/Nest"
device_ips = ["192.168.86.1", "192.168.86.41", "192.168.86.21"]
log_files = [ip + ".log" for ip in device_ips]
def poll_devices():
global device_ips
global log_files
for device_ip, log_file in zip(device_ips, log_files):
try:
response = requests.get(f"http://{device_ip}/api/v1/status")
json_response = json.loads(response.text)
with open(os.path.join(log_folder, log_file), "a") as log_file:
log_file.write(f"[{datetime.now()}] {json.dumps(json_response)}\n")
except Exception as e:
message = f"Error: Device {device_ip} not reachable. {e}\n"
sys.stderr.write(message)
subprocess.run(["osascript", "-e", f'display notification "{message}" with title "Device Error"'])
schedule.every(1).minutes.do(poll_devices)
while True:
schedule.run_pending()
time.sleep(1)
#
# Nest loganalysis
#
import os
import json
from datetime import datetime
log_folder = "/Users/{yourid}/Documents/Programming/Python/Nest"
for log_file in os.listdir(log_folder):
if log_file.endswith(".log"):
with open(os.path.join(log_folder, log_file)) as json_file:
for line in json_file:
timestamp, json_str = line.strip().split("]", 1)
json_data = json.loads(json_str)
log_time = datetime.strptime(timestamp[1:], "%Y-%m-%d %H:%M:%S.%f")
if json_data['system']['ledAnimation'] != "CONNECTED" or json_data['wan']['online'] != True:
print(f"Error: Device {log_file} status is not as expected at {log_time}")
If anyone knows of a better way to do some monitoring/logging--please let me know.
04-07-2023 01:17 PM
This is really cool, thanks for sharing!
04-10-2023 06:18 PM
04-15-2023 05:21 PM
Hi gjouret,
Checking back in should you still have some questions here. Let us know by replying to this thread.
Best,
Abi
04-16-2023 08:16 PM
Hello everyone,
We haven't heard from you in a while so we'll be locking this thread if there is no update within 24 hours. If you have any new issues, updates or just a discussion topic, feel free to start a new thread in the Community.
Regards,
Abi