Skip to content

Instantly share code, notes, and snippets.

@Here-Be-Dragons
Last active February 24, 2022 16:50
Show Gist options
  • Save Here-Be-Dragons/fb51de47c84a6ad0426175ab08295235 to your computer and use it in GitHub Desktop.
Save Here-Be-Dragons/fb51de47c84a6ad0426175ab08295235 to your computer and use it in GitHub Desktop.
A fork of Vince Loschiavo's script, this grabs a cookie and then also updates a telegraf config with the new cookie values.
@Here-Be-Dragons
Copy link
Author

The above expects a file at /etc/telegraf/telegraf.d/powerwall.conf something like this:

 [[inputs.http]]
   urls = [
     "https://192.168.1.140/api/meters/aggregates",
     "https://192.168.1.140/api/system_status/soe",
     "https://192.168.1.140/api/meters/solar",
     "https://192.168.1.140/api/sitemaster",
     "https://192.168.1.140/api/system_status/grid_status",
     "https://192.168.1.140/api/status"
   ]
    method = "GET"
    insecure_skip_verify = true
    timeout = "5s"
    data_format = "json"
    headers = {"Cookie" = "AuthCookie=asdf; UserRecord=asdf"}

It will replace the AuthCookie and UserRecord values with valid cookie values.

@brianchan
Copy link

Thanks for the modifications.

Please change line 78 from updatecookie to update_cookie.

@Here-Be-Dragons
Copy link
Author

Thanks for the modifications.

Please change line 78 from updatecookie to update_cookie.

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment