Issue was previously seen here:
https://www.domoticz.com/forum/viewtopi ... hp#p135033
As not all devices will provide a
"Set Level: 35%" but just
"Set Level". I think it is a Domoticz device bug.
"Set Level: 35%" will work with default Pass2PHP,
"Set Level" definitely not. To Solve it Pass2PHP.php needs a little modification.
Code: Select all
if(in_array($device,array('Lamp (Kastenkamer) (RF)','Lamp (CV Ruimte) (RF)','Lamp (Keukentafel)','Lamp (Keukentafel) (RF)','Lamp (Bank)','Lamp (Bank) (RF)',
'Lamp LED TV','Lamp LED Vensterbank','Lamp LED Tafel (Woonkamer)','Lamp LED Trap','Lamp LED Hal','Lamp LED Keukenkast',
'Xiaomi RGB Gateway','Xiaomi RGB Gateway (Keuken)','Lamp LED Study Left','Lamp LED Study Right','Lamp (Kastenkamer) (RF)' ))) {
if($status=='Off'){
store($device, 0); // 14-04-2019 Pass2PHP 3.0 If one of the above items (dimmers is updated store different values)
}elseif($status=='On'){
store($device, 100); // 14-04-2019 Pass2PHP 3.0 If one of the above items (dimmers is updated store different values)
}elseif( $status==='Set Level' || $status==='Set Color' || empty($status) ) {
store($device, nvalue($device,'Level')); // 14-04-2019 Pass2PHP 3.0 If one of the above items (dimmers is updated store different values)
}else{
$status=filter_var($status,FILTER_SANITIZE_NUMBER_INT);
store($device,$status); // 14-04-2019 Pass2PHP 3.0 If one of the above items (dimmers is updated store different values, dimmer value)
}
}
else {
store($device,$status); // 14-04-2019 Pass2PHP 3.0 If not one of the above items (dimmers is updated store different values)
}
//lgsql('Domoticz',$device,$status);
@include rootdir.'pass2php/'.$device.'.php';
//lg('Pass2php: Called '.$device.' = Received "'.$status.'" status');
}
Within functions I created an additional function
nvalue() to retrieve the missing info from the DB.
Code: Select all
function nvalue($name,$nvalue) // Added: 06-11-2018
{
$idx=idx($name);
$json_string=curl(domoticz.'json.htm?type=devices&rid='.$idx); // retrieve current level
$parsed_json = json_decode($json_string, true);
$parsed_json = $parsed_json['result'][0];
if(array_key_exists($nvalue, $parsed_json)) {
$value=$parsed_json[$nvalue];
}
else $value='NA';
return $value;
}
The patient... a.k.a. the House is running fine for over 12 hours now and no WAF complaints.