I created this script to read the txt file that is stored in the inverter web server.
Code: Select all
#!/usr/bin/php
<?php
########## DATA SUNWAYS ##########
$url = "http://13.3.89.50";
$username = "customer";
$password = "00000000";
$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);
curl_close($ch);
// Open the file
$fp = @fopen("http://13.3.89.50/data/sys.txt", 'r');
// Delete # & filter
$fp = explode('#', $input);
$actualPower = filter_var($fp[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
$dailyPower = filter_var($fp[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
$totalPower = filter_var($fp[5],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
fclose($fp);
########## PUSH DATA TO DOMOTICZ ########## */
$url = '13.3.89.3:8080/json.htm?'';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url.http_build_query(
array(
'type' => 'command',
'param' => 'udevice',
'idx' => '21',
'svalue' => $actualPower
)
)
);
curl_exec ($ch);
curl_close ($ch);
?>
Where is the bug?