power pulse timer

78 views
Skip to first unread message

John Magill

unread,
Apr 8, 2020, 6:17:16 AM4/8/20
to TasmotaUsers
Hi I'm struggling a bit with rules.
I'm monitoring pulses from my electric meter and sending pulse times to node-red.
teleperiod is 0   countertype is 1

on counter#c1>0 do publish leccy %value% endon on tele-counter#c1>0 do counter1 0 endon
this rule for some reason publishes mqtt every half second.

on counter#c1>0 do publish leccy %value% endon on counter#c1>0 do counter1 0 endon
this rule publishes only on new pulse (which is what I want) but also publishes
stat/xxxxx/RESULT : {"Counter1":0}   (which I don't want)

Anyone help?  thanks

John Magill

unread,
Apr 10, 2020, 5:22:03 AM4/10/20
to sonof...@googlegroups.com
I'm making the assumption that "on counter#1" means only do this when counter is triggered. In my case this is approx every 5 seconds. So why am I getting a publish every half second?
this simple rule publishes every half second and I don't know why
on counter#c1 do publish leccy %value% endon
thanks


Philip Knowles

unread,
Apr 10, 2020, 5:48:03 AM4/10/20
to TasmotaUsers, John Magill
I don't understand why you are using a counter which you reset when it reaches 1. I presume you get a pulse every fraction of a kWh.  Why not just accept the pulse as Switch1 and Relay1 will follow the pulse and automatically send an MQTT message without a rule.

Regards

Phil K

From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of John Magill <mugg...@gmail.com>
Sent: Friday, April 10, 2020 10:22:03 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: power pulse timer
 
I'm making the assumption that "on counter#1 means only do this when counter is triggered. In my case this is approx every 5 seconds. So why am I getting a publish every half second?
thanks

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/b23935ea-c49a-4c2b-81b1-87694b19e159%40googlegroups.com.

Sent from Outlook Mobile

From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of John Magill <mugg...@gmail.com>
Sent: Friday, April 10, 2020 10:22:03 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: power pulse timer
 
I'm making the assumption that "on counter#1 means only do this when counter is triggered. In my case this is approx every 5 seconds. So why am I getting a publish every half second?
thanks

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/b23935ea-c49a-4c2b-81b1-87694b19e159%40googlegroups.com.

John Magill

unread,
Apr 10, 2020, 6:12:12 AM4/10/20
to sonof...@googlegroups.com
TBH I plagiarized the rule from elsewhere. I use the counter to get a pulse time since last pulse. If pulse acts as a switch I lose that.
This simple rule published every half second?
on counter#c1 do publish leccy %value% endon
thanks

John Magill

unread,
Apr 10, 2020, 8:34:52 AM4/10/20
to TasmotaUsers
Very simple test.
Sonoff basic
teleperiod 0
countertype=1
GPIO 14 sensor set as counter1(42)
GPIO 14 (D5) grounded
running rule "on counter#c1 do publish test %value% endon"

This publishes every second? I don't know why.

Philip Knowles

unread,
Apr 10, 2020, 11:00:18 AM4/10/20
to John Magill, TasmotaUsers

What is connected to the input (and how)? And what do you actually do with the output?

 

Regards

 

Phil K

 

Sent from Mail for Windows 10

 

From: John Magill
Sent: 10 April 2020 13:34
To: TasmotaUsers
Subject: Re: power pulse timer

 

Very simple test.

--

You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

John Magill

unread,
Apr 10, 2020, 12:48:16 PM4/10/20
to TasmotaUsers
Input for the purposes of the test is connected to ground.
The mqtt message which should show the interval between pulses goes to Node Red and subsequently via web to my phone. (using Node Red dashboard)

Philip Knowles

unread,
Apr 10, 2020, 1:22:29 PM4/10/20
to John Magill, TasmotaUsers

The ‘rest’ state for an input should be Vcc and only go low with an input (unless an inverted input) . What happens if you tie to Vcc?

 

Regards

 

Phil K

 

Sent from Mail for Windows 10

 

From: John Magill
Sent: 10 April 2020 17:48
To: TasmotaUsers
Subject: Re: power pulse timer

 

Input for the purposes of the test is connected to ground.

The mqtt message which should show the interval between pulses goes to Node Red and subsequently via web to my phone. (using Node Red dashboard)

--

You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

John Magill

unread,
Apr 10, 2020, 1:56:48 PM4/10/20
to TasmotaUsers
Ok with input tied to vcc I still get a publish at approx 1 second intervals

Philip Knowles

unread,
Apr 10, 2020, 3:38:10 PM4/10/20
to John Magill, TasmotaUsers

The problem is that the counter isn’t resetting after the message so it’s repeatedly sending the same value.

on counter#c1>0 do backlog publish leccy %value%; counter1 0 endon

seems to work

 

Regards

 

Phil K

 

 

Sent from Mail for Windows 10

 

--

You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

John Magill

unread,
Apr 10, 2020, 4:02:16 PM4/10/20
to TasmotaUsers
that does stop the multiple publishes but each time it reports
"stat/frontFlood/RESULT : {"Counter1":0}"
I would like to suppress these messages as I log all mqtt messages.
thanks.
John

On Friday, 10 April 2020 20:38:10 UTC+1, Philip Knowles wrote:

The problem is that the counter isn’t resetting after the message so it’s repeatedly sending the same value.

on counter#c1>0 do backlog publish leccy %value%; counter1 0 endon

seems to work

 

Regards

 

Phil K

 

 

Sent from Mail for Windows 10

 

From: John Magill
Sent: 10 April 2020 18:56
To: TasmotaUsers
Subject: Re: Re: power pulse timer

 

Ok with input tied to vcc I still get a publish at approx 1 second intervals

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.

To unsubscribe from this group and stop receiving emails from it, send an email to sonof...@googlegroups.com.

Philip Knowles

unread,
Apr 10, 2020, 5:17:06 PM4/10/20
to TasmotaUsers, John Magill
Will have a think

Sent from Outlook Mobile


Sent: Friday, April 10, 2020 9:02:16 PM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Re: Re: power pulse timer
 
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/920161ef-e5e8-4103-8804-c0c63559d807%40googlegroups.com.

Philip Knowles

unread,
Apr 11, 2020, 4:50:46 AM4/11/20
to John Magill, TasmotaUsers

I’ve come up with a workround

on counter#c1!=%var1% do var1 %value% endon

 

09:36:53 RUL: COUNTER#C1!=%VAR1% performs "var1 0.336815"

09:36:53 MQT: stat/tasmota_electricity/RESULT = {"Var1":"0.336815"}

09:37:04 RUL: COUNTER#C1!=%VAR1% performs "var1 0.396861"

09:37:04 MQT: stat/tasmota_electricity /RESULT = {"Var1":"0.396861"}

09:37:08 RUL: COUNTER#C1!=%VAR1% performs "var1 0.430813"

09:37:08 MQT: stat/tasmota_electricity /RESULT = {"Var1":"0.430813"}

You get one MQTT message per operation of the input (from the var1 update). I’m not sure what would happen if you had a constant load – would the times be EXACTLY the same?

Michael Ingraham

unread,
Apr 11, 2020, 4:57:21 AM4/11/20
to TasmotaUsers
See if changing the MQTTLog setting can filter some of the traffic you want to eliminate.

John Magill

unread,
Apr 11, 2020, 5:25:17 AM4/11/20
to TasmotaUsers
Thank you so much for your time..
Yes this does reduce the throughput to once per pulse. I assume that response is in json format which I can parse in Node Red.
Does it have to publish as stat/xxxx/RESULT and not just as a simple "leccy"?

Philip Knowles

unread,
Apr 11, 2020, 7:13:26 AM4/11/20
to TasmotaUsers, John Magill
Yes it is a JSON so can be extracted. stat is changeable as Prefix2 so you can get rid of that part. The topic too can be anything you like (like leccy). The message isn't being published so difficult to make other changes.
However, it is better to leave the prefix unchanged. At some future point you may want to handle all status, commands or Tele messages and the prefix is used for that.

Sent from Outlook Mobile


Sent: Saturday, April 11, 2020 10:25:17 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Re: Re: Re: power pulse timer
 
Thank you so much for your time..
Yes this does reduce the throughput to once per pulse. I assume that response is in json format which I can parse in Node Red.
Does it have to publish as stat/xxxx/RESULT and not just as a simple "leccy"?

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

John Magill

unread,
Apr 11, 2020, 7:47:26 AM4/11/20
to TasmotaUsers
Philip, thanks again. I'll proceed with this.
Message has been deleted

John Magill

unread,
Apr 11, 2020, 2:45:05 PM4/11/20
to TasmotaUsers
Maybe I'm being stupid but cannot work out how to change the topic.


On Saturday, 11 April 2020 12:13:26 UTC+1, Philip Knowles wrote:
Yes it is a JSON so can be extracted. stat is changeable as Prefix2 so you can get rid of that part. The topic too can be anything you like (like leccy). The message isn't being published so difficult to make other changes.
However, it is better to leave the prefix unchanged. At some future point you may want to handle all status, commands or Tele messages and the prefix is used for that.

Sent from Outlook Mobile


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of John Magill <mugg...@gmail.com>
Sent: Saturday, April 11, 2020 10:25:17 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Re: Re: Re: power pulse timer
 
Thank you so much for your time..
Yes this does reduce the throughput to once per pulse. I assume that response is in json format which I can parse in Node Red.
Does it have to publish as stat/xxxx/RESULT and not just as a simple "leccy"?

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonof...@googlegroups.com.

Philip Knowles

unread,
Apr 11, 2020, 2:59:31 PM4/11/20
to John Magill, TasmotaUsers

Tasmota is case ‘blind’ so Var1 and var1 are the same.

 

This will give

19:58:27 MQT: Leccy/RESULT = {"Var1":"115.719515"}

 

Regards

 

Phil K

Sent from Mail for Windows 10

 

From: John Magill
Sent: 11 April 2020 18:56
To: TasmotaUsers

Subject: Re: Re: Re: Re: power pulse timer

 

Now I'm confused as to where the variable Var1 (capital first letter) comes from as the rule does not contain it. Just trying to change the publish topic to something more friendly.

thanks

From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of John Magill <mugg...@gmail.com>
Sent: Saturday, April 11, 2020 10:25:17 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Re: Re: Re: power pulse timer

 

Thank you so much for your time..

Yes this does reduce the throughput to once per pulse. I assume that response is in json format which I can parse in Node Red.

Does it have to publish as stat/xxxx/RESULT and not just as a simple "leccy"?

 

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonof...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/d9147f65-1358-4471-bfa6-78d58b0514ef%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.

To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/16106da9-1d36-4be2-a3e6-6138c51c237e%40googlegroups.com.

 

Reply all
Reply to author
Forward
0 new messages