-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version 20.49 broke this #14
Comments
Yep, not working at all now. |
Yes, access to the used API endpoints requires to be logged in. 😢 Anyone an idea how to add authentication? |
This link has some info on it - I'm afraid I don't understand it because it is python related. https://github.com/rhodesman/teslaPowerDash |
There is no way to add authentication in telegraf as of yet. The only workaround found is to login on the webpage and copy the cookie to the telegraf config file - but this will get it going only as long the cookie is valid, then it needs to be replaced. |
I'll think about extending the telegraf inputs.http plugin. Unfortunately the login mechanism to the powerwall is a custom one (credentials via URL parameters or via JSON body). So maybe you are right that a special plugin would be better than extending the existing one. |
you can use [[inputs.exec]] instead of [[inputs.http]] in the telegraf.conf file. in exec you can add any command line entry, including bash scripts or direct curl statements that can include authentication cookies. I did that, adapted some Grafana dashboards, works so far, but have not yet gotten the 20.49 update yet for final testing. |
@schumi could you please provide your changes via a pull request? I will test them then. |
Using this in the [[inputs.exec]] section of telegraf.conf see attached file (did not do pull request, as I removed actual ip address and PW below) Then a cron job that renews the authentication cookie (currently at 1 minute). not sure what timing will be actually needed, will test & adapt once Tesla has upgraded me to 20.49: */1 * * * * curl -s -k -i -c /tmp/cookies/pw.txt -X POST -H 'Content-Type: application/json' -d {"username":"customer","password":"password as configured for customer","email":"e-mail as configured for customer","force_sm_off":false} https://[ip addr]/api/login/Basic hope this helps! |
So how's the testing going? |
still on 20.40.3, so no news from my side |
I tried to use input.exec but I'm a novice in administration all of the components. I'm not sure but I think the telegraf config works but I don't see any data in grafana. |
you need to adjust the Grafana Dashboards, see screenshot below for a Dashboard query where I added both http tags and exec tags Spelled out as SELECT statement this is as follows: SELECT mean("load_instant_power") FROM "exec" WHERE $timeFilter GROUP BY time($__interval) fill(none) SELECT mean("load_instant_power") FROM "http" WHERE ("url" = 'https://192.168.7.14/api/meters/aggregates') AND $timeFilter GROUP BY time($__interval) fill(none) the dashboard then populates nicely. |
Sure that this is everything I need to adapt based on your input.exec config? I'm sorry. Currently I don't have enough time to RTFM all the stuff that is necessary to get it working. Please provide an export of your dashboard and check if the influxdb needs adjustment. How to check if there is data in the DB? |
Below is the dashboard definition to check, whether the database has been populated by Telegraf using the [[inputs.exec]] section as described above. It should plot the http values on top of the exec values for house consumption as provided by the Powerwall Gateway (adapt IP address of gateway to your actual IP address). In my case it looks as on screenshot, in cases where http access does not work anymore, only the blue curve would be visible: { |
Thanks, will use it tomorrow - hopefully. |
I've just been updated today so will give this a try. I'm a bit of a novice at all this, but thank you all for the details, I hope this works! |
I've tried this with my credentials, but the pw.txt file created only seems to have 4 lines in it. I'm not sure what should be in the file, but all I see is: Netscape HTTP Cookie File If I run the curl command at the pi command prompt, it returns an error 401 bad credentials. (I've tested my credentials on the new login screen so I know they are correct. Any suggestions most welcome! Update: You need to escape the quotes on the command and you need --data-raw otherwise the Powerwall replies with the 401 error. Netscape HTTP Cookie File 192.168.x.xx FALSE / FALSE 0 UserRecord eyJl... Hope this helps other newbies out there! |
I've followed your steps schumi, but when I try to run your test dashboard, I just get a blank screen. I've tried replacing http with exec in my dashboard.json file, but no data is being displayed. Does this suggest that my telegraf modification is wrong? I've tried the curl command at the command prompt and it all seems to work with data retrieved from the powerwall, I just can't seem to get the connection to the graphs sorted. Any help would be gratefully received. |
I'm exploring changing this to a cloud-based solution (based off the same stack here), where the code (still open sourced) will be pushed automatically to devices when there are updates. Would this kind of solution be of interest to the people using this now? You would still need your own device (I'm targeting raspberry pi initially, but x86 platform should work too), but you would not have to worry about updates, either on the firmware side or the client side. |
You have my interest. I love the view your solution gives of my system.
If you are adding anything I’d love to know how to export all the data to something like excel, but to have a stable graphic display would be excellent!
I’ve figured out the cookie paste so I’m running again for now.
Thanks!
… On 20 Feb 2021, at 22:17, mihailescu2m ***@***.***> wrote:
I'm exploring changing this to a cloud-based solution (based off the same stack here), where the code (still open sourced) will be pushed automatically to devices when there are updates. Would this kind of solution be of interest to the people using this now? You would still need your own device (I'm targeting raspberry pi initially, but x86 platform should work too), but you would not have to worry about updates, either on the firmware side or the client side.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
As a bit of a novice to the low down details of telegraf & grafana I failed to get the above solutions to work, so I've resorted to a bit of a cumbersome workaround - but it seems to work for my setup which is based on the original configuration from milhailescu2m instructions - but will only work on a Pi (as far as I know...) I've attached my little python program. Please feel free to either laugh at it or use the bits that work for you! I hope anyone else out there with a Raspberry Pi for monitoring their Powerwall finds it useful until there is a simpler solution! |
With the 20.49 firmware update by Tesla, the endpoints that previously were open are no longer without authentication. Unfortuantely, the mechanism used for authentication is not HTTP basic, rather it's cookie based. This makes it so a process runs in the background to ensure that you always stay logged in and then executes the queries against the endpoints with the login cookie. However, for some reason cURL was just ignoring the cookie file on my machine, so I had to do some extra hacks to make it pass the cookies in on the command line. Also, this requires cron, which means by that point I might as well build a new docker container for this process. Fixes mihailescu2m#14 DCO 1.1 Signed-off-by: Patrick Wagstrom <[email protected]>
With the 20.49 firmware update by Tesla, the endpoints that previously were open are no longer without authentication. Unfortuantely, the mechanism used for authentication is not HTTP basic, rather it's cookie based. This makes it so a process runs in the background to ensure that you always stay logged in and then executes the queries against the endpoints with the login cookie. However, for some reason cURL was just ignoring the cookie file on my machine, so I had to do some extra hacks to make it pass the cookies in on the command line. Also, this requires cron, which means by that point I might as well build a new docker container for this process. Fixes mihailescu2m#14 DCO 1.1 Signed-off-by: Patrick Wagstrom <[email protected]>
With the 20.49 firmware update by Tesla, the endpoints that previously were open are no longer without authentication. Unfortuantely, the mechanism used for authentication is not HTTP basic, rather it's cookie based. This makes it so a process runs in the background to ensure that you always stay logged in and then executes the queries against the endpoints with the login cookie. However, for some reason cURL was just ignoring the cookie file on my machine, so I had to do some extra hacks to make it pass the cookies in on the command line. Also, this requires cron, which means by that point I might as well build a new docker container for this process. Fixes mihailescu2m#14 DCO 1.1 Signed-off-by: Patrick Wagstrom <[email protected]>
With the 20.49 firmware update by Tesla, the endpoints that previously were open are no longer without authentication. Unfortuantely, the mechanism used for authentication is not HTTP basic, rather it's cookie based. This makes it so a process runs in the background to ensure that you always stay logged in and then executes the queries against the endpoints with the login cookie. However, for some reason cURL was just ignoring the cookie file on my machine, so I had to do some extra hacks to make it pass the cookies in on the command line. Also, this requires cron, which means by that point I might as well build a new docker container for this process. Fixes mihailescu2m#14 DCO 1.1 Signed-off-by: Patrick Wagstrom <[email protected]>
With the 20.49 firmware update by Tesla, the endpoints that previously were open are no longer without authentication. Unfortuantely, the mechanism used for authentication is not HTTP basic, rather it's cookie based. This brings in a very simple cookie aware proxy to run in the telegraf container. In short, cron updates the cookies every two minutes and then cookieproxy forwards to connection with cookies through to the Powerwall. Fixes mihailescu2m#14 DCO 1.1 Signed-off-by: Patrick Wagstrom <[email protected]>
With the 20.49 firmware update by Tesla, the endpoints that previously were open are no longer available without authentication. Unfortuantely, the mechanism used for authentication is not HTTP basic, rather it's cookie based. This change brings in an additional container that I created called cookieproxy, that can be used to proxy the cookie based requests through to the Powerwall gateway. In contrast to previous versions, this requires no compilation of containers on the local machine and no modifications to the more common containers of influxdb, grafana, and telegraf. There is a small customization that is required to store the password of your Powerwall in the `.env.cookieproxy` file, but otherwise it should be plug and play with the previous versions of mihailescu2m/powerwall_monitor. See mihailescu2m#14 DCO 1.1 Signed-off-by: Patrick Wagstrom <[email protected]>
@mihailescu2m: With PR #17 being accepted - can we close this issue? It's been running great for me for the past couple of weeks. |
Powerwall version 20.49 broke this
The text was updated successfully, but these errors were encountered: