Page 1 of 1

Generic - Pulse counter and /json?tasknr=1

Posted: 03 Mar 2020, 15:03
by petekeegan
Hi,
What a fantastic effort you have made with the ESPEasy.

I have been working on a water meter project for over a year and the ESPEasy is perfect for my needs.
Since I do not have internet at the properties I am metering I am using a SIM7000a LTE module to send UDP Packets to my IOT Server.
The LTE module is on a second ESP-12E.

When I query the Generic - Pulse counter Count,Total,Time values using "http://10.10.100.128/json?tasknr=1" <-- ESPEasy from my LTE-ESP
it returns the values from the last "Interval" not the current values that show on the Devices page.

http://10.10.100.128/devices returns for the first task

Code: Select all

Count:16
Total:2980
Time:11233
http://10.10.100.128/json?tasknr=1&view=sensorupdate returns

Code: Select all

{
"TaskValues": [
{"ValueNumber":1,
"Name":"Count",
"NrDecimals":2,
"Value":1.00
},
{"ValueNumber":2,
"Name":"Total",
"NrDecimals":2,
"Value":2964.00
},
{"ValueNumber":3,
"Name":"Time",
"NrDecimals":2,
"Value":11251.00
}],
"TTL":60000,
"TaskEnabled":"true",
"TaskNumber":1
}




I would like to query the current value of Count and Total then zero Count.
I would zero Total and Time every 24 hours.

I there a way to remotely trigger my Device/Task to use a Generic HTTP Controller every 15 minutes?

Help would be appreciated.
Thanks
Peter

Re: Generic - Pulse counter and /json?tasknr=1

Posted: 03 Mar 2020, 15:20
by TD-er
Sending every N minutes can be done in the rules. You can set a timer and then perform a SendToHttp command.
See: https://espeasy.readthedocs.io/en/lates ... nd-publish

You can also store the current count in a variable and then subtract that value from the current value.
This way you have the difference since last time you sent.
You can either store values in a variable using the let command ( https://espeasy.readthedocs.io/en/lates ... nds-listed ) or use a dummy plugin.

The values stored in tasks will be kept if the node reboots (as long as the node remains powered).
Using a dummy plugin also protects you from receiving strange values in the occasion the node crashes or reboots, because the counter values and the dummy values will be kept during reboot.

Re: Generic - Pulse counter and /json?tasknr=1

Posted: 03 Mar 2020, 17:18
by petekeegan
Thanks for the direction.
I did not know about the https://espeasy.readthedocs.io/ site.

I think I have solved the issue.
By issuing "http://10.10.100.128/control?cmd=taskrun,1" the Count, Total and Time are updated and Count is zeroed.
I then can issue the http://10.10.100.128/json?tasknr=1&view=sensorupdate command and the value are current.
So from what I see the /json?tasknr= returns the last values from running the task and not the current values of the counters.

I do not have any of the "Send to Controllers" enabled and have set the Interval to 65535 on my Device/Task.

I am running ESPAsyncWebServer on the ESP-12E/LTEmodem so when a http:// request is received it interrupts whatever is running.
I do not like to have the ESPEasy decide when to send the values because it interrupts the SIM7000a LTE modem post routine which takes about 20 seconds.
I will also have additional meters on the ESPEasy, therefore I want the ESP-12E/LTE modem controller to ask for the meter values at set intervals.

My next task will be to zero Total and Time every 24 hours.
The ESPEasy will not have the ability to connect to a time server so I will need to issue a command from the ESP-12E/LTEmodem to clear those values.

Thanks again for your help. What a great piece of work.

Peter

Re: Generic - Pulse counter and /json?tasknr=1

Posted: 05 Mar 2020, 00:18
by Domosapiens
My next task will be to zero Total and Time every 24 hours.
A rule:

Code: Select all

On Clock#Time=All,00:00 do
resetpulsecounter,1
EndOn
will do a reset of the first pulsecounter task.