reset PZEM-004T in rules

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bledad
Normal user
Posts: 86
Joined: 23 Nov 2020, 10:57
Location: France

reset PZEM-004T in rules

#1 Post by bledad » 05 Dec 2023, 10:33

Hello,
i see what reset PZEM-004T with http://*espeasyip*/control?cmd=resetenergy,*PZEM address*
but in rules , i can use sendtohttp or other function ??
thank

User avatar
Ath
Normal user
Posts: 3541
Joined: 10 Jun 2018, 12:06
Location: NL

Re: reset PZEM-004T in rules

#2 Post by Ath » 05 Dec 2023, 10:53

bledad wrote: 05 Dec 2023, 10:33 Hello,
i see what reset PZEM-004T with http://*espeasyip*/control?cmd=resetenergy,*PZEM address*
but in rules , i can use sendtohttp or other function ??
thank
In plain rules, that command would be:

Code: Select all

on ResetButton#State=0 do // Push-button, low on active
  resetenergy,*PZEM address*
endon
(Added the event for a button, as any code there should be in an event to handle.)
The form you used is for controlling the action remotely, f.e. from a browser or external http-enabled application.

NB: You shouldn't try to do a sendtohttp command to the ESPEasy unit (self) where this command is activated, that will block execution of the command (time-out).
/Ton (PayPal.me)

bledad
Normal user
Posts: 86
Joined: 23 Nov 2020, 10:57
Location: France

Re: reset PZEM-004T in rules

#3 Post by bledad » 05 Dec 2023, 11:06

ok ,thank you
I use it to safely control a sliding gate , I'm going to do a reset every time I stop sliding gate

TD-er
Core team member
Posts: 8766
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: reset PZEM-004T in rules

#4 Post by TD-er » 05 Dec 2023, 12:12

Just FYI, you should not try to use sendtohttp calls from rules to the node itself.

I've seen people try doing this and your initial question suggests you may have thought of this yourself :)
But from rules you can call any command supported in ESPEasy.
Commands initiated from remote sources cannot call all commands as some are 'restricted', based on the origin of the command call.
For example a call to reset factory default should not be made from an external source.
If you really want to do this, you should put it in the rules and trigger an event to do so.

We really try to prevent users to shoot themselves in their foot/feet, but if you really want/need to, you can do it :)

User avatar
Ath
Normal user
Posts: 3541
Joined: 10 Jun 2018, 12:06
Location: NL

Re: reset PZEM-004T in rules

#5 Post by Ath » 07 Dec 2023, 16:57

watt67 wrote: 07 Dec 2023, 16:02 use the HTTP command sendtohttp in rules like this: sendtohttp,*PZEM_address*,control?cmd=resetenergy
hope this helps
That is exactly how it is NOT to be used from the PZEM unit!

From another ESPEasy unit you can also use "SendTo,UnitNr-pzem,resetenergy,pzem-bus-address",
that's assuming you have the P2P network configured (default it should be enabled) and all ESPEasy units have a unique unit number, between 1 and 254.

Edit: That watt67 user turned out to be a spammer/troll (not sure if there's a difference... :?), but as some ppl may have read his poor response I'll leave my answer here to mitigate that ;)
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest