From 4e04dfdfd61ab2aeda0cbdb46f7ce04a7497bc53 Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Fri, 5 Aug 2022 17:24:11 +0200 Subject: [PATCH] Minor modif to moha.php\nDebug\nAdded script rdc_temperature_int_ext --- config/dashboard_conf.php | 1 + hooks/scripts/rdc_sdb_eclairage.php | 1 + hooks/scripts/rdc_temperature_int_ext.php | 28 +++++++++++++++++++++++ hooks/scripts/rdc_wc_eclairage.php | 4 +++- hooks/scripts/rdc_wc_eclairage.php~ | 12 ++++++---- moha.php | 3 ++- 6 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 hooks/scripts/rdc_temperature_int_ext.php diff --git a/config/dashboard_conf.php b/config/dashboard_conf.php index e437a3d..d4583b7 100644 --- a/config/dashboard_conf.php +++ b/config/dashboard_conf.php @@ -8,6 +8,7 @@ array(RDC_SDB_TEMP_HUM, "temperature"), array(RDC_SDB_RADIATEUR, "current_heating_setpoint"), array(METEO, "tempc"), + array(METEO, "indoortempc"), array(METEO, "humidity"), array(METEO, "winddir"), array(METEO, "windspeedkmh"), diff --git a/hooks/scripts/rdc_sdb_eclairage.php b/hooks/scripts/rdc_sdb_eclairage.php index 292bd73..c1b50fb 100644 --- a/hooks/scripts/rdc_sdb_eclairage.php +++ b/hooks/scripts/rdc_sdb_eclairage.php @@ -52,6 +52,7 @@ class rdc_sdb_eclairage extends hook { logger(DEBUG, _("Actionneurs are all false"), __FILE__ . ":" . __LINE__); //setDelay($deviceTarget, $this->delay, $this->timeUnit, "state_l1", "OFF", true, IDLE); + $this->send("OFF", IDLE); } break; case "state_l1": diff --git a/hooks/scripts/rdc_temperature_int_ext.php b/hooks/scripts/rdc_temperature_int_ext.php new file mode 100644 index 0000000..4a0a44b --- /dev/null +++ b/hooks/scripts/rdc_temperature_int_ext.php @@ -0,0 +1,28 @@ + enabled) + + protected $devicelist = array( + METEO=> "tempc", + ); + + // callback fonction. Is called with these 4 parameters + public function callBack(&$device, $property, $value) + { + global $indexDevices; + if ($device->properties["indoortempc"]["value"] > $value) + { + logger(ALERT, _("Indoor temperature is superior to outdoor one")) + }elseif ($device->properties["indoortempc"]["value"] < $value) + { + logger(ALERT, _("Indoor temperature is inferior to outdoor one")) + } + logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__); + } +} + +$hooks["rdc_temperature_int_ext"] = new rdc_temperature_int_ext(); +?> diff --git a/hooks/scripts/rdc_wc_eclairage.php b/hooks/scripts/rdc_wc_eclairage.php index dbd0d1b..f861244 100644 --- a/hooks/scripts/rdc_wc_eclairage.php +++ b/hooks/scripts/rdc_wc_eclairage.php @@ -46,11 +46,13 @@ class rdc_wc_eclairage extends hook { //$targetDevice->properties["state_l2"]["method"] = AUTO; $this->send($targetDevice, "ON", AUTO); + removeEvent($targetDevice, "state_l2", "OFF"); }elseif ($value === false and $targetDevice->properties["state_l2"]["method"] == AUTO) { //$targetDevice->properties["state_l2"]["method"] = IDLE; //$this->send($targetDevice, "OFF"); - setDelay($targetDevice, $this->delay, $this->timeUnit, "state_l2", "OFF", true, IDLE); + //setDelay($targetDevice, $this->delay, $this->timeUnit, "state_l2", "OFF", true, IDLE); + $this->send($targetDevice, "OFF", IDLE); } } logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__); diff --git a/hooks/scripts/rdc_wc_eclairage.php~ b/hooks/scripts/rdc_wc_eclairage.php~ index 68d3e3b..f861244 100644 --- a/hooks/scripts/rdc_wc_eclairage.php~ +++ b/hooks/scripts/rdc_wc_eclairage.php~ @@ -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 @@ -31,26 +31,28 @@ class rdc_wc_eclairage extends hook if ($targetDevice->properties["state_l2"]["method"] == IDLE) { $targetDevice->properties["state_l2"]["method"] = MANUAL; - setDelay($device, $this->delayManual, $this->timeUnit, "state_l2", "OFF", true); + setDelay($targetDevice, $this->delayManual, $this->timeUnit, "state_l2", "OFF", true); } }elseif ($value == "OFF") { $targetDevice->properties["state_l2"]["method"] = IDLE; - removeEvent($device, "state_l2", "OFF"); + removeEvent($targetDevice, "state_l2", "OFF"); } break; case "occupancy": - logger(DEBUG, "CASE: occupancy", __FILE__ . ":" . __LINE__); + logger(DEBUG, "CASE: WC 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", AUTO); + removeEvent($targetDevice, "state_l2", "OFF"); }elseif ($value === false and $targetDevice->properties["state_l2"]["method"] == AUTO) { //$targetDevice->properties["state_l2"]["method"] = IDLE; //$this->send($targetDevice, "OFF"); - setDelay($device, $this->delay, $this->timeUnit, "state_l2", "OFF", true, IDLE); + //setDelay($targetDevice, $this->delay, $this->timeUnit, "state_l2", "OFF", true, IDLE); + $this->send($targetDevice, "OFF", IDLE); } } logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__); diff --git a/moha.php b/moha.php index c782551..b866e5a 100644 --- a/moha.php +++ b/moha.php @@ -176,7 +176,7 @@ function connect2mqttServer() global $client; $client->onConnect('connectResponse'); } -logger(WARNING, _("starting moha"), __FILE__ . ":" . __LINE__); +logger(ALERT, _("starting moha"), __FILE__ . ":" . __LINE__); logger(DEBUG, _("requiring config files -> devices_constants.php"), __FILE__ . ":" . __LINE__); @@ -312,6 +312,7 @@ foreach($topics as $name => &$topic) // starting main loop logger(INFO, _("Starting loop"), __FILE__ . ":" . __LINE__, false); $oneshot = false; +logger(ALERT, _("Moha started"), __FILE__ . ":" . __LINE__); while (true) {