2022-01-06 13:03:26 +01:00
< ? php
2022-01-17 00:18:50 +01:00
class rdc_wc_eclairage extends hook
2022-01-06 13:03:26 +01:00
{
public $hookName = " rdc_wc_eclairage " ;
2022-01-17 00:18:50 +01:00
protected $devicelist = array ( RDC_SDB_WC_ECLAIRAGE => array ( " state_l2 " , false ));
2022-01-06 13:03:26 +01:00
public $delay = 3 ; // amount of time in $timeunit
2022-01-20 00:26:57 +01:00
public $delayManual = 8 ; // amount of time in $timeunit for manual mode
2022-01-06 13:03:26 +01:00
public $timeUnit = " minute " ; // unit of time for delay, second, minute, day, week, month, year
// callback fonction. Is called with these 4 parameters
public function callBack ( & $device , $property , $value )
{
global $devices , $indexDevices ;
2022-01-23 09:46:06 +01:00
//var_dump($value);
2022-01-06 13:03:26 +01:00
switch ( $property )
{
case " state_l2 " :
2022-01-20 00:26:57 +01:00
if ( $value == " ON " )
2022-01-06 13:03:26 +01:00
{
setDelay ( $device , $this -> delayManual , $this -> timeUnit , " state_l2 " , " OFF " , true );
$device -> method = MANUAL ;
2022-01-20 00:26:57 +01:00
} elseif ( $value = " OFF " )
2022-01-06 13:03:26 +01:00
{
deleteEvent ( searchEvent ( $device , " state_l2 " , " OFF " ));
}
break ;
}
2022-01-28 23:05:58 +01:00
logger ( INFO , sprintf ( _ ( " %s: notification received from MQTT from %s => parameter: %s value: %s " ), $this -> hookName , $device -> friendlyName , $property , $value ), __FILE__ . " : " . __LINE__ );
2022-01-06 13:03:26 +01:00
}
}
$hooks [ " rdc_wc_eclairage " ] = new rdc_wc_eclairage ();
?>