jeanmarc77 / meterN

meterN is a lightweight set of PHP/JS files that makes a " Home energy metering & monitoring " solution.
GNU General Public License v3.0
5 stars 2 forks source link

Metern: indicator value empty #23

Open novembre62 opened 6 months ago

novembre62 commented 6 months ago

HI I have an energy meter that measures today's energy which is reported in the indicators When the meter value is "0", the indicator value is "Empty" It is possible to display "0"

Use with Metern 1.2.4.1 Raspberry PI5 with bookworm

Thank you

jeanmarc77 commented 6 months ago

Hi, What output exactly your command ?
your 0 should not be quoted

novembre62 commented 6 months ago

in reqsdm.php ...... } elseif ($argv[1] == 'pow3oggi') { $url = 'http://192.168.1.42/cm?cmnd=Status%2010'; $pagina = file_get_contents($url); $json_output = json_decode($pagina, true); $val = $json_output['StatusSNS']['ENERGY']['Today']; $outstr = ("10($val*w)\n"); ....... http://192.168.1.42/cm?cmnd=Status%2010 returns {"StatusSNS":{"Time":"2024-03-08T08:39:42","ENERGY":{"TotalStartTime":"2023-03-17T00:00:00","Total":1367.148,"Yesterday":0.000,"Today":0.000,"Power":0,"ApparentPower":0,"ReactivePower":0,"Factor":0.00,"Voltage":230,"Current":0.000}}}

"Today":0.000

Therefore in metern indicators Command = reqsdm pow3oggi

the value is "empty" only when the Today value is 0, while it is displayed correctly when the value is greater than 0

this also happens with other indicators

jeanmarc77 commented 6 months ago

What returns reqsdm pow3oggi from CLI ? Maybe change reqsdm with $outstr = utf8_decode($outstr); echo "$outstr";

novembre62 commented 6 months ago

returns reqsdm pow3oggi from CLI:

10(0*w)

jeanmarc77 commented 6 months ago

and what returns metern/programs/programindicator.php ?

novembre62 commented 6 months ago

returns metern/programs/programindicator.php :

{"Tensione1":"234.15","Temp CPU2":"53.45","Distacco lavanderia3":"OFF<\/font>","Distacco clima4":"OFF<\/font>","Acqua giorno5":"105","Clima nuovi oggi6":"empty"}

and this : Clima nuovi oggi6":"empty"

novembre62 commented 6 months ago

I think this happened with the new version of metern...but I'm not sure

jeanmarc77 commented 6 months ago

i don't have such issue.. What show "more /dev/shm/mN_ILIVEMEMORY.json" ?

novembre62 commented 6 months ago

/dev/shm/mN_ILIVEMEMORY.json :

{"Tensione1":"238.09","Temp CPU2":"52.9","Distacco lavanderia3":"OFF<\/font>","Distacco clima4":"OFF<\/font>","Acqua giorno5":"133","Clima nuovi oggi6":"empty"}

jeanmarc77 commented 6 months ago
novembre62 commented 6 months ago

should I replace my metern.php with the one indicated in the link?

jeanmarc77 commented 6 months ago

yup

novembre62 commented 6 months ago

done...but nothing changes

novembre62 commented 6 months ago

...I add that by replacing metern.php, even some meters, which at this moment have a value of 0, "empty" is displayed

jeanmarc77 commented 6 months ago

dunno, it work here but it's been a while.. i somehow remember i have changed that behavior.. Maybe change also https://github.com/jeanmarc77/meterN/blob/main/index.php

novembre62 commented 6 months ago

replaced index.php, but no change

however, the system works well....the values are correctly displayed and counted when they are different from 0 It was just to not see "empty" when the value is 0 Thank you very much for your availability

jeanmarc77 commented 6 months ago

[jeanmarc@zbox ~]$ houseenergy -frq 1_F(0*Hz)

programindicator.php returns {"Volt1":"230.7","Freq2":"0","Cos3":"0.7","Main4":"14920","peak5":"4851.5","low6":"6"}

and my index show 0 Capture d’écran du 2024-03-08 17-34-40

Sorry i don't code much theses days

novembre62 commented 6 months ago

Thanks again

novembre62 commented 6 months ago

Good morning I solved it like this:

added to metern.php after line 314

if ($val === 'empty') { // Check if the value is 'empty' $val = 0; // Set the value to 0 if it is 'empty' }

Now when the value of an indicator is 0, 0 is displayed

jeanmarc77 commented 6 months ago

Well, if you it mean your com app return 'empty' in cli