Sofar inverter - simple integration
Moderator: leecollings
-
- Posts: 4
- Joined: Saturday 24 September 2022 23:33
- Target OS: Linux
- Domoticz version:
- Contact:
Sofar inverter - simple integration
A few days ago I decided to add the SOFAR inverter to the domoticz. I wrote a working script. Maybe it will be useful to someone. In addition to integrating the inverter, the script takes care of the problem of a possible domoticz error (after a power loss). In addition, it checks sunrises so as not to overload the processor. Lnes for downloading data from SOFAR is very short. Its method can be used for many other inverters.
- Attachments
-
- sofar.tgz
- (1.65 KiB) Downloaded 314 times
- waltervl
- Posts: 5397
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Sofar inverter - simple integration
Thanks for this perl script.
Perhaps you can add some extra instructions how to run this on the domoticz server. I suppose you start the script every x minutes with crontab?
Perhaps you can add some extra instructions how to run this on the domoticz server. I suppose you start the script every x minutes with crontab?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 4
- Joined: Saturday 24 September 2022 23:33
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Sofar inverter - simple integration
So I put the supplement.
Configuration consists of the following steps:
A) preparation of domoticz
- create Dummy equipment (e.g. SOFAR)
- create two virtual devices: STATUS - Text type, SOFAR - power and energy type
- read their idx's
B) Alternatively, install the missing perl libraries: (I don't know what distribution you have, so use google yourself to see the package name in your distribution)
C) I further assume that the domoticz directory is in your home directory (your name is john).
D) Edit the sofar.pl file, set the parameters in the #CONF area
E) Check just by running the script:
Devices in domoticz should seting up.
F. Place the script in CRON:
Add line (running script every 10 minutes):
Finally, I suggest that you set in the script: $checksun = 1;
Logs appear in /var/log/syslog.
Configuration consists of the following steps:
A) preparation of domoticz
- create Dummy equipment (e.g. SOFAR)
- create two virtual devices: STATUS - Text type, SOFAR - power and energy type
- read their idx's
B) Alternatively, install the missing perl libraries:
Code: Select all
LWP :: UserAgent; MIME :: Base64; JSON; Sys :: Syslog
C) I further assume that the domoticz directory is in your home directory (your name is john).
Code: Select all
cd ~/domoticz/scripts/
wget -O ./sofar.tgz "https://www.domoticz.com/forum/download/file.php?id=28722&sid=89c20055f3da17746a1c136b6d8025da"
tar -xzf ./sofar.tgz
chmod u+x ./sofar.pl
E) Check just by running the script:
Code: Select all
./sofar.pl
F. Place the script in CRON:
Code: Select all
sudo crontab -e -u john
Code: Select all
*/10 * * * * /usr/bin/perl /home/john/domoticz/scripts/sofar.pl >> /home/john/sofar.log
Logs appear in /var/log/syslog.
-
- Posts: 7
- Joined: Thursday 21 March 2024 9:57
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024
- Contact:
Re: Sofar inverter - simple integration
Thanks for the script, but I'm stuck in preparation:
A) preparation of domoticz
- create Dummy equipment (e.g. SOFAR)
- create two virtual devices: STATUS - Text type, SOFAR - power and energy type
- read their idx's
In hardware I can select dymmy-virtual sensors.
create sensortype TEXT, I can select.
But power&energy ? is not in the list.
I chose sensortype Electric (instant + counter) but no luck.
For the text type virtual device I get an error after I run the script:
Error while getting data from SOFAR.
A) preparation of domoticz
- create Dummy equipment (e.g. SOFAR)
- create two virtual devices: STATUS - Text type, SOFAR - power and energy type
- read their idx's
In hardware I can select dymmy-virtual sensors.
create sensortype TEXT, I can select.
But power&energy ? is not in the list.
I chose sensortype Electric (instant + counter) but no luck.
For the text type virtual device I get an error after I run the script:
Error while getting data from SOFAR.
- waltervl
- Posts: 5397
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Sofar inverter - simple integration
When I look into the perl script this error occures when the script cannot connect to your SOFAR inverter.
Check this part of the script:
Code: Select all
#SOFARCONF:
my $username='usersofar'; #Your username in SOFAR default admin
my $password='passsofar'; #Your password in SOFAR
my $inverter='192.168.1.88'; # Change to your inverter's IP/hostname
##############END OF CONFIG##################################
Code: Select all
curl -s --user $username:$password http://$inverter/status.html
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 7
- Joined: Thursday 21 March 2024 9:57
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024
- Contact:
Re: Sofar inverter - simple integration
The connection was blocked by my modem:
<HTML><HEAD><TITLE>401 Unauthorized</TITLE></HEAD>
<BODY BGCOLOR="#cc9999"><H4>401 Unauthorized</H4>
Authorization required.
</BODY></HTML>
After unblocking internet use of the inverter (in the fritzbox) I receive a line of data, but domoticz device is not updated after testing the script by:
./sofar.pl
I doubt my inverter answers the data needed.
I see some device info (SSID, LAN IP) but no inverter data.
part of the output:
addCfg('sta_ssid',-secret?-');
addCfg('ap_ssid',-secret?-');
addCfg('lan_ip',-secret?');
addCfg('sta_enable',-secret?-,'1');
var st_con1=""; var st_con2=""; var st_con3=""; function status(re) { var st_en=window.parent.reTip("3"); var st_dis=window.parent.reTip("4");
<HTML><HEAD><TITLE>401 Unauthorized</TITLE></HEAD>
<BODY BGCOLOR="#cc9999"><H4>401 Unauthorized</H4>
Authorization required.
</BODY></HTML>
After unblocking internet use of the inverter (in the fritzbox) I receive a line of data, but domoticz device is not updated after testing the script by:
./sofar.pl
I doubt my inverter answers the data needed.
I see some device info (SSID, LAN IP) but no inverter data.
part of the output:
addCfg('sta_ssid',-secret?-');
addCfg('ap_ssid',-secret?-');
addCfg('lan_ip',-secret?');
addCfg('sta_enable',-secret?-,'1');
var st_con1=""; var st_con2=""; var st_con3=""; function status(re) { var st_en=window.parent.reTip("3"); var st_dis=window.parent.reTip("4");
-
- Posts: 7
- Joined: Thursday 21 March 2024 9:57
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024
- Contact:
Re: Sofar inverter - simple integration
if I login into the webif of the sofar inverter, the status menu is shown with only the device information.
I need to click the connected inverter icon to see data of the inverter itself.
In this way the script can't collect the right data I assume?
I need to click the connected inverter icon to see data of the inverter itself.
In this way the script can't collect the right data I assume?
- Attachments
-
- sofar.jpg (45.18 KiB) Viewed 1409 times
-
- Posts: 7
- Joined: Thursday 21 March 2024 9:57
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024
- Contact:
Re: Sofar inverter - simple integration
http://192.168.x.x/js/status.js
gives more data with a line:
myDeviceArray[0]="SA1xxxxxxx ,V500,,SA1ES116,6 00,20,231,75230,,0,"
Changing the script does not help domoticz showing anything.
Seems the dummy domoticz devices are of a wrong type...
gives more data with a line:
myDeviceArray[0]="SA1xxxxxxx ,V500,,SA1ES116,6 00,20,231,75230,,0,"
Changing the script does not help domoticz showing anything.
Seems the dummy domoticz devices are of a wrong type...
- waltervl
- Posts: 5397
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Sofar inverter - simple integration
This looks similar to the omnik inverter I have. So perhaps try this python plugin: https://github.com/sincze/Domoticz-Omni ... Web-PluginMartjeB wrote: ↑Saturday 13 July 2024 18:36 http://192.168.x.x/js/status.js
gives more data with a line:
myDeviceArray[0]="SA1xxxxxxx ,V500,,SA1ES116,6 00,20,231,75230,,0,"
Changing the script does not help domoticz showing anything.
Seems the dummy domoticz devices are of a wrong type...
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 7
- Joined: Thursday 21 March 2024 9:57
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024
- Contact:
Re: Sofar inverter - simple integration
I just did and it gives me data.
total today in not correct and total yield is 1000 times to high
I also had an error in domoticz:
2024-07-13 19:51:00.980 Error: GetJSonDevices: exception occurred : 'stoll'
might be caused by first selecting webdata in stead of mydevicearray
total today in not correct and total yield is 1000 times to high
I also had an error in domoticz:
2024-07-13 19:51:00.980 Error: GetJSonDevices: exception occurred : 'stoll'
might be caused by first selecting webdata in stead of mydevicearray
- Attachments
-
- read.jpg (9.97 KiB) Viewed 1387 times
-
- solar.jpg (46.32 KiB) Viewed 1387 times
- waltervl
- Posts: 5397
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Sofar inverter - simple integration
Value is Ok. 7523.000 = 7523
Domoticz always show these values with 3 digits.
Domoticz always show these values with 3 digits.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Who is online
Users browsing this forum: No registered users and 0 guests