Git Product home page Git Product logo

Comments (8)

jasonacox avatar jasonacox commented on July 18, 2024 1

You are correct, there is no way to set it via the proxy. The Powerwall gateway API no longer allows local control of the Powerwall. To control the Powerwall, you must use the cloud.

The good news is that you can use the pypowerwall module to set up cloud auth and control via the command line:

# Setup Connection with Tesla Cloud
python -m pypowerwall setup

# Get Power Levels, Operation Mode, and Battery Reserve Setting
#
# Usage: PyPowerwall get [-h] [-format FORMAT]
#  -h, --help      show this help message and exit
#  -format FORMAT  Output format: text, json, csv
#
python -m pypowerwall get
python -m pypowerwall get -format json
python -m pypowerwall get -format csv

# Set Operation Mode and Battery Reserve Setting
#
# Usage: PyPowerwall set [-h] [-mode MODE] [-reserve RESERVE] [-current]
#  -h, --help        show this help message and exit
#  -mode MODE        Powerwall Mode: self_consumption, backup, or autonomous
#  -reserve RESERVE  Set Battery Reserve Level [Default=20]
#  -current          Set Battery Reserve Level to Current Charge
#
python -m pypowerwall set -mode self_consumption
python -m pypowerwall set -reserve 30
python -m pypowerwall set -current

from pypowerwall.

jasonacox avatar jasonacox commented on July 18, 2024 1

Yes it could. I confess, it scares me a bit. I have hesitated adding that since the proxy access point doesn't require authentication. Any malicious actor who happens to gain access to your network could thrash settings on your system, potentially creating damage. I suspect there are some safeguards in the Tesla logic for this but it is an exposure that requires the user to understand and treat with care.

I suppose we could make that write (control) access "default off" that requires specific settings on startup to allow, or better, requires some secret token to execute (e.g. setting PW_CONTROL_SECRET=**** environmental variable required as a GET/POST payload to perform those changes). I'm open to thoughts around around that and welcome any contributions to start adding. 😉

from pypowerwall.

jasonacox avatar jasonacox commented on July 18, 2024 1

Ok, I have something for you to try. If you are using Powerwall-Dashboard:

To Test

  1. Update the pypowerwall image setting in powerwall.yml to:
jasonacox/pypowerwall:0.8.3t54-beta2
  1. Add PW_CONTROL_SECRET={something} to pypowerwall.env
  2. Restart ./compose-dash.sh up -d

Usage

Use a browser to try these URLs or use curl commands:

# Set Mode
curl "http://localhost:8675/control/mode?token=$PW_CONTROL_SECRET&value=self_consumption"

# Set Reserve
curl "http://localhost:8675/control/reserve?token=$PW_CONTROL_SECRET&value=20"

# Omit Value to Read Settings
curl "http://localhost:8675/control/mode?token=$PW_CONTROL_SECRET"
curl "http://localhost:8675/control/reserve?token=$PW_CONTROL_SECRET"

from pypowerwall.

jasonacox avatar jasonacox commented on July 18, 2024 1

EDIT: I added info logging for any control command executed

jasonacox/pypowerwall:0.8.3t54-beta2
04/13/2024 06:35:22 PM [proxy] [INFO] pyPowerwall [0.8.3] Proxy Server [t54] - HTTP Port 8675
04/13/2024 06:35:22 PM [proxy] [INFO] pyPowerwall Proxy Started
04/13/2024 06:35:22 PM [proxy] [INFO] pyPowerwall Proxy Server - Local Mode
04/13/2024 06:35:23 PM [proxy] [INFO] Connected to Energy Gateway x (Cox Energy Gateway)
04/13/2024 06:35:23 PM [proxy] [INFO] Control Commands Activating - WARNING: Use with caution!
04/13/2024 06:35:23 PM [proxy] [INFO] Control Mode Enabled: Cloud Mode Connected
...
04/13/2024 06:36:07 PM [proxy] [INFO] Control Command: Set Reserve to 20

from pypowerwall.

spoonwzd avatar spoonwzd commented on July 18, 2024 1

Running curl from the command line I get a "{"reserve": 5.0}'value' is not recognized as an internal or external command, operable program or batch file."

...but the same URL string works fine in a browser with the output:

{"set_backup_reserve_percent": {"backup_reserve_percent": 20, "din": "1099752-01-B--T17K000XXXX", "result": "Updated"}, "set_operation": {"real_mode": "self_consumption", "din": "1099752-01-B--T17K000XXXX", "result": "Updated"}}

The logs say:

04/14/2024 09:07:26 AM [proxy] [INFO] pyPowerwall [0.8.3] Proxy Server [t54] - HTTP Port 8676
04/14/2024 09:07:26 AM [proxy] [INFO] pyPowerwall Proxy Started
04/14/2024 09:07:27 AM [proxy] [INFO] pyPowerwall Proxy Server - Cloud Mode
04/14/2024 09:07:28 AM [proxy] [INFO] Connected to Site ID 123456 (Spoon Powerwall)
04/14/2024 09:07:28 AM [proxy] [INFO] Control Commands Activating - WARNING: Use with caution!
04/14/2024 09:07:28 AM [proxy] [INFO] Control Mode Enabled: Cloud Mode Connected
04/14/2024 09:14:34 AM [pypowerwall.cloud.pypowerwall_cloud] [WARNING] This API [get_api_auth_toggle_supported] is using mock data in cloud mode. This message will be printed only once at the warning level.
04/14/2024 09:14:34 AM [pypowerwall.cloud.pypowerwall_cloud] [WARNING] This API [get_api_sitemaster] is using mock data in cloud mode. This message will be printed only once at the warning level.
04/14/2024 09:14:34 AM [pypowerwall.cloud.pypowerwall_cloud] [WARNING] This API [get_api_system_status_grid_faults] is using mock data in cloud mode. This message will be printed only once at the warning level.
04/14/2024 09:14:34 AM [pypowerwall.cloud.pypowerwall_cloud] [WARNING] This API [get_api_unimplemented_timeout] is using mock data in cloud mode. This message will be printed only once at the warning level.
04/14/2024 09:14:34 AM [pypowerwall.cloud.pypowerwall_cloud] [WARNING] This API [get_api_powerwalls] is using mock data in cloud mode. This message will be printed only once at the warning level.
04/14/2024 09:16:12 AM [proxy] [INFO] Control Command: Set Reserve to 20

Seems to work great! Nice one :)

from pypowerwall.

jasonacox avatar jasonacox commented on July 18, 2024 1

thanks @spoonwzd !

Running curl from the command line I get a "{"reserve": 5.0}'value' is not recognized as an internal or external command, operable program or batch file."

Ah yes! What is happening is that the URL needs to be quoted (I omitted that), so anything before & the shell is trying to run as a command in the background and omitting the rest of the line. I'll edit my notes above.

curl "http://localhost:8675/control/reserve?token=$PW_CONTROL_SECRET&value=20"

from pypowerwall.

spoonwzd avatar spoonwzd commented on July 18, 2024

Understood, and I am able to set reserve etc. using the command line when using cloud auth.

However, it would be massively beneficial to be able to control this from the proxy when using cloud auth. Could this be added?

from pypowerwall.

spoonwzd avatar spoonwzd commented on July 18, 2024

Yes, I think you're on the right track there. Any 'set' command requires PW_CONTROL_SECRET to be passed. Anyone concerned about PW_CONTROL_SECRET being passed in plain text can enable HTTPS. At least that way you've done your due diligence.

from pypowerwall.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.