1
0

- debug\n- webserver fonctionnel

This commit is contained in:
2022-03-04 22:30:16 +01:00
parent a29aa9b653
commit 9d10e51a24
17 changed files with 273 additions and 128 deletions

View File

@@ -26,21 +26,27 @@ class rdc_chambre_eclairage extends hook
$targetAmbiance = $indexDevices[RDC_CHAMBRE_AMBIANCE];
$targetEclairage = $indexDevices[RDC_CHAMBRE_ECLAIRAGE];
if ($property == "occupancy" and $value == "ON")
if ($property == "occupancy" and $value == ON)
{
$this->send($targetAmbiance, "ON", "OFF", AUTO);
}elseif ($property == "contact" and $value = true and getValue(RDC_CHAMBRE_ECLAIRAGE, "state_l1") == "OFF")
$this->send($targetAmbiance, "state", "ON", "OFF", AUTO);
}elseif ($property == "contact")
{
$this->send($targetEclairage, "ON", "OFF", AUTO);
if ($value == false and getValue(RDC_CHAMBRE_ECLAIRAGE, "state_l1") == "OFF")
{
$this->send($targetEclairage, "state_l1", "ON", "OFF", AUTO);
}elseif ($value == true and getValue(RDC_CHAMBRE_ECLAIRAGE, "state_l1") == "ON")
{
$this->send($targetEclairage, "state_l1", "OFF", null, null);
}
}
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__);
}
private function send($deviceObject, $state, $delayState = false, $method = MANUAL)
private function send($deviceObject, $property, $state, $delayState = false, $method = MANUAL)
{
global $devices, $indexDevices;
$msg = array("state_l1" => $state);
if ($deviceObject->properties["state_l1"]["value"] != $state)
$msg = array($property => $state);
if ($deviceObject->properties[$property]["value"] != $state)
{
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $deviceObject->friendlyName), __FILE__ . ":" . __LINE__);
$deviceObject->payload = $msg;