Import data from Fronius Solar api

Moderator: leecollings

User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Import data from Fronius Solar api

Post by Egregius »

Maybe cleaner for the forum to start a new topic?
Anyway, start at least with a function for the udevice command, code will be lot's smaller and easier to read. Maybe that already shows you where it went wrong:

Code: Select all

#!/usr/bin/php
<?php
$data = array();
inizio:
$x = exec("/usr/local/bin/sdm120c -v -c -p -g -f -e -i -t -q -w3 -z5 /dev/ttyUSB0");
$data = preg_split('/[[:space:]]+/', $x);
if ($data[8] = 'OK') {
  $tensione = udevice(1,0,$data[0]);
  $corrente = udevice(2,0,$data[1]);
  $potenza = $data[2];
  $cosfi = udevice(4,0,$data[3]);
  //$frequenza_2 = $data[4];
  $immessa = udevice(43,0,$data[5]);
  $prelevata = udevice(44,0,$data[6]);
  $energia = udevice(3,0,$data[7]);
}

sleep(2);
goto inizio;

function udevice($idx,$nvalue,$svalue) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://192.168.X.XXX:8080/json.htm?type=command&param=udevice&idx=$idx&nvalue=$nvalue&svalue=$svalue");
    curl_exec($ch);
    curl_close($ch);
}
Your sleep was commented (//) wich mean this script would constantly call domoticz for the update commands. Even with a 2 sec sleep... Do you really need that frequent updates for all these devices? Do you even need all of them?
I like to keep my Domoticz and the number of commands as clean and low as possible, I only put the needed data for automation. That garantees a light and fast system.

Tip for the forum: if you use code=php /code instead of code /code the code is colored ;)
videodrome
Posts: 64
Joined: Wednesday 11 May 2016 16:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Import data from Fronius Solar api

Post by videodrome »

Egregius wrote:Maybe cleaner for the forum to start a new topic?
Open a new topic here:
http://www.domoticz.com/forum/viewtopic ... 948#p93055
User avatar
psubiaco
Posts: 222
Joined: Monday 20 August 2018 9:38
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Italy
Contact:

Re: Import data from Fronius Solar api

Post by psubiaco »

I've just created the Fronius page in Domoticz wiki, with the script from GeyerA revised to get data from the Inverter.
It works well even during the night, when the inverter is off.
https://www.domoticz.com/wiki/Fronius_inverter
Paolo
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest