Je souhaiterai pourvoir pinger un noeud zwave via un script php dans un scenario.
j’arrive a recuperer la liste des noeuds sur secteur un utilisant ce bout de code:
// Load plugin
plugin::byId('zwavejs');
// write infos & stats in json file
zwavejs::getInfo();
zwavejs::getNodes('stats');
zwavejs::getNodes('health');
// Get Modules info
$json = zwavejs::getFile('nodeStats', null);
$All_node = $json['networkTree']['data'];
mais je ne sais pas comment effectuer le ping.
E t accessoirement comment fait-on pour récupérer le « wake-up intervall » dans noeud sur batterie (toujours un php)?
C’est un peu en vrac, mais difficile sur le téléphone de faire un copier coller
,
- Nom du scénario : Watchdog z-wave
- Objet parent : Jeedom
- Mode du scénario : schedule
- Programmation : 10 * * * *
Test Z wave id et reporte si dead
CODE
(code) // https://nechry-automation.ch/2018/06/07/api-restful/
// Setup
// Jeedom configuration/API/Clef API Z-Wave
$apizwave = 'GFLFRY5GFX881____________G9QfI9aEkHy';
// the node Id to perform the ping
$nodeId = 1;
// End Setup
$url = 'http://127.0.0.1:8083/node?node_id=' . $nodeId . '&type=action&action=testNode&apikey=' . $apizwave;
$contents = file_get_contents($url);
//$scenario->setLog('Contents :'.$contents);
$results = json_decode($contents);
$success = $results->state;
if ($success != 'ok') {
$scenario->setLog('Z-wave test : Node return an error: ' . $results->result);
$scenario->setData("ZAPI_NodePingDead", $nodeId);
} else { $scenario->setLog('Z-wave test : Node #' . $nodeId .' OK');
// save ping time for delta check
$scenario->setData("ZAPI_NodePingTime", time());
$scenario->removeData(ZAPI_NodePingDead);
}
SI variable(ZAPI_NodePingTime)!=""
ALORS
DANS 1
FAIRE
CODE
(code) // Setup
// Jeedom configuration/API/Clef API Z-Wave
$apizwave = 'GFLFdOIFX881G_____________9QfI9aEkHy';
// the node Id to perform the ping
$nodeId = 25;
// timeout
$timeout = 60;
// End Setup
// time of the testNode command
$send_time = $scenario->getData("ZAPI_NodePingTime");
$scenario->removeData(ZAPI_NodePingTime);
// get node health data
$url = 'http://127.0.0.1:8083/node?node_id=' . $nodeId . '&type=info&info=getHealth&apikey=' . $apizwave;
$contents = utf8_encode(file_get_contents($url));
//$scenario->setLog('Contents :' . $contents);
$results = json_decode($contents);
$success = $results->state;
if ($success != 'ok') {
$scenario->setLog('ZAPI node getHealth return an error: ' . $results["result"]);
} else {
// read the attributes of the last notification
$receiveTime = $results->result->last_notification->receiveTime;
$description = $results->result->last_notification->description;
$scenario->setLog('Receive ' . $description . ' notification at time :' . date("Y-m-j H:i:s", $receiveTime));
// init message to empty
$message = '';
// check if node is presume dead
if ($description == 'Dead') {
$message = 'The Z Wave controller marked the Node Id ' . $nodeId . ' as presumed dead';
} else {
// check the delta
$delta = $receiveTime - $send_time;
$scenario->setLog('Recive a echo in :' . $delta . ' seconds.');
// check if notification has occur more the 1 minute ago
if ($delta > $timeout) {
// use a notification command action to send the warning message
$message = 'No response received after node test after ' . $delta . ' seconds';
}
}
if ($message != '') {
// add log entry
$scenario->setLog($message);
$cmd = cmd::byString('#[Notifications][Telegram Bot][Tous]#');
if (is_object($cmd)) {
$option = array('title' => 'A ZWave node no longer seems to respond', 'message' => $message);
$cmd->execCmd($option);
} else {
$scenario->setLog('Error: the notification command did not exist');
}
}
}
SINON
SI variable(ZAPI_NodePingDead)!=""
ALORS
(scenario) start de [Multimedia][Jeedom][Message]
message - Options : {"enable":"1","background":"0","message":"\"Z-wave : Le noeud #\" variable(ZAPI_NodePingDead) \"ne r\u00e9pond plus\""}
SINON
je préfèrerai gérer cette partie. C’est plus souple et adaptable via un script.
Par exemple un module batterie qui ne remonte pas en Wake-Up mais qui fonctionne quand même (réagit lorsqu’on ouvre la porte) peut être en erreur dans un cas mais pas dans l’autre.
Bonjour je souhaite faire une boucle en prenant la liste de tous les modules Zwave (en demandant au plugin la liste des modules) de manière a ce que si j’ajoute un module zwave je n’ai pas besoin de l’ajouter dans un scénario.
->récupérer la liste des modules
-> si batterie: alerter si la date de dernière info > à la date du (dernier réveil + wakeup interval)
-> si secteur:
->si dernière info > X minutes => Ping
->si dernière info > Y minutes => alerte