hooks are now classes and devices scan exposes to add properties
This commit is contained in:
2
hooks/notifiers/notificationfreemobile.php
Normal file
2
hooks/notifiers/notificationfreemobile.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
$notificationMethods["freemobile"] = new notificationMethod("https://smsapi.free-mobile.fr/sendmsg?user=32886706&pass=JTGUY6l5OG73zX&msg=");
|
56
hooks/scripts/panneau_salon.php
Normal file
56
hooks/scripts/panneau_salon.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
class panneau_salon
|
||||
{
|
||||
private $devicelist = array("0x00124b0022ebac5c", "0x588e81fffe2cf695", "0x00124b001f900753", "0x04cf8cdf3c78aff0");
|
||||
public $delay = 3;
|
||||
public $timeUnit = "min";
|
||||
|
||||
function __construct()
|
||||
{
|
||||
global $indexDevices;
|
||||
foreach ($this->devicelist as $ieeeAddress)
|
||||
{
|
||||
$indexDevices[$ieeeAddress]->functions[] = array($this,"callback");
|
||||
//print_r($indexDevices[$ieeeAddress]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function callBack($topic, $fn, $param, $value)
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
|
||||
switch($param)
|
||||
{
|
||||
case "occupancy":
|
||||
if ($value == 1) $this->send();
|
||||
break;
|
||||
case "contact":
|
||||
if ($value == false) $this->send();
|
||||
break;
|
||||
}
|
||||
echo _("notification received from MQTT") . EOL;
|
||||
//echo $param . "=> " . $value . EOL;
|
||||
}
|
||||
|
||||
private function send()
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
if ($indexDevices["0x04cf8cdf3c78aff0"]->illuminance_lux <= 76)
|
||||
{
|
||||
$msg = array("state" => "ON");
|
||||
$device = & $indexDevices["0x588e81fffe343e8f"];
|
||||
$device->payload = $msg;
|
||||
$device->set(null);
|
||||
setDelay($device, $this->delay, $this->timeUnit, "state", "OFF", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$panneau_salon = new panneau_salon();
|
||||
//assignation of the function to the sensors devices
|
||||
//$indexDevices["0x00124b0022ebac5c"]->functions[] = array($panneau_salon,"getCallback"); // rdc-salon-mvmt2
|
||||
//$indexDevices["0x588e81fffe2cf695"]->functions[] = array($panneau_salon,"getCallback"); // rdc-salon-mvmt
|
||||
//$indexDevices["0x00124b001f900753"]->functions[] = array($panneau_salon,"getCallback"); // rdc-porte-entree
|
||||
//$indexDevices["0x04cf8cdf3c78aff0"]->functions[] = array($panneau_salon,"getCallback"); // rdc-salon-luminosite
|
||||
?>
|
Reference in New Issue
Block a user