From 9d10e51a243818ac40aeb83b4a4cd0686424cd02 Mon Sep 17 00:00:00 2001 From: daniel Tartavel Date: Fri, 4 Mar 2022 22:30:16 +0100 Subject: [PATCH] - debug\n- webserver fonctionnel --- class/hook_class.php | 6 +- config/aliases.php | 18 ++ config/dashboard_conf.php | 13 +- config/properties2log.php | 1 - constants.php | 1 + db_functions.php | 72 +++----- events.php | 5 +- hooks/scripts/availability.php | 7 - hooks/scripts/rdc_chambre_eclairage.php | 20 ++- hooks/scripts/rdc_wc_eclairage.php | 2 +- moha.php | 6 +- mqtt_functions.php | 2 +- topics_callbacks/pws2mqtt.php | 5 +- topics_callbacks/zigbee2mqtt.php | 4 +- webserver/cmd_functions.php | 208 ++++++++++++++++++++---- webserver/sendrange.js | 8 + webserver/webserver.php | 23 ++- 17 files changed, 273 insertions(+), 128 deletions(-) create mode 100644 config/aliases.php create mode 100644 webserver/sendrange.js diff --git a/class/hook_class.php b/class/hook_class.php index 05e49de..8fa6760 100644 --- a/class/hook_class.php +++ b/class/hook_class.php @@ -9,7 +9,7 @@ class hook // list of devices we are listening to function __construct() { - logger(DEBUG, _("Initializing hook: ") . $this->hookName); + logger(INFO, _("Initializing hook: ") . $this->hookName); $this->installHooks(); if (method_exists($this, "init")) { @@ -50,13 +50,13 @@ class hook if ($result === true) { $this->initialized = true; - logger(DEBUG, $this->hookName . _(" initialized"), __FILE__ . ":" . __LINE__); + logger(INFO, $this->hookName . _(" initialized"), __FILE__ . ":" . __LINE__); //var_dump($this); } }else { $this->initialized = true; - logger(DEBUG, $this->hookName . _("hook is disabled"), __FILE__ . ":" . __LINE__); + logger(INFO, $this->hookName . _("hook is disabled"), __FILE__ . ":" . __LINE__); } return $result; diff --git a/config/aliases.php b/config/aliases.php new file mode 100644 index 0000000..e1e5a61 --- /dev/null +++ b/config/aliases.php @@ -0,0 +1,18 @@ + "sdb", + "rdc/wc-sdb/eclairage/state_l2" => "wc" +) + +?> diff --git a/config/dashboard_conf.php b/config/dashboard_conf.php index 1600074..ef7db61 100644 --- a/config/dashboard_conf.php +++ b/config/dashboard_conf.php @@ -1,10 +1,9 @@ "state", - RDC_SDB_WC_ECLAIRAGE => "state_l1", - RDC_SDB_WC_ECLAIRAGE => "state_l2", - RDC_CHAMBRE_AMBIANCE => "state", - RDC_CHAMBRE_ECLAIRAGE => "state_l1" + $dashboards[0] = array( + array(RDC_SALON_ECLAIRAGE_PANNEAU, "state"), + array(RDC_SDB_WC_ECLAIRAGE, "state_l1"), + array(RDC_SDB_WC_ECLAIRAGE, "state_l2"), + array(RDC_CHAMBRE_AMBIANCE, "state"), + array(RDC_CHAMBRE_ECLAIRAGE, "state_l1") ); - ?> diff --git a/config/properties2log.php b/config/properties2log.php index 03154c6..9c238b6 100644 --- a/config/properties2log.php +++ b/config/properties2log.php @@ -18,7 +18,6 @@ $properties2log = array( "position" => null, "pressure" => 10, "occupancy" => null, - "tamper" => null, "illuminance_lux" => function($value) {($value < 500?50:$value*10/100); return $value;}, // "illuminance" => 8, "requested_brightness_level" => function($value) {($value < 500?50:$value*10/100);return $value;}, diff --git a/constants.php b/constants.php index a9c5e18..e62a08e 100644 --- a/constants.php +++ b/constants.php @@ -3,6 +3,7 @@ //Constants define("EOL", "\n"); define("EOLR", "\n\r"); +define("EOLH", "
\n"); define("Z2M", "zigbee2mqtt"); define("ON", true); define("OFF", false); diff --git a/db_functions.php b/db_functions.php index 13a5ee8..d2ba276 100644 --- a/db_functions.php +++ b/db_functions.php @@ -21,7 +21,7 @@ function loadDB(& $db, $filepath) function mkDevicesDB($topic, $json, $group=false) { - global $devices, $listProperties, $listPropertiesKeys, $indexDevices, $dbInit, $logFh, $hooks; + global $devices, $listProperties, $listPropertiesKeys, $indexDevices, $dbInit, $logFh, $hooks, $indexFriendlyNames; if (!isset($devices[$topic])) { $devices[$topic]= array(); @@ -63,11 +63,11 @@ function mkDevicesDB($topic, $json, $group=false) fwrite($logFh, "################################START##################################################"); fwrite($logFh, var_export($devices, true)); fwrite($logFh, "################################END##################################################"); - logger(DEBUG, _("Devices DB made"), __FILE__ . ":" . __LINE__); + logger(INFO, _("Devices DB made"), __FILE__ . ":" . __LINE__); //print_r($devices); } -function addDevice($topic, & $device, $fn, $jsonDevice ) +function addDevice($topic, &$device, $fn, $jsonDevice ) { global $listProperties, $listPropertiesKeys, $hooks, $indexDevices, $indexFriendlyNames; $device->type = $jsonDevice->type; @@ -99,16 +99,17 @@ function searchPropertyKey($fn, &$device, $inputObject, $listPropertiesKeys) { logger(DEBUG, _("propertyKey exists filling properties"), __FILE__ . ":" . __LINE__ ); $string = $inputObject->property; - $device->properties[$string]["value"] = null; - $device->properties[$string]["functions"] = array(); - + if (!array_key_exists($string, $device->properties)) + { + $device->properties[$string]["value"] = null; + } + $device->properties[$string]["functions"] = array(); foreach($inputObject as $key2 => $value2) { - if ($key2 != "property") { $device->properties[$string][$key2] = $value2; - logger(DEBUG, sprintf(_("property %s value %s"), $key2, print_r($device->properties[$string][$key2])), __FILE__ . ":" . __LINE__ ); + //logger(DEBUG, sprintf(_("property %s value %s"), $key2, print_r($device->properties[$string][$key2])), __FILE__ . ":" . __LINE__ ); } } }else @@ -154,8 +155,6 @@ function changeDevice($topic, $fn, &$device, $payloadArray) //print_r($payloadArray); if (!empty($payloadArray)) { - //echo "==================== New ChangeDevice =====================" .EOL; - iterateDevice($topic, $fn, $device, $device->properties, $payloadArray); }else { @@ -194,8 +193,10 @@ function iterateDevice($topic, $fn, $parentDevice, &$properties, $payloadArray, { $properties[$key] = array("value" => $value); $properties[$key]["functions"] = array(); + }elseif ($properties[$key]["value"] !== $value) + { + changeValue($properties[$key], $value, $parentDevice, $propertyTree, $key); } - changeValue($properties[$key], $value, $parentDevice, $propertyTree, $key); } } } @@ -217,7 +218,13 @@ function getDevicesValues($topic) { foreach($device->properties as $property => $value) { - $device->payload[$property] = ""; + if (array_key_exists("access", $value)) + { + if ($value["access"] & 5) + { + $device->payload[$property] = ""; + } + } } //logger(DEBUG, print_r($device->payload, true), __FILE__ . ":" . __LINE__ ); $device->get(); @@ -230,47 +237,6 @@ function getDevicesValues($topic) } } -/*function getDeviceByFriendlyname(&$device, $topic, $fn, $payloadArray, $create = false) -{ - global $devices, $indexDevices, $indexFriendlyNames; - $n = explode("/", $fn); - $device = &$devices[$topic]; - foreach($n as $value) - { - //print_r($device[$value]); - if (array_key_exists($value, $device)) - { - $device = &$device[$value]; - }elseif($create === true) - { - $device[$value] = array(); - $device = &$device[$value]; - }else - { - logger(ERROR, sprintf(_(" device with friendlyname %s not found"), $fn), __FILE__ . ":" . __LINE__); - return false; - } - } - if (! array_key_exists("device", $device)) - { - if ($create === true) - { - logger(WARNING, _("init of ") . $fn, __FILE__ . ":" . __LINE__); - $device["device"] = new device; - $device["device"]->type = $payloadArray->type; - $device["device"]->ieeeAddress = $payloadArray->ieeeAddress; - $device["device"]->friendlyname = $fn; - $indexDevices[$device["device"]->ieeeAddress] = & $device["device"]; - $indexFriendlyNames[$topic][$fn] = & $device["device"]; - } - }else - { - logger(INFO, sprintf(_(" device with friendlyname %s exists"), $fn), __FILE__ . ":" . __LINE__); - } - //var_dump($device); - return true; -}*/ - function changeValue(&$property, $value, &$parentDevice, $propertyTree, $key) { global $mohaDB; diff --git a/events.php b/events.php index 7fd4441..9f988e5 100644 --- a/events.php +++ b/events.php @@ -161,12 +161,13 @@ function setDelay(&$deviceObject, $delay, $unit, $property, $value, $replace=fal function removeEvent($deviceObject, $property , $value) { - if (($eventKey = searchEvent($deviceObject, $property , $value)) === true) + $eventKey = searchEvent($deviceObject, $property , $value); + if ($eventKey !== false) { deleteEvent($eventKey); } - } + function searchEvent($deviceObject, $property , $value) { global $events; diff --git a/hooks/scripts/availability.php b/hooks/scripts/availability.php index fc6dd12..f8adb6b 100644 --- a/hooks/scripts/availability.php +++ b/hooks/scripts/availability.php @@ -45,14 +45,7 @@ class availability } break; } - //echo sprintf(_("notification received from MQTT -> device %s is %s"), $device->friendlyName , $value). EOL; - //echo $property . "=> " . $value . EOL; } - /* - public function getHook() - { - return array($this,"callback"); - }*/ } $hooks["availability"] = new availability(); diff --git a/hooks/scripts/rdc_chambre_eclairage.php b/hooks/scripts/rdc_chambre_eclairage.php index cf194b4..28ba84b 100644 --- a/hooks/scripts/rdc_chambre_eclairage.php +++ b/hooks/scripts/rdc_chambre_eclairage.php @@ -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; diff --git a/hooks/scripts/rdc_wc_eclairage.php b/hooks/scripts/rdc_wc_eclairage.php index a3a1053..f0cedbc 100644 --- a/hooks/scripts/rdc_wc_eclairage.php +++ b/hooks/scripts/rdc_wc_eclairage.php @@ -22,7 +22,7 @@ class rdc_wc_eclairage extends hook { setDelay($device, $this->delayManual, $this->timeUnit, "state_l2", "OFF", true); $device->method = MANUAL; - }elseif ($value = "OFF") + }elseif ($value == "OFF") { deleteEvent(searchEvent($device, "state_l2", "OFF")); } diff --git a/moha.php b/moha.php index 2aa45e7..978a81a 100644 --- a/moha.php +++ b/moha.php @@ -44,13 +44,15 @@ if ($testMode) $dataPath = "./"; $logFile = "./moha.log"; // Path of log file $configDir = "./config"; // default config dir (production value is /etc/moha/) + $httpServerIp = "192.168.1.253"; }else { - $logLevel = INFO | NOTICE | WARNING | ERROR | ALERT; + $logLevel = DEBUG | 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 $configDir = "/etc/moha"; // default config dir (production value is /etc/moha/) + $httpServerIp = "127.0.0.1"; } if (!init()) exit(1); @@ -186,7 +188,7 @@ require "class/main.php"; require "class/db.php"; require "class/hook_class.php"; require "utils.php"; -require "config/properties2log.php"; +require $configDir . "/properties2log.php"; require "mqtt_functions.php"; require "events.php"; require "db_functions.php"; diff --git a/mqtt_functions.php b/mqtt_functions.php index 4d2d8d0..1861fb0 100644 --- a/mqtt_functions.php +++ b/mqtt_functions.php @@ -6,7 +6,7 @@ function messageReceived($message) global $topics, $logFh, $devices, $included; $topic = explode ("/", $message->topic); $callback = $topics[$topic[0]]->callback; - //logger(DEBUG, "topic => " . var_export($topic, true), __FILE__ . ":" . __LINE__); + logger(DEBUG, "message => " . var_export($message, true), __FILE__ . ":" . __LINE__); $callback($topic, $message); } diff --git a/topics_callbacks/pws2mqtt.php b/topics_callbacks/pws2mqtt.php index eea5925..dcb29a4 100644 --- a/topics_callbacks/pws2mqtt.php +++ b/topics_callbacks/pws2mqtt.php @@ -51,6 +51,9 @@ $topics["pws2mqtt"]->callback = function($topic, $message) } } //$device = getDeviceByFriendlyname($topicName, $fn, $payloadArray, true); - changeDevice($topicName, $fn, $device["device"], $payloadArray); + if (!empty($payloadArray)) + { + changeDevice($topicName, $fn, $device["device"], $payloadArray); + } } ?> diff --git a/topics_callbacks/zigbee2mqtt.php b/topics_callbacks/zigbee2mqtt.php index c980ee9..dc0886f 100644 --- a/topics_callbacks/zigbee2mqtt.php +++ b/topics_callbacks/zigbee2mqtt.php @@ -41,7 +41,7 @@ $topics["zigbee2mqtt"]->callback = function($topic, $message) default: break; }; - }elseif (($topic[array_key_last($topic)]) != "get" and ($topic[array_key_last($topic)]) != "set" and $included) + }elseif (($topic[array_key_last($topic)]) != "get" and $included) { $topic = explode ("/", $message->topic, 2); // get topic name $topicName = $topic[0]; @@ -80,7 +80,7 @@ $topics["zigbee2mqtt"]->callback = function($topic, $message) }else { - logger(DEBUG, _("Zigbee2mqtt doing nothing !?")); + logger(DEBUG, _("Zigbee2mqtt doing get or set !?")); } }; diff --git a/webserver/cmd_functions.php b/webserver/cmd_functions.php index d9299bb..d2c7ef4 100644 --- a/webserver/cmd_functions.php +++ b/webserver/cmd_functions.php @@ -1,50 +1,130 @@ + if(array_key_exists($n, $dashboards)) { - foreach ($dashboards[$n] as $ieeeAddress => $property) + foreach ($dashboards[$n] as $array) { - $value = $indexDevices[$ieeeAddress]->properties[$property]["value"]; + print_r($array); + $device = $indexDevices[$array[0]]; + $property = $array[1]; + $propertyObject = $device->properties[$property]; + $value = $propertyObject["value"]; if ($value === null) { - $value ="null"; + $value = "null"; + } + logger(DEBUG, $device->friendlyName . " => " . bool2string(_($value))); + $response .= $device->friendlyName . aliases($device->friendlyName, $property) . " => " . bool2string(_($value)) . EOL; + if (array_key_exists("access", $propertyObject)) + { + logger(DEBUG, _("Access = ") . $propertyObject["access"], __FILE__ . ":" . __LINE__); + if(($propertyObject["access"] & 2)) + { + logger(DEBUG, _("Write Access OK ") . ($propertyObject["access"] & 2), __FILE__ . ":" . __LINE__); + $response .= "     " . displayChoice($device, $property) . EOL; + } + if(($propertyObject["access"] & 4)) + { + logger(DEBUG, _("can get value") . ($propertyObject["access"] & 4), __FILE__ . ":" . __LINE__); + $response .= '     friendlyName . "/" . $propertyObject["name"] . '" value="' . _("Update") . "\" onmouseup=\"getPropertyValue('" . $device->topic . "','" . $propertyObject["name"] . "')\">
" . EOL; + } } - logger(DEBUG, _($indexDevices[$ieeeAddress]->friendlyName . " => " . bool2string($value))); - $response .= $indexDevices[$ieeeAddress]->friendlyName . " => " . bool2string($value) . "
"; } }else { $response = _("dashboard not found"); } - htmlSend($socket, $response); } -function webBrowse($socket, $argList) +function displayChoice($device, $propertyName) { - global $topics, $devices; + logger(INFO, _("function displayChoice"), __FILE__ . ":" . __LINE__); + $propertyObject = $device->properties[$propertyName]; + + if(array_key_exists("unit", $propertyObject)) + { + $unit = $propertyObject["unit"]; + logger(DEBUG, _("unit = ") . $unit, __FILE__ . ":" . __LINE__); + } + if (!array_key_exists("type", $propertyObject)) return ""; + switch ($propertyObject["type"]) + { + case "binary": + logger(DEBUG, _("type is binary"), __FILE__ . ":" . __LINE__); + $choice["on"] = $propertyObject["value_on"]; + $choice["off"] = $propertyObject["value_off"]; + if (array_key_exists("toggle", $propertyObject)) + { + $choice["toggle"] = $propertyObject["toggle"]; + } + $formHTML = mkHTML($device, $propertyName, $choice); + break; + case "numeric": + logger(DEBUG, _("type is numeric"), __FILE__ . ":" . __LINE__); + $formHTML = 'topic . "', this.value, '" . $propertyObject["name"] . "')\">"; + + break; + case "enum": + logger(DEBUG, _("type is enum"), __FILE__ . ":" . __LINE__); + $choice = $propertyObject["values"]; + $formHTML = mkHTML($device, $propertyName, $choice); + break; + } + return $formHTML; +} + +function mkHTML($device, $propertyName, $choice) +{ + global $listenPort, $httpServerIp; + $html = ""; + logger(DEBUG, _("function mkHTML"), __FILE__ . ":" . __LINE__); + foreach ($choice as $key => $value) + { + $html .= 'friendlyName . "/" . $propertyName . "/" . $key . '" value="' . $value . "\" onmouseup=\"setPropertyValue('" . $device->topic . "', '" . $value . "', '" . $propertyName . "')\">"; + } + return $html; +} + +function webBrowse($socket, $argList, $page="/browse") +{ + global $topics, $devices, $listenPort,$indexDevices; logger(DEBUG, _("Generic response to choose device and property"), __FILE__ . ":" . __LINE__); //$response = "
" . _("unknown command") . ""; $response = ""; $flag = false; $tab = ""; + if (array_key_exists("topic", $argList)) { if (array_key_exists($argList["topic"], $topics)) { - logger(DEBUG, _("Topic exists") , __FILE__ . ":" . __LINE__); - $topicRef = '"; - $response .= $tab . "[
"; - echo memory_get_usage(); + $response .= $key . "     "; + if (array_key_exists("access", $value)) + { + if(($value["access"] & 2)) + { + logger(DEBUG, _("Write Access OK ") . ($value["access"] & 2), __FILE__ . ":" . __LINE__); + $response .= displayChoice($device, $key); + } + if(($value["access"] & 4)) + { + logger(DEBUG, _("can get value") . ($value["access"] & 4), __FILE__ . ":" . __LINE__); + $response .= '     friendlyName . "/" . $key . '" value="' . _("Update") . "\" onmouseup=\"getPropertyValue('" . $device->topic . "', '" . $key . "')\">"; + } + } + $response .= "
\n" . $tab . "[
\n"; + //echo memory_get_usage(); //$response = value($key, $value, $response); - iterateProperty($key, $value, $response, $tab); - $response .= $tab . "]
"; + iterateProperty($device, $key, $value, $response, $tab); + $response .= $tab . "]
\n"; } /*foreach($device->properties as $key => $value) { @@ -86,17 +203,23 @@ function webBrowse($socket, $argList) $response .= $topicRef . htmlentities("&fn=" . $fn . "/" . $key) . '">' . $key . "

