1
0
This commit is contained in:
Daniel Tartavel 2022-07-07 22:46:05 +02:00
parent c0aef550ab
commit 6e216d776b
11 changed files with 97 additions and 92 deletions

View File

@ -129,11 +129,11 @@ function displayChoice($device, $propertyName, $value)
return $formHTML;
}
function displayMethod($device, $property)
function displayMethod($device, $propertyName)
{
$html = '<input type="button" id="' . $device->topic ."/" . $device->friendlyName . "/" . $propertyName . "/" . strtolower($value) . '" method="' . IDLE . "\" onmouseup=\"setPropertyMethod('" . $device->topic . "', '" . $device->friendlyName . "', '" . IDLE . "', '" . $propertyName . "')\">";
$html = '<input type="button" id="' . $device->topic ."/" . $device->friendlyName . "/" . $propertyName . "/" . strtolower($value) . '" method="' . AUTO . "\" onmouseup=\"setPropertyMethod('" . $device->topic . "', '" . $device->friendlyName . "', '" . AUTO . "', '" . $propertyName . "')\">";
$html = '<input type="button" id="' . $device->topic ."/" . $device->friendlyName . "/" . $propertyName . "/" . strtolower($value) . '" method="' . MANUAL . "\" onmouseup=\"setPropertyMethod('" . $device->topic . "', '" . $device->friendlyName . "', '" . MANUAL . "', '" . $propertyName . "')\">";
$html = '<input type="button" id="' . $device->topic ."/" . $device->friendlyName . "/" . $propertyName . '" method="' . IDLE . "\" onmouseup=\"setPropertyMethod('" . $device->topic . "', '" . $device->friendlyName . "', '" . IDLE . "', '" . $propertyName . "')\">";
$html = '<input type="button" id="' . $device->topic ."/" . $device->friendlyName . "/" . $propertyName . "/" . '" method="' . AUTO . "\" onmouseup=\"setPropertyMethod('" . $device->topic . "', '" . $device->friendlyName . "', '" . AUTO . "', '" . $propertyName . "')\">";
$html = '<input type="button" id="' . $device->topic ."/" . $device->friendlyName . "/" . $propertyName . "/" . '" method="' . MANUAL . "\" onmouseup=\"setPropertyMethod('" . $device->topic . "', '" . $device->friendlyName . "', '" . MANUAL . "', '" . $propertyName . "')\">";
}
function mkHTML($device, $propertyName, $choice)
{

View File

@ -98,7 +98,7 @@ class rdc_salon_eclairage extends hook
//{
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $deviceTarget->friendlyName), __FILE__ . ":" . __LINE__);
$deviceTarget->payload = $msg;
$deviceTarget->set("state", "method");
$deviceTarget->set("state", $method);
//$deviceTarget->properties["state"]["method"] = $method;
/*}else
{

View File

@ -9,7 +9,7 @@ class rdc_sdb_eclairage extends hook
// public $active = true;
//public $initlialized = false;
public $delay = 1; // amount of time in $timeunit
public $delay = 3; // amount of time in $timeunit
public $delayManual = 20; // amount of time in $timeunit for manual mode
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
// list of devices we are listening to

View File

@ -78,37 +78,7 @@ class rdc_store extends hook
$this->storeLevel = 0;
//return true;
}
if (array_key_exists("illuminance_lux", $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties))
{
$exterieur_lux = $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties["illuminance_lux"]["value"];
$exterieurLuxMoyen = $mohaDB->moyenne($indexDevices[RDC_EXTERIEUR_LUMINOSITE], "illuminance_lux", 5);
if ($exterieurLuxMoyen == 0)
{
$exterieurLuxMoyen = $exterieur_lux;
}
logger(DEBUG, "exterieur_lux=" . $exterieur_lux . " et exterieurLuxMoyen=" . $exterieurLuxMoyen, __FILE__ . ":" . __LINE__);
}
if (array_key_exists("illuminance_lux", $indexDevices[RDC_SALON_LUMINOSITE]->properties))
{
$salon_lux = $mohaDB->moyenne($indexDevices[RDC_SALON_LUMINOSITE], "illuminance_lux", 10);
if ($salon_lux == 0)
{
$salon_lux = $indexDevices[RDC_SALON_LUMINOSITE]->properties["illuminance_lux"]["value"];
}
logger(DEBUG, "salon_lux=" . $salon_lux, __FILE__ . ":" . __LINE__);
}
if ($exterieur_lux > 30000 or $salon_lux >600)
{
logger(DEBUG, "exterieur_lux > 30000 or salon_lux >600", __FILE__ . ":" . __LINE__);
if ($this->maxLevel != 0 and $salon_lux > 100)
{
$store2level = $this->storeLevel + 15;
}
}elseif ($exterieurLuxMoyen < 5000 and $salon_lux < 450)
{
logger(DEBUG, "exterieurLuxMoyen < 5000 and salon_lux < 1000", __FILE__ . ":" . __LINE__);
$this->close("Luminosité faible");
}
if (array_key_exists(METEO, $indexDevices))
{
if (array_key_exists("rainin", $indexDevices[METEO]->properties))
@ -150,10 +120,43 @@ class rdc_store extends hook
}
if (array_key_exists("solarradiation", $indexDevices[METEO]->properties))
{
$soleil = $mohaDB->moyenne($indexDevices[METEO], "solarradiation", 12);
$soleil = $mohaDB->moyenne($indexDevices[METEO], "solarradiation", 6);
logger(DEBUG, "soleil=" . $soleil, __FILE__ . ":" . __LINE__);
}
}
if (array_key_exists("illuminance_lux", $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties))
{
$exterieur_lux = $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties["illuminance_lux"]["value"];
$exterieurLuxMoyen = $mohaDB->moyenne($indexDevices[RDC_EXTERIEUR_LUMINOSITE], "illuminance_lux", 5);
if ($exterieurLuxMoyen == 0)
{
$exterieurLuxMoyen = $exterieur_lux;
}
logger(DEBUG, "exterieur_lux=" . $exterieur_lux . " et exterieurLuxMoyen=" . $exterieurLuxMoyen, __FILE__ . ":" . __LINE__);
}
if (array_key_exists("illuminance_lux", $indexDevices[RDC_SALON_LUMINOSITE]->properties))
{
$salon_lux = $mohaDB->moyenne($indexDevices[RDC_SALON_LUMINOSITE], "illuminance_lux", 10);
if ($salon_lux == 0)
{
$salon_lux = $indexDevices[RDC_SALON_LUMINOSITE]->properties["illuminance_lux"]["value"];
}
logger(DEBUG, "salon_lux=" . $salon_lux, __FILE__ . ":" . __LINE__);
}
if ($exterieur_lux > 33000 or $salon_lux >600)
{
logger(DEBUG, "exterieur_lux > 33000 or salon_lux >600", __FILE__ . ":" . __LINE__);
if ($this->maxLevel != 0 and $salon_lux > 100)
{
$store2level = $this->storeLevel + 15;
}
}elseif ($exterieurLuxMoyen < 6000 and $salon_lux < 200 and $soleil < 100)
{
logger(DEBUG, "exterieurLuxMoyen < 6000 and salon_lux < 200 and soleil < 100", __FILE__ . ":" . __LINE__);
$this->close("Luminosité faible");
}
logger(DEBUG, sprintf(_("property=%s, value=%s"), $property, $value), __FILE__ . ":" . __LINE__);
if ($rafale >= 70 or $rain != 0)
{

View File

@ -78,37 +78,7 @@ class rdc_store extends hook
$this->storeLevel = 0;
//return true;
}
if (array_key_exists("illuminance_lux", $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties))
{
$exterieur_lux = $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties["illuminance_lux"]["value"];
$exterieurLuxMoyen = $mohaDB->moyenne($indexDevices[RDC_EXTERIEUR_LUMINOSITE], "illuminance_lux", 5);
if ($exterieurLuxMoyen == 0)
{
$exterieurLuxMoyen = $exterieur_lux;
}
logger(DEBUG, "exterieur_lux=" . $exterieur_lux . " et exterieurLuxMoyen=" . $exterieurLuxMoyen, __FILE__ . ":" . __LINE__);
}
if (array_key_exists("illuminance_lux", $indexDevices[RDC_SALON_LUMINOSITE]->properties))
{
$salon_lux = $mohaDB->moyenne($indexDevices[RDC_SALON_LUMINOSITE], "illuminance_lux", 10);
if ($salon_lux == 0)
{
$salon_lux = $indexDevices[RDC_SALON_LUMINOSITE]->properties["illuminance_lux"]["value"];
}
logger(DEBUG, "salon_lux=" . $salon_lux, __FILE__ . ":" . __LINE__);
}
if ($exterieur_lux > 30000 or $salon_lux >600)
{
logger(DEBUG, "exterieur_lux > 30000 or salon_lux >600", __FILE__ . ":" . __LINE__);
if ($this->maxLevel != 0 and $salon_lux > 100)
{
$store2level = $this->storeLevel + 15;
}
}elseif ($exterieurLuxMoyen < 5000 and $salon_lux < 450)
{
logger(DEBUG, "exterieurLuxMoyen < 5000 and salon_lux < 1000", __FILE__ . ":" . __LINE__);
$this->close("Luminosité faible");
}
if (array_key_exists(METEO, $indexDevices))
{
if (array_key_exists("rainin", $indexDevices[METEO]->properties))
@ -150,10 +120,43 @@ class rdc_store extends hook
}
if (array_key_exists("solarradiation", $indexDevices[METEO]->properties))
{
$soleil = $mohaDB->moyenne($indexDevices[METEO], "solarradiation", 12);
$soleil = $mohaDB->moyenne($indexDevices[METEO], "solarradiation", 6);
logger(DEBUG, "soleil=" . $soleil, __FILE__ . ":" . __LINE__);
}
}
if (array_key_exists("illuminance_lux", $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties))
{
$exterieur_lux = $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties["illuminance_lux"]["value"];
$exterieurLuxMoyen = $mohaDB->moyenne($indexDevices[RDC_EXTERIEUR_LUMINOSITE], "illuminance_lux", 5);
if ($exterieurLuxMoyen == 0)
{
$exterieurLuxMoyen = $exterieur_lux;
}
logger(DEBUG, "exterieur_lux=" . $exterieur_lux . " et exterieurLuxMoyen=" . $exterieurLuxMoyen, __FILE__ . ":" . __LINE__);
}
if (array_key_exists("illuminance_lux", $indexDevices[RDC_SALON_LUMINOSITE]->properties))
{
$salon_lux = $mohaDB->moyenne($indexDevices[RDC_SALON_LUMINOSITE], "illuminance_lux", 10);
if ($salon_lux == 0)
{
$salon_lux = $indexDevices[RDC_SALON_LUMINOSITE]->properties["illuminance_lux"]["value"];
}
logger(DEBUG, "salon_lux=" . $salon_lux, __FILE__ . ":" . __LINE__);
}
if ($exterieur_lux > 33000 or $salon_lux >600)
{
logger(DEBUG, "exterieur_lux > 33000 or salon_lux >600", __FILE__ . ":" . __LINE__);
if ($this->maxLevel != 0 and $salon_lux > 100)
{
$store2level = $this->storeLevel + 15;
}
}elseif ($exterieurLuxMoyen < 6000 and $salon_lux < 200 and $soleil < 100)
{
logger(DEBUG, "exterieurLuxMoyen < 11000 and salon_lux < 1000", __FILE__ . ":" . __LINE__);
$this->close("Luminosité faible");
}
logger(DEBUG, sprintf(_("property=%s, value=%s"), $property, $value), __FILE__ . ":" . __LINE__);
if ($rafale >= 70 or $rain != 0)
{
@ -191,17 +194,17 @@ class rdc_store extends hook
logger(DEBUG, "maxLevel = " . $this->maxLevel . ' result => $r = ' . $r, __FILE__ . ":" . __LINE__);
if ($this->storeLevel > $this->maxLevel)
{
$this->setTo($this->maxLevel);
$this->setTo($this->maxLevel, AUTO);
}elseif ($store2level !== false) //$store2level = false then no change on store position
{
if ( $store2level > $this->maxLevel )
{
logger(DEBUG, "store2level > maxLevel", __FILE__ . ":" . __LINE__);
$this->setTo($this->maxLevel);
$this->setTo($this->maxLevel, AUTO);
}else
{
logger(DEBUG, "store2level <= maxLevel", __FILE__ . ":" . __LINE__);
$this->setTo($store2level);
$this->setTo($store2level, AUTO);
}
}
}else
@ -211,13 +214,13 @@ class rdc_store extends hook
}
private function setTo($level)
private function setTo($level, $method)
{
logger(DEBUG, "function 'set' to level : " . $level, __FILE__ . ":" . __LINE__);
if ($level <= 100)
{
logger(DEBUG, "Open store :" . $level, __FILE__ . ":" . __LINE__);
$this->send(100 - $level, AUTO);
$this->send(100 - $level, $method);
}//else
/*{
logger(DEBUG, "store is already at level" . $this->storeLevel . " so < at " . $level, __FILE__ . ":" . __LINE__);

View File

@ -10,7 +10,7 @@ class rdc_wc_eclairage extends hook
RDC_WC_MVMT => "occupancy"
);
public $delay = 1; // amount of time in $timeunit
public $delay = 3; // amount of time in $timeunit
public $delayManual = 10; // amount of time in $timeunit for manual mode
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
@ -41,6 +41,7 @@ class rdc_wc_eclairage extends hook
break;
case "occupancy":
logger(DEBUG, "CASE: occupancy", __FILE__ . ":" . __LINE__);
logger(DEBUG, "method =" . $targetDevice->properties["state_l2"]["method"], __FILE__ . ":" . __LINE__);
if ($value === true and $targetDevice->properties["state_l2"]["method"] == IDLE)
{
//$targetDevice->properties["state_l2"]["method"] = AUTO;

View File

@ -41,10 +41,11 @@ class rdc_wc_eclairage extends hook
break;
case "occupancy":
logger(DEBUG, "CASE: occupancy", __FILE__ . ":" . __LINE__);
logger(DEBUG, "method =" . $targetDevice->properties["state_l2"]["method"], __FILE__ . ":" . __LINE__);
if ($value === true and $targetDevice->properties["state_l2"]["method"] == IDLE)
{
$targetDevice->properties["state_l2"]["method"] = AUTO;
$this->send($targetDevice, "ON");
//$targetDevice->properties["state_l2"]["method"] = AUTO;
$this->send($targetDevice, "ON", AUTO);
}elseif ($value === false and $targetDevice->properties["state_l2"]["method"] == AUTO)
{
//$targetDevice->properties["state_l2"]["method"] = IDLE;
@ -54,14 +55,14 @@ class rdc_wc_eclairage extends hook
}
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($targetDevice, $state)
private function send($targetDevice, $state, $method = IDLE)
{
global $indexDevices;
$msg = array("state_l2" => $state);
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $targetDevice->friendlyName), __FILE__ . ":" . __LINE__);
$targetDevice->payload = $msg;
$targetDevice->set(null);
$targetDevice->set("state_l2", $method);
}
}

View File

@ -50,7 +50,7 @@ if ($testMode)
$httpServerIp = "192.168.1.253";
}else
{
$logLevel = DEBUG | INFO | NOTICE | WARNING | ERROR | ALERT;
$logLevel = INFO | NOTICE | WARNING | ERROR | ALERT;
$mqttServerIp = "127.0.0.1"; // IP address of mqttserver in production mode
$dataPath = "/usr/share/moha/";
$logFile = "/var/log/moha.log"; // Path of log file

View File

@ -177,7 +177,13 @@ function diagramDisplay($datas)
}
$tmp = explode("|", $_GET["device"]);
if (!empty($tmp[0]) && !empty($tmp[1]) && !empty($tmp[2]))
{
displayStats($tmp[0], $tmp[1], $tmp[2], $_GET["startDate"], $_GET["endDate"]);
}else
{
logger(ERROR, "Your syntax is bad");
}
displayStats($tmp[0], $tmp[1], $tmp[2], $_GET["startDate"], $_GET["endDate"]);
?>

View File

@ -33,7 +33,7 @@ if (empty($indexIeeeAddress))
$devicesList[$value["device"]][] = $value["property"];
}
}
array_multisort($devicesList);
ksort($devicesList, SORT_STRING );
//$devicesList = array_intersect_key($indexIeeeAddress, $tmp);
//print_r($devicesList);

View File

@ -1,9 +0,0 @@
<?php
require "class/db.php";
require "header.php";
require "menu.php";
?>