i'm new to domoticz and not sure if this is the right place for my question.
Domoticz is running here on a Synology DS-214. Everything is perfect so far but now i wonder how to get data from variables in php script that is running on the same machine into domoticz as a counter. I know Javascript and a little bit PHP. So i made a script to read out data from my solar inverter (Kostal Piko 4.2), see below.
In domoticz i set up a dummy device with a virtual sensor. And now? Is it possible to import the output from my script?
Code: Select all
<?php
/* ########## DATA KOSTAL ########## */
$url = "192.168.11.99";
$username = "user";
$password = "password";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$pos1 = strpos($output,"aktuell</td>");
$pos2 = strpos($output,"</td>",$pos1+20);
$data = substr($output,($pos1+65),$pos2-$pos1-65);
/* # WERT ERTRAG # */
$ertrag = (float) $data;
$pos1 = strpos($output,"Gesamtenergie</td>");
$pos2 = strpos($output,"</td>",$pos1+30);
/* # WERT GESAMTERTRAG # */
$gesamtertrag = substr($output,($pos1+70),$pos2-$pos1-70);
$pos1 = strpos($output,"Tagesenergie</td>");
$pos2 = strpos($output,"</td>",$pos1+30);
/* # WERT TAGESERTRAG # */
$tagesertrag = substr($output,($pos1+70),$pos2-$pos1-70);
echo($ertrag);
echo($tagesertrag);
echo($gesamtertrag);
?>