1
0
Fork 0
Queries the solar data from Hoymiles API and stores it in a database and shows it in FHEM.
Go to file
Manuel Kamper 4b422a7997 „solar.service“ hinzufügen 2023-05-29 07:25:37 +00:00
LICENSE Initial commit 2023-05-29 06:56:11 +00:00
README.md „README.md“ ändern 2023-05-29 07:17:13 +00:00
index.php „index.php“ hinzufügen 2023-05-29 07:09:08 +00:00
solar.py „solar.py“ hinzufügen 2023-05-29 07:10:28 +00:00
solar.service „solar.service“ hinzufügen 2023-05-29 07:25:37 +00:00
solardata.sql „solardata.sql“ hinzufügen 2023-05-29 07:11:50 +00:00

README.md

Hoymiles-Solar-Database-FHEM

Queries the solar data from Hoymiles API and stores it in a database and shows it in FHEM.

Prerequisites

Make sure you have installed apache2 with php8.1 (and mysql extension). You need python3 too with mysql connector: python3 -m pip install mysql-connector-python

Create folders and rights

mkdir /opt/hoymiles && mkdir /opt/hoymiles/www
chown -R fhem:dialout /opt/hoymiles/www

Upload files

Upload index.php into /opt/hoymiles/www folder. It acts as an JSON-API for serving data to FHEM.
Upload solar.py into /opt/hoymiles folder. It will gather data from Hoymiles API and stores it in the database.

Create database

Use the script solardata.sql to create your database for storing solar data. Make sure you configure the rights accordingly.

Change values

In file index.php insert your database connection details. Do this also in solar.py, where you add also your Hoymiles credentials for login.

Run python script as a service

Apache mysql example

This example shows how to set up the JSON API in apache2.

<VirtualHost *:80>
    ProxyPreserveHost On
    ServerName automation.${MYDOMAIN}
    Alias /solarapi "/opt/hoymiles/www"
    <Directory "/opt/hoymiles/www/">
        AllowOverride none
        Require all granted
    </Directory>
    CustomLog /var/log/apache2/${LOG} combined
</VirtualHost>

FHEM example

This is an example, how you can show the data in your FHEM instance.

define Solar HTTPMOD 0
setuuid Solar 64744ab5-f33f-1b7d-ecc0-8b30ed24e4a4b55a
attr Solar event-on-change-reading .*
attr Solar extractAllJSON 1
attr Solar get01Name ReadSolarStats
attr Solar get01Poll 1
attr Solar get01URL http://your-automation-host/solarapi/index.php
attr Solar icon sani_solar
attr Solar room Solar
attr Solar stateFormat Current: current W, Today: today Wh