Efergy Engage

Discussioni relative al software di monitoraggio energetico METERN
sep20
Messaggi: 3
Iscritto il: 21/07/2020, 8:18

Efergy Engage

Messaggioda sep20 » 24/07/2020, 11:23

Buongiorno a tutti.
Ho già da qualche anno un contatore Efergy Engage e volevo provare ad integrarlo in MeterN.
E' possibile leggere i valori con delle API e quello che ottengo è questa stringa:

[{"cid":"PWER","data":[{"1595575168000":907}],"sid":"782418","units":"W","age":2}]

dove 907 è il valore del consumo espresso in watt e 782418 si riferisce al codice del sensore (visto che se ne possono avere più di uno)

Adesso vorrei capire il giro che deve essere fatto per passare il valore a MeterN.

Guardando il file \var\www\comapps\poolerconsumi.php, mi sembra di capire che i valori vengono letti dal file txt contenuto nella cartella /dev/shm :
$cmd = "more /dev/shm/metern$metnum.txt | egrep \"^$metnum\(\" | grep \"*Wh)\""; // Request Energy values
$cmd1 = "more /dev/shm/metern$metnum.txt | egrep \"^$metnum\(\" | grep \"*W)\""; // Request Power values


E' corretto? Se si, chi li mette li? Nel caso di un contatore SDM120 credo sia lo script contenuto nella cartella home\pi\SDM120C e schedulato per partire ogni tot minuti.
Sono sulla strada giusta?


Avatar utente
Flane
Messaggi: 2460
Iscritto il: 16/01/2016, 15:02

Re: Efergy Engage

Messaggioda Flane » 25/07/2020, 14:44

La stringa è in formato JSON.

I dati si possono estrarre con il comando Json_decode.

Questo ad esempio è uno script (reqtasmota.php) per estrarre umidità e temperatura dai un sonoff con firmware tasmota a cui è stato collegato un dht22. Puoi prendere spunto da qui.

Codice: Seleziona tutto

#!/usr/bin/php
<?php
// This script will output a meterN compatible format for the main or live command
// You'll need to setup correct permission chmod +x
// then ln -s /var/www/comapps/reqtasmota.php /usr/local/bin/reqtasmota
// Request command with 'reqtasmota temp' or 'reqtasmota umi'

if (isset($_SERVER['REMOTE_ADDR'])) {
    die('Direct access not permitted');
}
if (!isset($argv[1])) {
   die("Abording: no valid argument given.\n");
      } elseif ($argv[1] == 'temp') {
   $url = 'http://192.168.3.71/cm?cmnd=Status%2010';
   $pagina = file_get_contents($url);
   $json_output = json_decode($pagina, true);
   $val = $json_output['StatusSNS']['AM2301']['Temperature'];
   $outstr = ("22($val*°C)\n");
      } elseif ($argv[1] == 'umi') {
   $url = 'http://192.168.3.71/cm?cmnd=Status%2010';
   $pagina = file_get_contents($url);
   $json_output = json_decode($pagina, true);
   $val = $json_output['StatusSNS']['AM2301']['Humidity'];
   $outstr = ("23($val*%)\n");
      } elseif ($argv[1] == 'tens') {
   $url = 'http://192.168.3.123/cm?cmnd=Status%2010';
   $pagina = file_get_contents($url);
   $json_output = json_decode($pagina, true);
   $val = $json_output['StatusSNS']['ENERGY']['Voltage'];
   $outstr = ("23($val*V)\n");
 // and so on ....
   } else {
    die("Usage: reqtasmota (temp|umi)\n");
   }
echo "$outstr";
?>


Si tratta di capire le chiavi per la lettura dal dato che ti interessa


Torna a “MeterN”

Chi c’è in linea

Visitano il forum: Nessuno e 21 ospiti