\n"; } } - logger(DEBUG, _("response: ") . EOL . $response , __FILE__ . ":" . __LINE__); - + //logger(DEBUG, _("response: ") . EOL . $response , __FILE__ . ":" . __LINE__); //htmlSend($socket, $response); }else { - foreach($devices[$argList["topic"]] as $key => $value) + logger(DEBUG, _("no FriendlyName given"), __FILE__ . ":" . __LINE__); + if (empty($devices[$argList["topic"]])) { - print "key = " . print_r($key, true) . " value = " . print_r($value, true) . EOLR; - logger(DEBUG, _("devices de topic: ") . $key , __FILE__ . ":" . __LINE__); - $response .= $topicRef . htmlentities("&fn=" . $key) . '">' . $key . "
"; - logger(DEBUG, _("response: ") . $response , __FILE__ . ":" . __LINE__); + $response .= _("No devices yet found"); + }else + { + foreach($devices[$argList["topic"]] as $key => $value) + { + //print "key = " . print_r($key, true) . " value = " . print_r($value, true) . EOL; + logger(DEBUG, _("devices de topic: ") . $key , __FILE__ . ":" . __LINE__); + $response .= $topicRef . htmlentities("&fn=" . $key) . '">' . $key . "
\n"; + logger(DEBUG, _("response: ") . $response , __FILE__ . ":" . __LINE__); + } } } }else @@ -110,22 +233,28 @@ function webBrowse($socket, $argList) htmlSend($socket, $response); } -function iterateProperty($property, $value, &$response, $tab="") +function iterateProperty($device, $property, $value, &$response, $tab="") { - $tab .= "     "; + $tab .= "        "; if (is_array($value) or is_object($value)) { - logger(DEBUG, _("is object or array"), __FILE__ . ":" . __LINE__ ); + logger(DEBUG, _("is array"), __FILE__ . ":" . __LINE__ ); foreach($value as $key => $value2) { - logger(DEBUG, $key, __FILE__ . ":" . __LINE__ ); - iterateProperty($key, $value2, $response, $tab); - + $response .= $tab . $key; + if (is_array($value2) or is_object($value2)) + { + $response .= "
\n"; + }else + { + $response .= " = "; + } + iterateProperty($device, $key, $value2, $response, $tab); } }else { - $response .= $tab . $property . ' = ' . bool2string($value) . "
";//value($property, $value, ""); + $response .= bool2string($value) . "
\n";//. displayChoice($device, $property); //value($property, $value, ""); } } @@ -136,7 +265,7 @@ function webListTopics() $response = ""; foreach ($topics as $name => $topic) { - $response .= '' . $name ."
"; + $response .= '' . $name ."
\n"; } return $response; } @@ -162,15 +291,24 @@ function webGet($argList) function webSet($argList) { + global $indexFriendlyName; if(!array_key_exists("topic", $argList) or !array_key_exists("fn", $argList) or !array_key_exists("property", $argList) or !array_key_exists("value", $argList)) { - $response = "SET: " . _("no parameters passed, need topic, fn, property and value") . "passed"; - + if (!array_key_exists($argList["topic"], $topics) ) + { + $response = "SET: " . _("bad parameter passed: topic does not exists") . "
\n"; + } + if (!array_key_exists(!array_key_exists($argList["fn"], $indexFriendlyName))) + { + $response = "SET: " . _("bad parameter passed: fn does not exists") . "
\n"; + } + $response .= "SET: " . _("not all parameters passed, need topic, fn, property and value"); }else { $response = "setting property " . $argList["property"] . " of " . $argList["fn"] . " to value: " . $argList["value"]; $payload = array($argList["property"] => $argList["value"]); publish(Z2M . "/" . $argList["fn"], $payload); + //removeEvent($indexFriendlyName($argList["fn"]), $argList["property"], "OFF"); } return $response; } @@ -228,7 +366,7 @@ function webNotify($argList) { if (!array_key_exists("topic", $argList) or !array_key_exists("fn", $argList) or !array_key_exists("property", $argList) or !array_key_exists("condition", $argList) or !array_key_exists("value", $argList)) { - $response = _("Error: With 'notify' command, you need 4 parameters: topic, fn, property, condition, value"); + $response = _("Error: With 'notify' command, you need 5 parameters: topic, fn, property, condition, value"); }else { $response = _("notify command have been set"); diff --git a/webserver/sendrange.js b/webserver/sendrange.js new file mode 100644 index 0000000..6c1a58f --- /dev/null +++ b/webserver/sendrange.js @@ -0,0 +1,8 @@ +