pulsecounter acting strange after latest changes

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
GravityRZ
Normal user
Posts: 107
Joined: 23 Dec 2019, 21:24

pulsecounter acting strange after latest changes

#1 Post by GravityRZ » 29 Apr 2020, 09:40

with build 20200410 i had a completely stable solution for at least 3 weeks
no extra or missing pulses.

now with build 20200426 i am experiencing strange things
i changed my rules script so i could use the setpulsecountertotal command instead of a dummy -device

first day i experienced that the pulsecounter total was missing 1 pulse
no rules involved because this happens directly in the plugin

to be save i restored the old rules which use count=1 as a trigger and increment a dummy device total
in this setup the dummy device total had an extra pulse.
strange thing in this situation is that the pulsecounter total was right

no reboots happened at that time so i suspect the changes made regarding restoring RTC values did not create this, nor did using the 4th var as a value.
at the moment i am going back to 20200410 to see if i still have a stable solution again

@TD-er,

can you see if changes between 20200410 and 20200426 has something to do with this

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

Re: pulsecounter acting strange after latest changes

#2 Post by TD-er » 29 Apr 2020, 11:15

OK, can you itemize what parts you think may have different behavior?
Reading these changes in story-like format are a bit hard to interpret and itemizing may help to categorize what things have been checked and ruled out and what not.

Just by reading your post (for a few times), it looks like:
- the plugin itself does record an extra pulse
- You made sure it was never a count>1 between intervals. (or at least not in the run with the old rules)

Do you still use the setpulsecountertotal command?
If so, it could be you set it to some value and almost immediately there is a new pulse registered.
Any offset should then be visible right after setting the counter total.

GravityRZ
Normal user
Posts: 107
Joined: 23 Dec 2019, 21:24

Re: pulsecounter acting strange after latest changes

#3 Post by GravityRZ » 29 Apr 2020, 12:21

TD-er wrote:
29 Apr 2020, 11:15
OK, can you itemize what parts you think may have different behavior?
Reading these changes in story-like format are a bit hard to interpret and itemizing may help to categorize what things have been checked and ruled out and what not.

Just by reading your post (for a few times), it looks like:
- the plugin itself does record an extra pulse
CORRECT: it is adding an extra pulse in case of the 20200426 firmware and with the old rules it is sometimes missing a pulse
i check on Count=1 but this does not change the total because the plugin does that

- You made sure it was never a count>1 between intervals. (or at least not in the run with the old rules)

Do you still use the setpulsecountertotal command?
Only on a cold boot, i retrieve the value from domoticz and set it to the pulsecounter so this does not account for extra/missing pulses
If so, it could be you set it to some value and almost immediately there is a new pulse registered.
Any offset should then be visible right after setting the counter total.
i added the complete setup here with the 3 scenarios
in a nutshell
20200410 build using count=1 as trigger to increment dummy counter is stable

20200426 using build in pulsecounter total is adding an extra pulse
20200426 build using count=1 as trigger to increment dummy counter is missing a pulse
Attachments
esp-devices-rules.rar
(153.73 KiB) Downloaded 31 times

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

Re: pulsecounter acting strange after latest changes

#4 Post by TD-er » 29 Apr 2020, 12:28

GravityRZ wrote:
29 Apr 2020, 12:21
[...]
20200426 using build in pulsecounter total is adding an extra pulse
20200426 build using count=1 as trigger to increment dummy counter is missing a pulse
This does look like it is still possible the pulse counter sometimes has "count=2".
Can you extend the rules slightly to store the counts where count > 1? You can use the %eventvalue% for that.

GravityRZ
Normal user
Posts: 107
Joined: 23 Dec 2019, 21:24

Re: pulsecounter acting strange after latest changes

#5 Post by GravityRZ » 29 Apr 2020, 13:00

do you mean like a test to see if there are pulses with values higher then 1

can you explain how to do this with %eventvalue% because i do not understand

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

Re: pulsecounter acting strange after latest changes

#6 Post by TD-er » 29 Apr 2020, 13:15

Yep, that's what I mean.

Just taken from your Word document:

Code: Select all

