Page 1 of 1

Resets the variable every day.

Posted: 17 Mar 2017, 18:47
by mvn77
Help! It is necessary to reset the variable "TotalCount" every day (Device - Pulse Counter)
Rules -

Code: Select all

On Clock#Time=All,20:00 do
 [rain#TotalCount] = 0
endon
On Clock#Time=All,8:00 do
 [rain#TotalCount] = 0
endon
Rule does not work
log-
Fri Mar 17 20:00:02 2017: 192.168.0.51: <7>ESP Unit: 0 : EVENT: Clock#Time=Fri,20:00
Fri Mar 17 20:00:02 2017: 192.168.0.51: <7>ESP Unit: 0 : ACT : 1.40 = 0

Re: Resets the variable every day.

Posted: 18 Mar 2017, 09:14
by mvn77
Bad decision -

Code: Select all

On Clock#Time=All,20:00 do
reboot
endon
On Clock#Time=All,8:00 do
reboot
endon
Do you have any other suggestions?

Re: Resets the variable every day.

Posted: 18 Mar 2017, 10:54
by toffel969
Have you tried TaskValueSet command?( store variable in Dummy device, and 2.. task) then read dummy rather than sensor value


Like

On pulse#total do
TaskValueSet 2,1,[pulse#total]
End on

On Clock #Time=all, 20:00 do

TaskValueSet 2,1,0
Endon

Re: Resets the variable every day.

Posted: 18 Mar 2017, 12:01
by mvn77
I thought. But with the next record, he will write down the "pulse#total" value into the variable.
How much I understood in rules it is impossible to work with variables - to subtract, to multiply ....

Re: Resets the variable every day.

Posted: 18 Mar 2017, 18:04
by paxi
mvn77 wrote: 18 Mar 2017, 09:14 Bad decision -

Code: Select all

On Clock#Time=All,20:00 do
reboot
endon
On Clock#Time=All,8:00 do
reboot
endon
Do you have any other suggestions?
What happens? Bootloop for a minute I guess. In this case a workaround is to set a timer and reboot when it's 20:01.

You can do basic calculations in rules like this:

Code: Select all

TaskValueSet 4,3,[test#a]-[test#b]
So store your a bias-pulsecount once a day in one variable, substract that from the actual pulsecount into another dummyvalue and publish this.

Re: Resets the variable every day.

Posted: 19 Mar 2017, 12:06
by mvn77
Thank you!!!!!!

Re: Resets the variable every day.

Posted: 19 Mar 2017, 18:59
by mvn77
Can create a rule for calculating RAINRATE for DOMOTICZ? RAINRATE = amount of rain in last hour

Re: Resets the variable every day.

Posted: 20 Mar 2017, 00:27
by paxi
Always a joy. ;)

"Hourly rain" would be easy with the same principle using a timer that triggers every 60 minutes but that would only provide a measurement for every full hour. An instant (every minute) "last 60 minutes" would require to store 60 values and awefullly hacky rules- too much for espeasy - as mentioned earlier I don't use domoticz nor know its cababilities but think this kind of statisic is definately a job for the controler.

You could compromise something with 15 minute intervalls using the 4 availible values of a single dummy device, still a lot of fiddling though.

Re: Resets the variable every day.

Posted: 10 May 2019, 15:49
by novembre62
Hi!
I take these old posts to be helped:
sorry but I'm very inexperienced

I would like to reset my pulse counter variable at 00:01 every day
"Total" with the TaskValueSet rule

"Sensors": [
{
"TaskName": "counter",
"Count": 0.00,
"Total": 2591.75, <<<<<<<<<<<< THIS
"Time": 27470.00
},
{
"TaskName": "outside temperature",
"Temperature": 21.19
}

but I don't understand how to do it ... someone can help me
thank you

Re: Resets the variable every day.

Posted: 10 May 2019, 16:47
by grovkillen
Use rule and the command TaskValueSet.

Re: Resets the variable every day.

Posted: 10 May 2019, 16:58
by grovkillen

Code: Select all

On Clock#Time=All,00:01 Do
  TaskValueSet,TaskNo,ValueNo,Value
EndOn
If your device is on task number 4 (as an example) and the total is on value number 3 your rule would be looking like this:

Code: Select all

On Clock#Time=All,00:01 Do
  TaskValueSet,4,3,0
EndOn
And that is already explained further up in this topic.

Re: Resets the variable every day.

Posted: 10 May 2019, 19:48
by novembre62
Thanks for the reply.
I apologize if I ask a trivial question, but I am inexperienced ..
how can I then have the new value as a json output?

Re: Resets the variable every day.

Posted: 10 May 2019, 20:06
by grovkillen
To trigger the value change event you can do the same but change the command to TaskValueSetAndRun.

Re: Resets the variable every day.

Posted: 10 May 2019, 21:35
by novembre62
I entered the "TaskValueSetAndRun" command with rule

On Clock # Time = All, 21: 28 do
  TaskValueSetAndRun, 1,2,0
Endon

  but the "Total" value of the pulser counter device does not change

Re: Resets the variable every day.

Posted: 11 May 2019, 10:12
by grovkillen
Don't have spaces in the event name!

Re: Resets the variable every day.

Posted: 11 May 2019, 14:26
by novembre62
there are no spaces

in image my device

https://drive.google.com/file/d/1ZiPhKf ... dgXug/view

then
On Clock#Time=All,12:09 Do
TaskValueSetAndRun,1,2,0
EndOn

it's correct ?

the "TaskValueSetAndRun" command, should change the "Total" value of my device to 0 at the set time and then continue counting until the next set time ?????
Do not do anything else ... I read in the tutorial rules that a Dummy Device needs ... but I don't know how to do it

I use the value of my "Total" device as a JSON output, which I read in a monitoring system (Metern) in this way http://192.168.1.150/json?tasknr=1
It is a water meter and I would like to reset the value every day at 00:01
I apologize for my inexperience

Re: Resets the variable every day.

Posted: 11 May 2019, 14:35
by grovkillen
Maybe try the TaskValueSet followed be a TaskRun instead...

Code: Select all

...
  TaskValueSet,1,2,0
  TaskRun,1
...

Re: Resets the variable every day.

Posted: 11 May 2019, 14:38
by grovkillen
If that isn't working it might be a bug.

Re: Resets the variable every day.

Posted: 11 May 2019, 14:41
by novembre62
I tried but it doesn't work
log:
60867434: ACT: TaskValueSet, 1,2,0
60867446: ACT: TaskRun, 1
60867475: EVENT: counter # Count = 0.00
60867503: EVENT: counter # Total = 344.75
60867536: EVENT: counter # Time = 1245007.00
60876994: WD: Uptime 1011 ConnectFailures 0 FreeMem

Re: Resets the variable every day.

Posted: 11 May 2019, 14:42
by novembre62
Total value does not change

Re: Resets the variable every day.

Posted: 11 May 2019, 14:43
by grovkillen
Ok, I guess that TaskValueSet is the command not working then. Until we have fixed it you may do a reboot once at 00:01?

Re: Resets the variable every day.

Posted: 11 May 2019, 14:45
by novembre62
that's what I already do, reboot at 00:01, but I'd like to avoid this

Re: Resets the variable every day.

Posted: 11 May 2019, 14:47
by novembre62
in the post above I read:
TaskValueSet 4.3, [test # a] - [test # b]

but I didn't understand what to do

Re: Resets the variable every day.

Posted: 11 May 2019, 14:57
by grovkillen
The other example you posted is to show how you can do calculations. That's not what you're asking about. It's a bug and we should fix it. But in the meantime, do the reboot.

Re: Resets the variable every day.

Posted: 11 May 2019, 15:01
by novembre62
OK thank you very much

Re: Resets the variable every day.

Posted: 11 May 2019, 21:44
by TD-er
There still is a space in the line of the rules

Code: Select all

TaskValueSet, 1,2,0
And the suggestion made by Jimmy to do the reboot will probably not work (anymore) in the more recent builds.
I (quite recently) fixed a bug, which does now keep track of the last values of plugins after a reboot. (as long as the board was powered)
So I expect the plugin to continue counting after a crash or reboot.

Re: Resets the variable every day.

Posted: 12 May 2019, 01:06
by Domosapiens
My suggestion,
at 00.01
read the value
and
subtract that value

Re: Resets the variable every day.

Posted: 23 Aug 2019, 18:51
by novembre62
.....My suggestion,
at 00.01
read the value
and
subtract that value.....


.......I do not know how to do...

I can get help

thank you