Change Total value of a pulse counter with command

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bulthaup
Normal user
Posts: 8
Joined: 29 Jul 2019, 15:10

Change Total value of a pulse counter with command

#1 Post by bulthaup » 08 Aug 2019, 20:41

Hi,
Sometimes I need to do maintenance in my electrical/network setup and I have to reboot the ESPEasy device during the day. I'm running pulse counters and after a reboot the total of the day so far is lost. Luckily I can gather the collected amount of pulses from my mqtt broker logs.

I'm looking for a way to push a Total value to the pulse counter. I tried it with taskvalueset but it doesn't work?

http://192.168.1.173/control?cmd=taskvalueset,1,2,163 (where 163 is the amount of Liters water we used so far during the day).

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

Re: Change Total value of a pulse counter with command

#2 Post by TD-er » 08 Aug 2019, 21:21

Taskvalueset is only supposed to work on Dummy variables.

You could use rules to add 2 values and output those to your controller of choice.
Then you can set the offset again in a dummy variable and just let the rules output the sum of both.

bulthaup
Normal user
Posts: 8
Joined: 29 Jul 2019, 15:10

Re: Change Total value of a pulse counter with command

#3 Post by bulthaup » 08 Aug 2019, 23:00

TD-er wrote:
08 Aug 2019, 21:21
Then you can set the offset again in a dummy variable and just let the rules output the sum of both.
Would you mind explaining this further in an example? Does the value of such dummy variable survive a reboot? Because I'm issuing a reboot every night at 0:00 with a rule to start collecting the Total count of my watermeter again for a new day.

I understand your approach but it's kinda hard for me to put it in writing (I'm not an experienced coder.. ) But I think what you mean that on a normal day, just the Total value + 0 is saved in another variable and that variable is published to a controller? So If I have to reboot my device I can push a value to a dummy to that variable with the control cmd and espeasy will continue to publish the sum of both the new and old count until a reboot?

Alvast bedankt! Thank in advance!

User avatar
ThomasB
Normal user
Posts: 385
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Change Total value of a pulse counter with command

#4 Post by ThomasB » 08 Aug 2019, 23:24

TD-er is probably in deep sleep at this hour. So I'll try to lend a hand while he counts sheep.
Does the value of such dummy variable survive a reboot?
On recent Mega releases the Dummy vars are retained in a warm boot. So no worries if you save the current count to a dummy var then use a rule to reboot the device. Keep in mind that dummy vars will be initialized to zero on a power reset (cold boot).
So If I have to reboot my device I can push a value to a dummy to that variable with the control cmd and espeasy will continue to publish the sum of both the new and old count until a reboot?
Yes, before the rule does the reboot just save the latest calculated Total count to a dummy var. During use, publish the calculated Total value (saved dummy value + new measured total) to your controller.

Edit: He's awake, so pardon my intrusion. :)

- Thomas
Last edited by ThomasB on 08 Aug 2019, 23:27, edited 2 times in total.

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

Re: Change Total value of a pulse counter with command

#5 Post by TD-er » 08 Aug 2019, 23:25

Yes, the Dummy plugin should get the last values restored after a reboot.
There is however a very big BUT here.
These values can only be kept if the ESP is not loosing its power.
If you remove power, the RTC memory is lost in which these values are being stored.

If you need that, then you have to wait until we have added support for I2C EEPROM/FRAM for this purpose.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests