- changed webserver to apiserver
- added webserver - a lot of debugging - install shell script
This commit is contained in:
63
archives/etage_bureau_eclairage.php
Normal file
63
archives/etage_bureau_eclairage.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
class etage_bureau_eclairage extends hook
|
||||
{
|
||||
public $hookName = "etage_bureau_eclairage";
|
||||
public $active = true; //enable/disable hook (true => enabled)
|
||||
public $delay = 1; // amount of time in $timeunit
|
||||
public $timeUnit = "hour"; // unit of time for delay, second, minute, hour, day, week, month, year
|
||||
protected $devicelist = array(ETAGE_BUREAU_ECLAIRAGE_INTER => "action");
|
||||
|
||||
// callback fonction. Is called with these 3 parameters
|
||||
// $device -> calling device
|
||||
// $property -> property of the device (given by mqtt)
|
||||
// $value -> value of the property
|
||||
public function callBack($device, $property, $value)
|
||||
{
|
||||
logger(DEBUG, "Callback : " . $this->hookName, __FILE__ . ":" . __LINE__);
|
||||
if($value == "on")
|
||||
{
|
||||
logger(DEBUG, "value: " . $value, __FILE__ . ":" . __LINE__);
|
||||
//if(getValue(ETAGE_BUREAU_PANNEAU, "state") == 'OFF')
|
||||
//{
|
||||
logger(DEBUG, "Bureau panneau state: off", __FILE__ . ":" . __LINE__);
|
||||
$this->send("ON", "OFF");
|
||||
//}
|
||||
}elseif ($value == "off")
|
||||
{
|
||||
//if(getValue(ETAGE_BUREAU_PANNEAU, "state") == 'ON')
|
||||
//{
|
||||
logger(DEBUG, "Bureau panneau state: on", __FILE__ . ":" . __LINE__);
|
||||
$this->send("OFF", false);
|
||||
//}
|
||||
}
|
||||
|
||||
logger (INFO,sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, $value));
|
||||
}
|
||||
|
||||
private function send($state, $delayState = false, $method = MANUAL)
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
|
||||
$device = & $indexDevices[ETAGE_BUREAU_PANNEAU];
|
||||
$msg = array("state" => $state);
|
||||
//if ($device->state_l1["value"] != $state)
|
||||
//{
|
||||
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $device->friendlyName));
|
||||
$device->payload = $msg;
|
||||
$device->set();
|
||||
$device->properties["state"]["method"] = $method;
|
||||
if ($delayState !== false) setDelay($device, $this->delay, $this->timeUnit, "state", $delayState, true);
|
||||
|
||||
|
||||
//}else
|
||||
//{
|
||||
// logger(INFO, sprintf(_("not publishing message: %s to %s, already set"), //json_encode($msg), $device->friendlyName));
|
||||
//}
|
||||
//echo 'delaystate = ' . var_dump($delayState);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$hooks["etage_bureau_eclairage"] = new etage_bureau_eclairage();
|
||||
?>
|
||||
@@ -3,10 +3,10 @@
|
||||
class etage_plan_travail_eclairage extends hook
|
||||
{
|
||||
public $hookName = "etage_plan_travail_eclairage";
|
||||
public $active = false; //enable/disable hook (true => enabled)
|
||||
public $delay = 3; // amount of time in $timeunit
|
||||
public $active = true; //enable/disable hook (true => enabled)
|
||||
public $delay = 1; // 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 => "state");
|
||||
protected $devicelist = array(ETAGE_CUISINE_PLAN_TRAVAIL_INTER => "action");
|
||||
|
||||
// callback fonction. Is called with these 3 parameters
|
||||
// $device -> calling device
|
||||
@@ -14,14 +14,16 @@ class etage_plan_travail_eclairage extends hook
|
||||
// $value -> value of the property
|
||||
public function callBack($device, $property, $value)
|
||||
{
|
||||
logger(DEBUG, sprintf(_("property=%s, value=%s"), $property, $value), __FILE__ . ":" . __LINE__);
|
||||
// here your code
|
||||
if($value == "ON") // ON
|
||||
logger(DEBUG, "Callback : " . $this->hookName, __FILE__ . ":" . __LINE__);
|
||||
if($value == "single")
|
||||
{
|
||||
$this->send("ON", "OFF");
|
||||
}elseif($value == "OFF")
|
||||
{
|
||||
$this->send("OFF", null, AUTO);
|
||||
if(getValue(ETAGE_CUISINE_PLAN_TRAVAIL_ECLAIRAGE, "state") == 'OFF')
|
||||
{
|
||||
$this->send("ON", "OFF");
|
||||
}else
|
||||
{
|
||||
$this->send("OFF", false, null);
|
||||
}
|
||||
}
|
||||
logger (INFO,sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, $value));
|
||||
}
|
||||
@@ -31,18 +33,31 @@ class etage_plan_travail_eclairage extends hook
|
||||
global $devices, $indexDevices;
|
||||
$device = & $indexDevices[ETAGE_CUISINE_PLAN_TRAVAIL_SPOT];
|
||||
$msg = array("state_l1" => $state);
|
||||
if ($device->state_l1["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 ($device->state_l1["value"] != $state)
|
||||
//{
|
||||
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $device->friendlyName));
|
||||
$device->payload = $msg;
|
||||
$device->set();
|
||||
$device->properties["state_l1"]["method"] = $method;
|
||||
if ($delayState !== false) setDelay($device, $this->delay, $this->timeUnit, "state_l1", $delayState, true);
|
||||
|
||||
$device = & $indexDevices[ETAGE_CUISINE_PLAN_TRAVAIL_ECLAIRAGE];
|
||||
$msg = array("state" => $state);
|
||||
//if ($device->state_l1["value"] != $state)
|
||||
//{
|
||||
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $device->friendlyName));
|
||||
$device->payload = $msg;
|
||||
$device->set();
|
||||
$device->properties["state"]["method"] = $method;
|
||||
if ($delayState !== false) setDelay($device, $this->delay, $this->timeUnit, "state", $delayState, true);
|
||||
|
||||
|
||||
//}else
|
||||
//{
|
||||
// logger(INFO, sprintf(_("not publishing message: %s to %s, already set"), //json_encode($msg), $device->friendlyName));
|
||||
//}
|
||||
//echo 'delaystate = ' . var_dump($delayState);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user