3 Commits

Author SHA1 Message Date
df4b62fd47 Some small improvements in README.md 2025-06-16 15:13:36 +02:00
53da0a1416 Some small fixes 2025-06-16 15:13:08 +02:00
eb8c865474 Added instructions for docker usage; added Update section 2025-06-16 15:07:34 +02:00
3 changed files with 18 additions and 6 deletions

2
.env
View File

@@ -9,7 +9,7 @@ OPENDTU_ADDR=<ADDRESS OF OPENDTU> # address of opendtu (format: http(s)://<IP-
OPENDTU_USER=<OPENDTU USER> # username for opendtu auth OPENDTU_USER=<OPENDTU USER> # username for opendtu auth
OPENDTU_PWD=<OPENDTU PWD> # password for opendtu auth OPENDTU_PWD=<OPENDTU PWD> # password for opendtu auth
OPENDTU_INVERTER_SN=<SERIAL NR> # serial number of the inverter to control OPENDTU_INVERTER_SN=<SERIAL NR> # serial number of the inverter to control
LIMIT_CORRECTION_FACTOR=2 # correction factor for limit setting (e.g.: when only 2 strings of 4 are connected, you always need to set 2x the power), default: 2 LIMIT_CORRECTION_FACTOR=2 # correction factor for limit setting (e.g.: when only 2 strings of 4 are connected, you always need to set 2x the power), default: 1.0
LIMIT_UPDATE_INTERVAL=5 # interval in which the limit shall be updated, default: 5 [sec] LIMIT_UPDATE_INTERVAL=5 # interval in which the limit shall be updated, default: 5 [sec]
DRY_RUN=0 # if the limit shall be set or not; default: 1 (0: False, 1: True) DRY_RUN=0 # if the limit shall be set or not; default: 1 (0: False, 1: True)
POWER_TARGET=15 # the target power consumption of the house, default: 50 [Watts] POWER_TARGET=15 # the target power consumption of the house, default: 50 [Watts]

View File

@@ -6,12 +6,18 @@ Enforce a zero export (or whatever consumption you like) policy with an OpenDTU-
## Configuring and usage ## Configuring and usage
### Docker ### docker-compose
Todo To run it using docker, try the `docker-compose.yaml` file present in this repository. You will need the .env file too for that reasons, so the easiest thing is to just run the following commands:
```bash
git clone https://git.privacynerd.de/BlueFox/SolarControl.git && cd SolarControl
vi .env # adjust the script to your needs
docker-compose up -d && docker-compose logs -f
```
### Bare-bone ### barebone
The script can be configured using the .env file where you can adjust it (hopefully perfect) to your needs. After that, just run the script: The script can be configured using the .env file where you can adjust it (hopefully perfect) to your needs. After that, just run the script:
@@ -22,7 +28,12 @@ python3 lge320reader.py
Please note: the .env file needs to be in the same folder or any other folder higher up in the directory structure as the script (more specifically, the WORKDIR). It is just a help, actually, the script searches for specific variables in its environment variables. It only loads the .env file so that you do not need to `export` all the files before running (see https://pypi.org/project/python-dotenv/ for more details). This also means that when using it in docker, you can set the docker containers environment file to that .env file and it will be accepted too. Please note: the .env file needs to be in the same folder or any other folder higher up in the directory structure as the script (more specifically, the WORKDIR). It is just a help, actually, the script searches for specific variables in its environment variables. It only loads the .env file so that you do not need to `export` all the files before running (see https://pypi.org/project/python-dotenv/ for more details). This also means that when using it in docker, you can set the docker containers environment file to that .env file and it will be accepted too.
## Building docker ## Updating
To update, simply use `git pull` to pull the latest changes. Afterwards, you need to restart your script (with docker, just use `docker-compose up -d --force-recreate`).
## Building the docker image
To build the image for docker, simply use the following commands: To build the image for docker, simply use the following commands:

View File

@@ -61,7 +61,7 @@ powers = {"total": None, "total_house": None, "total_solar": None, "timestamp":
# define mqtt callbacks # define mqtt callbacks
def on_connect(client, userdata, flags, reason_code, properties): def on_connect(client, userdata, flags, reason_code, properties):
print(f"{bcolors.OKGREEN}Connected with result code {bcolors.ENDC}{reason_code}") print(f"{bcolors.OKGREEN}Connected to the MQTT broker ({mq_broker}:{mq_port}) with result code {bcolors.ENDC}{reason_code}{bcolors.OKGREEN}.{bcolors.ENDC}")
client.subscribe("lge320/#") client.subscribe("lge320/#")
client.subscribe("solar/ac/#") client.subscribe("solar/ac/#")
def on_message(client, userdata, msg): def on_message(client, userdata, msg):
@@ -83,6 +83,7 @@ mqttc.connect(mq_broker, mq_port, 60)
mqttc.loop_start() mqttc.loop_start()
def threaded_current_power_calculation(): def threaded_current_power_calculation():
while True: while True:
last_powers = powers_raw.copy() last_powers = powers_raw.copy()