@geoborders/node-red-contrib-geoborders 0.4.0

Nodi Node-RED ufficiali GeoBorders per GeoAccess ed EMS backup con autenticazione API key.

npm install @geoborders/node-red-contrib-geoborders

@geoborders/node-red-contrib-geoborders

Palette ufficiale GeoBorders per Node-RED.

Nodi inclusi

GeoBorders API

Configuration node condiviso e non trascinabile nella palette. Salva:

  • nome della connessione;
  • indirizzo base del server, normalmente https://api.geoborders.com;
  • API key;
  • timeout delle richieste.

L'API key è dichiarata come credenziale Node-RED e viene inviata con:

X-API-Key: LA_TUA_API_KEY

GeoAccess Switch

Legge lo stato oppure accende e spegne uno switch remoto tramite GeoBorders API.

Comandi supportati:

  • status;
  • on oppure 1;
  • off oppure 0.

EMS-backup

Invia all'API GeoBorders il backup dell'EMS oppure richiede la configurazione salvata per effettuare un restore.

Valori gestiti:

  • site_id: identifica il sito;
  • configuration_file: configurazione inviata nel backup e restituita nel restore;
  • ems_version: inviata soltanto nel backup;
  • diagnostic_file: inviato soltanto nel backup.

Entrambi i nodi visibili hanno due uscite:

  1. successo;
  2. errore.

Installazione

Dalla directory utente di Node-RED, normalmente ~/.node-red:

npm install @geoborders/node-red-contrib-geoborders

Sul Cerbo GX con Venus OS Large è possibile installare il file .tgz da:

Menu → Manage palette → Install → Upload module tgz file

Nella palette apparirà la categoria GeoBorders con:

  • GeoAccess Switch;
  • EMS-backup.

GeoBorders API rimane nascosto perché è un configuration node.

Configurazione GeoBorders API

Aprire uno dei nodi GeoBorders, premere la matita accanto al campo API e inserire:

Server: https://api.geoborders.com
API key: ********
Timeout: 15

GeoAccess Switch

Lettura stato

GET /public/geoaccess/node_red_functions.php?app=read_status&type=SWITCH&id=123
X-API-Key: LA_TUA_API_KEY

Accensione

GET /public/geoaccess/node_red_functions.php?app=write_status&value=1&type=SWITCH&id=123
X-API-Key: LA_TUA_API_KEY

Spegnimento

GET /public/geoaccess/node_red_functions.php?app=write_status&value=0&type=SWITCH&id=123
X-API-Key: LA_TUA_API_KEY

Quando il nodo è impostato su Usa msg.payload:

msg.payload = "status";
msg.payload = "on";
msg.payload = "off";

ID e comando dinamici:

msg.geoaccess = {
    site_switch_id: 123,
    action: "on"
};
return msg;

EMS-backup

Il nodo può usare percorsi fissi configurati nell'editor oppure valori dinamici presenti in msg.ems_backup.

Mandare il backup

msg.ems_backup = {
    action: "backup",
    site_id: 123,
    ems_version: "1.4.0",
    configuration_file_path: "/data/ems/configuration.json",
    diagnostic_file_path: "/data/ems/diagnostic.zip"
};
return msg;

È possibile passare direttamente i file come Buffer:

msg.ems_backup = {
    action: "backup",
    site_id: 123,
    ems_version: "1.4.0",
    configuration_file: Buffer.from("..."),
    diagnostic_file: Buffer.from("...")
};
return msg;

Richiesta API:

POST /public/geoaccess/node_red_functions.php?app=write_backup
X-API-Key: LA_TUA_API_KEY
Content-Type: multipart/form-data; boundary=...

Campi multipart:

site_id
configuration_file
ems_version
diagnostic_file

configuration_file è obbligatorio. diagnostic_file è opzionale.

Richiedere la configurazione per restore

msg.ems_backup = {
    action: "restore",
    site_id: 123
};
return msg;

Richiesta API:

GET /public/geoaccess/node_red_functions.php?app=read_backup&site_id=123
X-API-Key: LA_TUA_API_KEY
Accept: application/octet-stream, application/json

L'API può restituire direttamente il file binario oppure JSON:

{
  "configuration_file": "BASE64...",
  "configuration_file_encoding": "base64"
}

Il nodo restituisce:

msg.payload = Buffer;
msg.filename = "configuration-site-123.bin";
msg.ems_backup = {
    action: "restore",
    site_id: "123",
    configuration_file: Buffer,
    configuration_filename: "configuration-site-123.bin",
    success: true
};

Nel restore non vengono richiesti né restituiti ems_version e diagnostic_file.

Esempi

  • examples/02-geoaccess-switch.json;
  • examples/03-ems-backup.json.

Dopo l'importazione aprire GeoBorders API e inserire l'API key, che non viene inclusa nei flow esportati.

Aggiornamento dalla 0.3.0

La versione 0.4.0 rimuove GB Tag e aggiunge EMS-backup. I flow che non usavano GB Tag non richiedono modifiche.

Test

npm test
npm run pack:check

Pubblicazione

npm login
npm whoami
npm test
npm run pack:check
npm publish . --access public

Licenza

Software proprietario GeoBorders. Consultare LICENSE.

Node Info

Version: 0.4.0
Updated 1 day ago
License: UNLICENSED
Rating: not yet rated

Categories

Actions

Rate:

Downloads

0 in the last week

Nodes

  • geoborders-api
  • geoaccess-switch
  • ems-backup

Keywords

  • node-red
  • geoborders
  • geoaccess
  • ems
  • backup
  • automation
  • iot
  • integration

Maintainers