Variables in TimerSet

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
ChrisT
New user
Posts: 7
Joined: 24 May 2020, 09:43

Variables in TimerSet

#1 Post by ChrisT » 25 May 2020, 14:57

Hello everyone,
I've only recently discovered ESPEasy and am tinkering around trying to understand what it can do. My test setup is a D1 Mini, BME280, BH1750, a couple of LEDs, Solar Cell with battery, Analogue input measuring battery voltage and I'm logging that data to ThingSpeak. So far so good.

My current challenge is to set a variable timer for my test "irrigation" system, I can't seem to use a variable in TimerSet? Here's the whole rule:

Code: Select all

on System#Boot do
 GPIO,0,1                      // Make output set correctly
endon

LET 1,600                      // Set morning timer
LET 2,600                      // Set afternoon timer

on Clock#Time=ALL,%sunrise+1h% do  // 1 hour after sunrise...
 GPIO,0,0                      // turn on relay
 TimerSet,1,%v1%               // wait for v1 seconds
endon

on Rules#Timer=1 do            // When the timer runs out
 GPIO,0,1                      // turn off relay
endon

on Clock#Time=ALL,15:30 do     // Mid afternoon...
 GPIO,0,0                      // turn on relay
 TimerSet,2,%v2%               // wait for v2 seconds
endon

on Rules#Timer=2 do            // When the timer runs out
 GPIO,0,1                      // turn off relay
endon
I've been through loads of posts and tried these options with the following results:
Variable Result
%v1% 0.00
%V1% %V1%
[var#1] 0
[VAR#1] 0.00
[int#1] 0
[INT#1] 0

With variable 1 set to 600, 60 and 6 and using the syntax in column 1 for the variable in TimerSet, in my rules I get the result in column 2 the log.

Is it possible to use a variable in TimerSet? If so what am I doing wrong with the syntax?


Chris

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

Re: Variables in TimerSet

#2 Post by grovkillen » 25 May 2020, 15:23

You must declare the variables inside an event block! Use the system#boot for that.
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:

ChrisT
New user
Posts: 7
Joined: 24 May 2020, 09:43

Re: Variables in TimerSet

#3 Post by ChrisT » 25 May 2020, 15:54

Thought it had to easy!

Solved.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 38 guests