This is a TypeScript/PostgreSQL version of Powerwall2PVOutput, written partially for learning and also because I found the SQLite file from that repository kept getting corrupted.
Copy the example configuration file .env.example
in the root level of the repository to .env
and at a minimum fill out all the uncommented variables.
POSTGRES_PASSWORD
— The standard Docker setup for powerwall-to-pvoutput-uploader includes its own PostgreSQL Docker container and volume to save data to, so the only required environment variable is POSTGRES_PASSWORD
.
POSTGRES_
variables that are commented out.POWERWALL_URL
— The local URL of your Powerwall.
https://
URL and not an http://
one.https://powerwall
, https://powerpack
, or https://teg
, without any domain component.POWERWALL_EMAIL
and POWERWALL_PASSWORD
— Accessing the Powerwall 2's API locally since firmware version 20.49.0 requires a username and password. If you haven't set up a username and password on the Powerwall 2 yet, follow the instructions on Tesla's site to configure them.TIMEZONE
— If you're using the standard Docker setup, be sure to set this variable as inside a Docker container, the timezone is always UTC which will throw off the times being sent to PVOutput. (This isn't strictly required, but highly recommended.)PVOUTPUT_API_KEY
and PVOUTPUT_SYSTEM_ID
— The API key can be generated in account settings at PVOutput, and the system ID is listed under Registered Systems on the same page.To send extended data to PVOutput, you need a PVOutput account with an active donation and the PVOUTPUT_SEND_EXTENDED_DATA
environment variable set to true
in .env
. To set up the extended data, use the following setup on your Edit System page on PVOutput:
DEBUG
— Set this to enable full debug logging of everything that's going onDISABLE_PVOUTPUT_UPLOAD
— Set this to have the application do everything except actually send data to PVOutput (useful for local development, or if you don't care about PVOutput at all and just want to have the data from the Powerwall accessible via MQTT as described below)MQTT_HOST
, MQTT_PORT
, and MQTT_TOPIC
— Set these variables to have powerwall-to-pvoutput publish the data it receives from the Powerwall to the specified MQTT broker and topic.
MQTT_PORT
is optional and defaults to 1883 if not specifiedThe data format that will be send to the given MQTT topic is the same as what's sent to PVOutput:
{
"timestamp": <number>,
"solar_generation": <number>,
"solar_voltage": <number>,
"home_usage": <number>,
"home_voltage": <number>,
"grid_flow": <number>,
"battery_flow": <number>,
"battery_charge_percentage": <number>
}
docker compose up --build -d
. If the image doesn't exist, it will be built, and if there have been any new changes pulled from this repository, it will be rebuilt.npm run build
, prepare the database with npm run db:migrate
and start it with npm start
, then use something like PM2 or Forever to keep it up../bin/start-dev.sh
to load the code up in a Docker container. It uses nodemon
to automatically reload on file changes.