Resets the variable every day.

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mvn77
Normal user
Posts: 12
Joined: 25 Jan 2017, 21:18

Resets the variable every day.

#1 Post by mvn77 » 17 Mar 2017, 18:47

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

mvn77
Normal user
Posts: 12
Joined: 25 Jan 2017, 21:18

Re: Resets the variable every day.

#2 Post by mvn77 » 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?

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Resets the variable every day.

#3 Post by toffel969 » 18 Mar 2017, 10:54

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
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

mvn77
Normal user
Posts: 12
Joined: 25 Jan 2017, 21:18

Re: Resets the variable every day.

#4 Post by mvn77 » 18 Mar 2017, 12:01

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 ....

paxi
Normal user
Posts: 121
Joined: 02 Feb 2017, 00:48
Location: Germany

Re: Resets the variable every day.

#5 Post by paxi » 18 Mar 2017, 18:04

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.

mvn77
Normal user
Posts: 12
Joined: 25 Jan 2017, 21:18

Re: Resets the variable every day.

#6 Post by mvn77 » 19 Mar 2017, 12:06

Thank you!!!!!!

mvn77
Normal user
Posts: 12
Joined: 25 Jan 2017, 21:18

Re: Resets the variable every day.

#7 Post by mvn77 » 19 Mar 2017, 18:59

Can create a rule for calculating RAINRATE for DOMOTICZ? RAINRATE = amount of rain in last hour

paxi
Normal user
Posts: 121
Joined: 02 Feb 2017, 00:48
Location: Germany

Re: Resets the variable every day.

#8 Post by paxi » 20 Mar 2017, 00:27

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.

novembre62
Normal user
Posts: 10
Joined: 10 May 2019, 15:39
Location: italy

Re: Resets the variable every day.

#9 Post by novembre62 » 10 May 2019, 15:49

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

User avatar
grovkillen
Core team member
Posts: 3225
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Resets the variable every day.

#10 Post by grovkillen » 10 May 2019, 16:47

Use rule and the command TaskValueSet.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
grovkillen
Core team member
Posts: 3225
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Resets the variable every day.

#11 Post by grovkillen » 10 May 2019, 16:58

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.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

novembre62
Normal user
Posts: 10
Joined: 10 May 2019, 15:39
Location: italy

Re: Resets the variable every day.

#12 Post by novembre62 » 10 May 2019, 19:48

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?

User avatar
grovkillen
Core team member
Posts: 3225
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Resets the variable every day.

#13 Post by grovkillen » 10 May 2019, 20:06

To trigger the value change event you can do the same but change the command to TaskValueSetAndRun.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

novembre62
Normal user
Posts: 10
Joined: 10 May 2019, 15:39
Location: italy

Re: Resets the variable every day.

#14 Post by novembre62 » 10 May 2019, 21:35

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

User avatar
grovkillen
Core team member
Posts: 3225
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Resets the variable every day.

#15 Post by grovkillen » 11 May 2019, 10:12

Don't have spaces in the event name!
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

novembre62
Normal user
Posts: 10
Joined: 10 May 2019, 15:39
Location: italy

Re: Resets the variable every day.

#16 Post by novembre62 » 11 May 2019, 14:26

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

User avatar
grovkillen
Core team member
Posts: 3225
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Resets the variable every day.

#17 Post by grovkillen » 11 May 2019, 14:35

Maybe try the TaskValueSet followed be a TaskRun instead...

Code: Select all

...
  TaskValueSet,1,2,0
  TaskRun,1
...
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
grovkillen
Core team member
Posts: 3225
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Resets the variable every day.

#18 Post by grovkillen » 11 May 2019, 14:38

If that isn't working it might be a bug.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

novembre62
Normal user
Posts: 10
Joined: 10 May 2019, 15:39
Location: italy

Re: Resets the variable every day.

#19 Post by novembre62 » 11 May 2019, 14:41

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

novembre62
Normal user
Posts: 10
Joined: 10 May 2019, 15:39
Location: italy

Re: Resets the variable every day.

#20 Post by novembre62 » 11 May 2019, 14:42

Total value does not change

User avatar
grovkillen
Core team member
Posts: 3225
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Resets the variable every day.

#21 Post by grovkillen » 11 May 2019, 14:43

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?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

novembre62
Normal user
Posts: 10
Joined: 10 May 2019, 15:39
Location: italy

Re: Resets the variable every day.

#22 Post by novembre62 » 11 May 2019, 14:45

that's what I already do, reboot at 00:01, but I'd like to avoid this

novembre62
Normal user
Posts: 10
Joined: 10 May 2019, 15:39
Location: italy

Re: Resets the variable every day.

#23 Post by novembre62 » 11 May 2019, 14:47

in the post above I read:
TaskValueSet 4.3, [test # a] - [test # b]

but I didn't understand what to do

User avatar
grovkillen
Core team member
Posts: 3225
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Resets the variable every day.

#24 Post by grovkillen » 11 May 2019, 14:57

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.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

novembre62
Normal user
Posts: 10
Joined: 10 May 2019, 15:39
Location: italy

Re: Resets the variable every day.

#25 Post by novembre62 » 11 May 2019, 15:01

OK thank you very much

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

Re: Resets the variable every day.

#26 Post by TD-er » 11 May 2019, 21:44

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.

Domosapiens
Normal user
Posts: 283
Joined: 06 Nov 2016, 13:45

Re: Resets the variable every day.

#27 Post by Domosapiens » 12 May 2019, 01:06

My suggestion,
at 00.01
read the value
and
subtract that value
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

novembre62
Normal user
Posts: 10
Joined: 10 May 2019, 15:39
Location: italy

Re: Resets the variable every day.

#28 Post by novembre62 » 23 Aug 2019, 18:51

.....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

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests