enesbcs / rpieasy

Easy MultiSensor device based on Raspberry PI
GNU General Public License v3.0
162 stars 33 forks source link

Unknown command: PZEMRESET,1 #279

Closed Epik77 closed 1 year ago

Epik77 commented 1 year ago

Hi, I wanted to reset the counter of my pzem004t but the command is not found. could you fix it? Thank you

Epik77 commented 1 year ago

same result 11:15:01 : CMD: resetenergy 11:15:01 : Unknown command: resetenergy or 11:15:51 : CMD: resetenergy,1 11:15:51 : Unknown command: resetenergy,1

TD-er commented 1 year ago

I already removed my reply, since I overlooked this was about RpiEasy, not ESPEasy ;)

enesbcs commented 1 year ago
Available commands:
  PZEMADDRESS,<currentaddress>,<newaddress>     - change address of pzem device
  PZEMRESET,<address>               - PZEM reset energy at address

if the PZEM device is not initialized in RPIEAsy or, address is unknown or resetenergy() returns False, then the result is unknown command.

Epik77 commented 1 year ago

sorry but PZEM device is initialized and work correctly

immagine

I go to tool -> esegui comando -> PZEMRESET,1

but result is unknown command

enesbcs commented 1 year ago

I've added more log output to current release, please upgrade and check console log https://github.com/enesbcs/rpieasy/commit/a7d1219c2e98045c7ac10afb01f529aed55b88b5

Epik77 commented 1 year ago

Hi this output:

False 15:39:05 : PZEM004 reset error: 'Instrument' object has no attribute '_performCommand' 15:39:05 : PZEM reset command failed! 15:39:05 : PZEM004 reset error: 'Instrument' object has no attribute '_performCommand' 15:39:05 : PZEM reset command failed! 15:39:05 : Unknown command: pzemreset,1

enesbcs commented 1 year ago

15:39:05 : PZEM004 reset error: 'Instrument' object has no attribute '_performCommand'

I see... when i wrote the plugin at 2020 there was a "_performCommand" function in minimalmodbus. And now it is called as "_perform_command".. magnificent. :D "Note that the API might change, as this is outside the official API."

Could you please change your "lib/lib_pzem.py" file both occurences of this:

self.dev._performCommand(66,'')

to these:

self.dev._perform_command(66, b'')

Epik77 commented 1 year ago

Very good replaced performCommand with perform_command now the command works correctly:

08:44:52 : Timer 2 started with timeout: 5 08:44:52 : Unit alive: 21 08:44:52 : Unit alive: 13 08:44:54 : CMD: pzemreset,1

immagine

thanks for support :-)

enesbcs commented 1 year ago

Thank you for testing, i will add this fix to the next commit!