1
0
moha/scripts/panneau_salon.php

33 lines
836 B
PHP
Raw Normal View History

2021-12-30 16:18:32 +01:00
<?php
$scriptTopic = Z2M;
//callback function
$rdcPanneau = function($topic, $fn, $param, $value)
{
global $devices, $indexDevices;
$delay = 3;
$timeUnit = "min";
2021-12-30 16:18:32 +01:00
switch($param)
{
case "occupancy":
if ($value == 1)
{
$msg = array("state" => "ON");
$device = $devices[Z2M][$indexDevices["0x588e81fffe343e8f"]];
$device->payload = $msg;
$device->set(null);
setDelay($device, $delay, $timeUnit, "state", "OFF", true);
2021-12-30 16:18:32 +01:00
}
break;
}
echo _("notification received from MQTT") . EOL;
//echo $param . "=> " . $value . EOL;
2021-12-30 16:18:32 +01:00
};
//assignation of the function to the sensors devices
$indexDevices["0x00124b0022ebac5c"]->functions[] = $rdcPanneau;
$indexDevices["0x588e81fffe2cf695"]->functions[] = $rdcPanneau;
$indexDevices["0x04cf8cdf3c78aff0"]->functions[] = $rdcPanneau;
2021-12-30 16:18:32 +01:00
?>