jasonacox / pypowerwall

Python API for Tesla Powerwall and Solar Power Data
MIT License
120 stars 21 forks source link

Issues with POST #90

Closed spoonwzd closed 2 months ago

spoonwzd commented 2 months ago

Things have stopped working for me since you implemented POST.

I can set the reserve correctly using POST using curl from your example, but when I set the method in my node-red function to POST it says my token is bad.

"{"unauthorized": "Control Command Token Invalid"}"

I'm not sure what I'm doing wrong. It should be as simple as changing msg.method in my custom function:

if (powerwall_reserve!=charge_level && overnight_charge===true) {
    msg.method = "POST"
    msg.url = "http://192.168.78.40:8675/control/reserve?token=MY_TOKEN&value=" + charge_level
return msg;

The only thing I can see different is your example sets the value before the token. Should this matter?

Any ideas?

jasonacox commented 2 months ago

POST sends the payload via a message versus on the URL. I think you would need something like this:

if (powerwall_reserve != charge_level && overnight_charge === true) {
    msg.method = "POST";
    msg.url = "http://192.168.78.40:8675/control/reserve";
    msg.payload = "token=MY_TOKEN&value=" + charge_level;
    return msg;
}
spoonwzd commented 2 months ago

Yup that was the secret sauce - thanks!

jasonacox commented 2 months ago

Thanks for testing, @spoonwzd ! I'll close this but feel free to reopen.