From 247d1fd17d6362a1d761f9d12fa17e59a02f8ed6 Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Fri, 5 Aug 2022 17:34:23 +0200 Subject: [PATCH] debug --- hooks/scripts/rdc_temperature_int_ext.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hooks/scripts/rdc_temperature_int_ext.php b/hooks/scripts/rdc_temperature_int_ext.php index 4a0a44b..e7690d5 100644 --- a/hooks/scripts/rdc_temperature_int_ext.php +++ b/hooks/scripts/rdc_temperature_int_ext.php @@ -13,12 +13,15 @@ class rdc_temperature_int_ext extends hook public function callBack(&$device, $property, $value) { global $indexDevices; - if ($device->properties["indoortempc"]["value"] > $value) + static $status = 0; + if ($device->properties["indoortempc"]["value"] > $value and $status === 1) { - logger(ALERT, _("Indoor temperature is superior to outdoor one")) - }elseif ($device->properties["indoortempc"]["value"] < $value) + $status = 0; + logger(ALERT, _("Indoor temperature is superior to outdoor one")); + }elseif ($device->properties["indoortempc"]["value"] < $value and $status === 0) { - logger(ALERT, _("Indoor temperature is inferior to outdoor one")) + $status = 1; + 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__); }