solar_edge/README.md

92 lines
2.6 KiB
Markdown
Raw Normal View History

2019-04-15 16:15:57 -06:00
# Solar Edge Status Updater
When placed in a cron job this uppdater will make an https call to a json api to retrieve the co2 savings and equivenant trees planted and overlay those numbers on a graphic and upload them to the website.
# Dependancies
2019-04-15 17:15:35 -06:00
Python 3 and contents of `requirements.txt`.
2019-04-15 16:15:57 -06:00
2019-04-15 17:15:35 -06:00
The font `Biko_Regular.otf`.
A `.png` graphic to write text on.
The package direnv and the follwing changes to the user account:
* bash.rc (https://github.com/direnv/direnv/wiki/Python#bash)
* venv (https://github.com/direnv/direnv/wiki/Python#venv-stdlib-module)
2019-04-15 17:26:14 -06:00
If `ssh_host` is blank will copy file locally instead of scping file to sever. To scp valid sshkeys are required.
2019-04-15 16:15:57 -06:00
# Bulid Instructions
2020-10-28 12:21:27 -06:00
If want to run this by executing the code in the python venv envrionment, there is no need to make any changes after modifying the ```.env``` file.
2019-04-15 17:15:35 -06:00
assumes installed to `~/python/solar_edge`
2020-10-28 12:21:27 -06:00
2019-04-15 17:17:27 -06:00
```
2019-04-15 17:15:35 -06:00
cd ~/python
git clone http://git.elder-geek.net/fredw/solar_edge.git
cd solar_edge
cp env.sample .env
direnv allow
pip install -r requirements.txt
2019-04-15 17:17:27 -06:00
```
2019-04-15 17:15:35 -06:00
edit `.env` and update accordingly
2019-04-15 17:02:41 -06:00
2020-10-28 09:04:44 -06:00
add to user crontab to update site every 5 minutes
```
*/5 * * * * cd ~/python/solar_edge && direnv exec . python solar_edge.py > /dev/null 2>&1
```
# Create pyinstaller
2020-10-28 12:21:27 -06:00
Anytime you make a change to the ```.env``` file you will need to create and install a new copy if want to run this as a stand alone exceutable.
2020-10-28 09:04:44 -06:00
```
pyinstaller --onefile solar_edge.spec
2020-10-28 11:45:03 -06:00
cp dist/solar_edge ~/bin # user must have bin folder
2020-10-28 09:04:44 -06:00
```
2019-04-15 16:15:57 -06:00
2019-04-15 17:15:35 -06:00
add to user crontab to update site every 5 minutes
2019-04-15 17:17:27 -06:00
```
2020-10-28 09:04:44 -06:00
*/5 * * * * ~/bin/solar_edge > /dev/null 2>&1
2019-04-15 17:17:27 -06:00
```
2019-04-15 17:26:14 -06:00
2020-10-28 09:04:44 -06:00
2020-10-28 12:21:27 -06:00
2019-04-15 17:26:14 -06:00
# Sample .env if installed on the server
```
SSH_HOST=
2020-10-28 09:04:44 -06:00
SSH_PORT=
2019-04-15 17:26:14 -06:00
SSH_USER=
SSH_FOLDER=/var/www/wordpress
2020-10-28 12:00:17 -06:00
URL1=https://monitoringapi.solaredge.com/site/55555/envBenefits?systemUnits=Imperial&api_key=
2019-04-15 17:26:14 -06:00
INFILE=environmental_benefits_blank.png
OUTFILE=solar.png
FONT_FACE=Biko_Regular.otf
2020-10-28 11:45:03 -06:00
LINE1=81
LINE2=157
MARGIN=91
COLOR=#298246
2019-04-15 17:26:14 -06:00
```
# Sample .env file for scp
```
SSH_HOST=myserver.com
2020-10-28 09:04:44 -06:00
SSH_PORT=22
2019-04-15 17:26:14 -06:00
SSH_USER=www-data
SSH_FOLDER=/var/www/wordpress
2020-10-28 12:00:17 -06:00
URL1=https://monitoringapi.solaredge.com/site/55555/envBenefits?systemUnits=Imperial&api_key=
2019-04-15 17:26:14 -06:00
INFILE=environmental_benefits_blank.png
OUTFILE=solar.png
FONT_FACE=Biko_Regular.otf
2020-10-28 11:45:03 -06:00
LINE1=81
LINE2=157
MARGIN=91
COLOR=#298246
2019-04-15 17:26:14 -06:00
```
2020-10-28 12:00:17 -06:00
# Combining Mulitple Sites
Each site will need it's own ```URL```. These should be numbed from one, in sequence in the ```.env``` file. IE ```URL1```, ```URL2```, ```URL3```...
2020-10-28 11:45:03 -06:00
# Backgrounds
2020-10-28 12:00:17 -06:00
There are multilpe backgrounds to choose from. They can be selected by changing the ```INFILE``` value. You can make more and add them in the ```datas``` section of ```solar_edge.spec```.