Egregius wrote: ↑Saturday 18 August 2018 13:05
I would indeed put it in cron120 or cron300 at the end of the file so it doesn't slow down the rest. Or put it in a separate script and call that at the end of cron.
Tnx for the tip at the end of Cron300.php
- Cron line calls function OmnikInverterUpdate() within pass2php library to update the omnik devices.
- The function calls 1 script 3 times (1 for each inverter)
Code: Select all
function OmnikInverterUpdate()
{
shell_exec(domoticz_location.'scripts/pass2php/omnikwebinverter.sh "Omnik_1" > /dev/null 2>/dev/null &');
shell_exec(domoticz_location.'scripts/pass2php/omnikwebinverter.sh "Omnik_2" > /dev/null 2>/dev/null &');
shell_exec(domoticz_location.'scripts/pass2php/omnikwebinverter.sh "Omnik_3" > /dev/null 2>/dev/null &');
}
omnikwebinverter.sh calls a omnikwebinverter.php via the local webserver.
As the device name (Omnik_1) is passed as a parameter the omnikwebinverter.php can update the device using that name and you 'ud' function.
Maybe there is a better solution, but it is working
I could ofcourse move all inverter data to omnikwebinverter.php and have just 1 call
like so.
Code: Select all
function OmnikInverterUpdate()
{
shell_exec(domoticz_location.'scripts/pass2php/omnikwebinverter.sh "all" > /dev/null 2>/dev/null &');
}
Code: Select all
function retrieve_omnik_data($command)
{
// $device=$command;
$to_inverters = array(
array( 'device' => "Omnik 1", 'username' => 1_user, 'password' => 1_pwd, 'id' => 1_id ),
array( 'device' => "Omnik 2", 'username' => 2_user, 'password' => 2_pwd, 'id' => 2_id ),
array( 'device' => "Omnik 3", 'username' => 3_user, 'password' => 3_pwd, 'id' => 3_id )
);
foreach ($to_inverters as $item)
{
$inverter = new \OmnikWebInverter\OmnikWebInverter($item['username'],$item['password'],$item['id']);
$result=$inverter->omnikdata();
$device=$item['device'];
$str= ( round($result[0]).';'.($result[1]*1000) );
lg('Omnik: '.$device.' result: '.round($result[0]).' and: '.$result[1].' for domoticz: '.$str);
if ( isset($result[0]) && isset($result[1]) ) ud($device,0,$str,'Omnik: Inverter: Generation updated');
}
}
Also working a well multiple roads to Rome...