Page 2 of 2

Re: Import data from Fronius Solar api

Posted: Monday 01 August 2016 6:30
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 ;)

Re: Import data from Fronius Solar api

Posted: Thursday 11 August 2016 18:21
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

Re: Import data from Fronius Solar api

Posted: Wednesday 09 February 2022 21:56
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