On Watermeter#Count do						// When Pulse is detected
	if [Watermeter#Count] = 1 				// if pulse is received
		TaskValueSet 3,4,[Water#CounterTotal]+1  	// increase Water#CounterTotal with 1 liter
		SendToHTTP 192.168.1.50,8084,/json.htm?type=command&param=udevice&idx=344&nvalue=0&svalue=[Water#CounterTotal]
		TaskValueSet 3,1,60000/[Watermeter#Time]	// set Water#Flow
		SendToHTTP 192.168.1.50,8084,/json.htm?type=command&param=udevice&idx=338&nvalue=0&svalue=[Water#Flow]
	endif
		if [Water#Flow] > [Water#MaxFlow]
		TaskValueSet 3,3,[Water#Flow]			// copy Water#Flow to Water#MaxFlow
EndOn
Not going to make it all, but just as illustration:

Code: Select all

On Watermeter#Count do						// When Pulse is detected
	if [Watermeter#Count] = 1 				// if pulse is received
	  // Normal operations, do your stuff.
	else
	  // Not normal so it is either 0 or > 1
	  // Just assuming you have a dummy task and task variable called [debug#total] at task position 12, variable position 1
	  TaskValueSet 12,1,[debug#total]+[Watermeter#Count]
	endif
EndOn
Just based on your description, it is incorrect behavior if the count > 1, but if you ignore it you will loose counts.
So maybe a simple fix in your rules can be to count any count > 1 as just a single count.

Code: Select all

	if [Watermeter#Count] >= 1 				// if pulse is received

GravityRZ
Normal user
Posts: 107
Joined: 23 Dec 2019, 21:24

Re: pulsecounter acting strange after latest changes

#7 Post by GravityRZ » 29 Apr 2020, 14:15

ok, that i can do(the %eventvalue% was not clear)

that would proof why pulses are missing but that will not proof where the extra pulse came from because that one is added directly to the total of the pulsecounter.

in this thread we tried to solve a problem regarding the RTC values which turned out to be a different problem becaue Bulthaup was using a formula
https://www.letscontrolit.com/forum/vie ... f=6&t=6926
i remember that you changed a sequence just to be sure this was not a problem.
i think it was this issue
https://github.com/letscontrolit/ESPEasy/pull/2996

could this have caused it or is this change already in build 20200410

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

Re: pulsecounter acting strange after latest changes

#8 Post by TD-er » 29 Apr 2020, 15:40

About the %eventvalue%

Just have a look at this part of your own rules:

Code: Select all

On Watermeter#Count do
The event starts with: "Watermeter#Count"
But the actual event is: "Watermeter#Count=1" (or =2..., you get the idea)
So the event has a value, which exists after the "=" sign.
In the rules you can refer to this value using %eventvalue%
So just like referring to [Watermeter#Count], which could have changed, you can also use %eventvalue% in the rules.
The content of %eventvalue% is the same as it was at the moment the event was fired.
Since the pulse counter acts on interrupts, it is possible the actual value of [Watermeter#Count] has changed by the time you refer to it from rules.


That pull request you refer to was already merged in build 20200410.

GravityRZ
Normal user
Posts: 107
Joined: 23 Dec 2019, 21:24

Re: pulsecounter acting strange after latest changes

#9 Post by GravityRZ » 29 Apr 2020, 15:55

ah,
finally clear to me

i let it run for a couple of days to see if it stays stable with current build 20200410(it did for 3 weeks)
after that i only update the firmware and let it run again for a couple of days.
finally i will change the rules to see if that affects things and will start the debugging

GravityRZ
Normal user
Posts: 107
Joined: 23 Dec 2019, 21:24

Re: pulsecounter acting strange after latest changes

#10 Post by GravityRZ » 15 May 2020, 17:32

well i did a lot of testing but sofar

after a week instantly 4 extra pulses
after another week of testing 1 missing pulse

i tested if the pulsecounter was triggered on values higher then 1 but this is not the case
i also did set the pulsecounter to the total amount and that value always matched to the one on the dummy device

so it looks like the extra pulse is cominf from the pulsecounter itself

because it ran completely stable for 3 weeks eith the previous build i am going to downgrade to version 20200410 or even 20200328

i will let it run again for another 3 weeks
if in those 3 weeks i do not get any extra or missing pulses then we might need to revert some changes we made in the p003 pulsecounter

not the setpulsecountertotal but the things before that.

will get back after 3 weeks

#update with 20200328 2 missing pulses so going back to 20200328

GravityRZ
Normal user
Posts: 107
Joined: 23 Dec 2019, 21:24

Re: pulsecounter acting strange after latest changes

#11 Post by GravityRZ » 02 Jun 2020, 13:17

ok.

it seems that after running stable for so long i tried to looosten up the settings
i apparently changed the wifi no sleep

after setting wifi to no sleep again the system seems stable also with the 20200426 build.

it seems that this one setting can cause extra pulses

could it be that some way when the wifi is sleeping and a pulse is counted the system comes back to life and again registers a pulse?

it has nothing to do with pulses missing because the total is calculated in the esp instead of sending over 1 pulse at a time

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

Re: pulsecounter acting strange after latest changes

#12 Post by TD-er » 02 Jun 2020, 22:06

If sleeping wifi was responsible for less pulses, then it would make sense.
I can't explain what you're experiencing.

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests