- added values in celsius degree and in km/h in pws2mqtt
- debug of hooks -added webserver.php
This commit is contained in:
@ -6,15 +6,7 @@ class etage_plan_travail_eclairage extends hook
|
||||
public $active = true; //enable/disable hook (true => enabled)
|
||||
public $delay = 3; // amount of time in $timeunit
|
||||
public $timeUnit = "hour"; // unit of time for delay, second, minute, hour, day, week, month, year
|
||||
protected $devicelist = array("ETAGE_CUISINE_PLAN_TRAVAIL_ECLAIRAGE" => array("action", false));
|
||||
|
||||
// if you need some initialisation when creating the object, uncomment andput your code here.
|
||||
// If existing, This function is called by __construct
|
||||
/*protected function init()
|
||||
{
|
||||
// Your code here
|
||||
}
|
||||
*/
|
||||
protected $devicelist = array("ETAGE_CUISINE_PLAN_TRAVAIL_ECLAIRAGE" => array("state", false));
|
||||
|
||||
// callback fonction. Is called with these 3 parameters
|
||||
// $device -> calling device
|
||||
@ -47,7 +39,6 @@ class etage_plan_travail_eclairage extends hook
|
||||
}else
|
||||
{
|
||||
logger(INFO, sprintf(_("not publishing message: %s to %s, already set"), json_encode($msg), $device->friendlyName));
|
||||
|
||||
}
|
||||
//echo 'delaystate = ' . var_dump($delayState);
|
||||
if ($delayState !== false) setDelay($device, $this->delay, $this->timeUnit, "state", $delayState, true);
|
||||
|
@ -3,17 +3,17 @@
|
||||
class rdc_chambre_eclairage extends hook
|
||||
{
|
||||
public $hookName = "rdc_chambre_eclairage";
|
||||
public $active = false; //enable/disable hook (true => enabled)
|
||||
|
||||
protected $devicelist = array();
|
||||
|
||||
// if you need some initialisation when creating the object, uncomment andput your code here.
|
||||
// If existing, This function is called by __construct
|
||||
/*protected function init()
|
||||
{
|
||||
// Your code here
|
||||
}
|
||||
*/
|
||||
public $active = false; //enable/disable hook (true => enabled)
|
||||
public $delay = 5; // amount of time in $timeunit
|
||||
public $timeUnit = "minute"; // unit of time for delay, second, minute, hour, day, week, month, year
|
||||
public $luminance_min = 60;
|
||||
public $luminance_max = 3000;
|
||||
protected $devicelist = array(
|
||||
"RDC_CHAMBRE_AMBIANCE" => array("state", false),
|
||||
"RDC_CHAMBRE_ECLAIRAGE" => array("state_l1", false),
|
||||
"RDC_CHAMBRE_MVMT" => array("occupancy", false),
|
||||
"RDC_CHAMBRE_ARMOIRE_GAUCHE" => array("contact", false)
|
||||
);
|
||||
|
||||
// callback fonction. Is called with these 3 parameters
|
||||
// $device -> calling device
|
||||
@ -21,9 +21,33 @@ class rdc_chambre_eclairage extends hook
|
||||
// $value -> value of the property
|
||||
public function callBack(&$device, $property, $value)
|
||||
{
|
||||
// here your code
|
||||
global $devices, $indexDevices;
|
||||
$lux = $indexDevices[RDC_CHAMBRE_LUMINOSITE]->illuminance_lux;
|
||||
if ($property == "occupancy" and $value == "ON")
|
||||
{
|
||||
$this->send(RDC_CHAMBRE_LUMINOSITE, "ON", "OFF", AUTO);
|
||||
}
|
||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, $value));
|
||||
}
|
||||
|
||||
logger (INFO,sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, $value));
|
||||
private function send($device, $state, $delayState = false, $method = MANUAL)
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
$device = &$indexDevices[$device];
|
||||
$msg = array("state" => $state);
|
||||
if ($device->state["value"] != $state)
|
||||
{
|
||||
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $device->friendlyName));
|
||||
$device->payload = $msg;
|
||||
$device->set();
|
||||
$device->method = $method;
|
||||
}else
|
||||
{
|
||||
logger(INFO, sprintf(_("not publishing message: %s to %s, already set"), json_encode($msg), $device->friendlyName));
|
||||
|
||||
}
|
||||
//echo 'delaystate = ' . var_dump($delayState);
|
||||
if ($delayState !== false) setDelay($device, $this->delay, $this->timeUnit, "state", $delayState, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ class rdc_salon_eclairage extends hook
|
||||
RDC_SALON_LUMINOSITE => array("illuminance_lux", false)
|
||||
);
|
||||
|
||||
public $delay = 5; // amount of time in $timeunit
|
||||
public $delay = 3; // amount of time in $timeunit
|
||||
public $timeUnit = "minute"; // unit of time for delay, second, minute, hour, day, week, month, year
|
||||
public $luminance_min = 60;
|
||||
public $luminance_max = 3000;
|
||||
@ -28,19 +28,29 @@ class rdc_salon_eclairage extends hook
|
||||
//print_r($indexDevices[RDC_SALON_LUMINOSITE]);
|
||||
if ($value == ON and $indexDevices[RDC_SALON_LUMINOSITE]->illuminance_lux["value"] <= $this->luminance_min)
|
||||
{
|
||||
$this->send("ON", "OFF", AUTO);
|
||||
$this->send("ON", null, AUTO);
|
||||
removeEvent($indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU], "state", "OFF");
|
||||
}
|
||||
if ($value == OFF)
|
||||
{
|
||||
if ($indexDevices(RDC_SALON_MVMT)->occupancy == OFF and $indexDevices(RDC_SALON_MVMT2)->occupancy == OFF)
|
||||
{
|
||||
setDelay($indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU], $this->delay, $this->timeUnit, "state", "OFF", true);
|
||||
//$this->send("ON", "OFF", AUTO);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "contact":
|
||||
if ($value == false and $indexDevices[RDC_SALON_LUMINOSITE]->illuminance_lux["value"] <= $this->luminance_min)
|
||||
{
|
||||
$this->send("ON", "OFF", AUTO);
|
||||
//$this->send("ON", "OFF", AUTO);
|
||||
}
|
||||
break;
|
||||
case "illuminance_lux":
|
||||
if ($value >= $this->luminance_max)
|
||||
{
|
||||
$this->send("OFF");
|
||||
//$this->send("OFF", null, AUTO);
|
||||
removeEvent($indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU], "state", "OFF");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user