jasonacox / pypowerwall

Python API for Tesla Powerwall and Solar Power Data
MIT License
134 stars 24 forks source link

Changing Battery Configuration State Via GET #87

Closed KevM closed 5 months ago

KevM commented 5 months ago

I noticed that you added a control surface for the battery reserve. I am very excited about this for my needs. Thank you all for working on this. 💯

I was curious why you made the request a GET and not a POST? Maybe this has already been debated. My history with creating web APIs points to avoiding using GETs in front of anything that changes the state of the world.

Feel free to close this if I am being too pedantic.

Thanks again.

jasonacox commented 5 months ago

Excellent point, @KevM ! I'll add it to my TODO list to move to POST.

jasonacox commented 5 months ago

Staged update in #86 to add POST method. Available via beta proxy container:

jasonacox/pypowerwall:0.8.4t54-beta5
# Set Reserve to 20
curl -X POST -d "value=20&token=1234" http://localhost:8675/control/reserve

# Set Mode to self_consumption
curl -X POST -d "value=self_consumption&token=1234" http://localhost:8675/control/mode

# Read values by omitting value
curl -X POST -d "token=1234" http://localhost:8675/control/reserve
curl -X POST -d "token=1234" http://localhost:8675/control/mode