PV Automated Load Manager
This software forms the basis of a simple home automation system, using the following hardware:
GivEnergy AC-coupled inverter with power monitoring on supply and local PV generation MiHome remote-controlled switches for various loads, controlled via hub and API
It performs the following functions:
-
aggregating data from multiple sources and upload to PVOutput.org every for 5 minutes for long-term analysis
-
setting overnight battery charge target for off-peak electricity usage, based on forecast generation and previous days' consumption
-
a simple sequencer for load management, based on time, temperature, battery charge and CO2/kWh
UPDATE 18/Aug/2023 File palm_soc.py is used by the GivTCP add-on to Home Assistant. The main file for execution outside the HA environment is palm.py. This includes ONCE_MODE "palm.py -o" to run through the overnight calculations and then exit.
To simplify code maintenance:
- the settings.py file has been renamed to palm_settings.py for consistency with GivTCP.
- common functionality for all variants of PALM has been moved to a separate palm_utils.py file.
Use the command "palm.py -t" for test, drop the "-t" argument for the target value to be written to the GivEnergy server
PALM now outputs a set of plot data that summarises the SoC calculation. To generate a chart, paste the CSV data into Excel.
The conservativeness of the forecast works for me and is set at 35%. It can be altered by changing the "Solcast.weight" parameter in settings.py
PALM now includes an Overmorrow function to increase self-consumption in changeable weather.
INSTALLATION INSTRUCTIONS FOR LINUX-BASED SYSTEMS, INCLUDING HOW TO RUN AS A SERVICE ON RASPBERRY PI
-
Create local directories:
$ mkdir /home/pi/palm
$ mkdir /home/pi/logs
-
Download all files to /home/pi/palm/
$ cd /home/pi/palm
$ wget github.com/salewis38/palm/archive/heads/main.zip
$ unzip main.zip
$ cp -rp palm-heads-main/* ./
-
Edit palm_settings.py with your system details, etc
$ nano palm_settings.py
-
Run palm.py, initially in test mode with the command:
$ ./palm.py -t
-
To run as a persistent service, execute the following commands:
$ sudo cp palm.service /lib/systemd/system
$ sudo systemctl start palm.service
$ sudo systemctl enable palm.service
This will run palm.py in the background and save date-coded logfiles to /home/pi/logs
-
Enjoy!
INSTALLATION INSTRUCTIONS FOR WINDOWS-BASED SYSTEMS Method 1 (simplest):
- Create a working directory
- Download palm.exe and palm_settings.py to the working directory
- Edit palm_settings.py with your system details
- Using a command window, navigate to the working directory and run palm.exe, initially with the -t option to run in test mode
Method 2 (harder, but more versatile):
- Install Python 3 from python.org. Palm.py works with versions of Python >= 3.9
- Create a working directory
- Download palm.py, palm_utils.py and palm_settings.py to the working directory
- Edit palm_settings.py with your system details
- Using a command window, navigate to the working directory and run palm.py, initially with the -t option to run in test mode
- If there are any missing library dependencies from the Python install, these are added using the command "pip3 install [modulename]"
INSTALLATION INSTRUCTIONS FOR SYNOLOGY NAS (credits to BoffinBoy)
Palm will not run natively on Synology as the installed version of python does not include the relevant packages. Running as a Docker container can help resolve this. A Dockerfile is provided to simplify the process.
Please note, to make any changes to the image, i.e. updating the settings file, it is most reliable to create a new version of the image with a different name in step 5, otherwise you may find the running Containers don’t use the new version.
- Extract palm to a directory on your Synology NAS, and edit the settings file as desired
- Go to Control Panel > Terminal & SNMP > Enable SSH service
- SSH into your Synology NAS
- Navigate to the directory you have extracted palm to using: cd /volume1/your/palm-directory
- Create a Docker image using: sudo docker build -t desired-image-name
- Once complete, depending on Synology version go to Docker or Container Manager and select the “Container” menu; the instructions below assume you have Container Manager, the menus are slightly different in Docker, but should still generally match the below
- Click “Create” and I’m the Image field select the image you just created
- Give the Container a name under “Container name”
- Tick “Enable auto restart” if you want palm to load automatically when Synology reboots, or if it experiences an error - this is recommended for typical use
- Under “Environment” add a new environment variable called TZ with value Europe/London (or your relevant timezone); this is important to ensure the Container is aware of daylight savings
- Under “Execution Command” enter python3 palm.py (note: if you want to pass through any additional arguments you should enter them here as well, e.g. python3 palm.py -o if you want to have a version that you run once, when needed)
- Complete the wizard, and the container should start running; you can look at the “Log” tab of the running container each day to check all has worked OK
- Return to Control Panel > Terminal & SNMP > Disable SSH service; important to do this for security purposes