Hello from Bristol, UK

Moderators: rtenklooster, Voyager, BertB, Stuntteam

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

Hello from Bristol, UK

#1 Post by ChrisT » 24 May 2020, 11:30

Hello everyone,
I've been tinkering with ESP8266 for a little while and was blissfully unaware of ESPEasy until quite recently!? Image my joy when I turned up here!

I don't really have a current project aim at the moment, just tryng understand what ESPEasy is and can do. I think I've got a handle on the basics for everything except Rules. In my test setup I've got a BME280, BH1750 and Analog input (measuring voltage output from a solar cell and battery charger), all logging to ThingSpeak every 30 minutes. Also a couple of outputs driving LEDs.

I've writen a few rules to handle some analogue and digital inputs and outputs but I have a few questions:
1. What the difference/benefits of New v Old rules engine? I've currently got Old Engine ticked.
2. I've used examples of the ubiquitous watering timer to understand timer activation. I'm trying to use %sunrise%, I've set my location and the system variable is correctly calculated when I check. However, the rule is triggered at midnight when I check the logs. Timed triggers work as expected. I've tried this on a D1 mini and ESP-01 and I get the same results.

Here's my test code

Code: Select all

on System#Boot do
 GPIO 0,1
endon

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

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

on Clock#Time=ALL,13:30 do    // Give the plants some lunch...
 GPIO 0,0                     // turn on relay
 TimerSet,2,600               // wait for 10 minutes
endon

on Rules#Timer=2 do           // When the time runs out
 GPIO 0,1                     // turn off relay
endon
Have I done something wrong?


Chris

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

Re: Hello from Bristol, UK

#2 Post by TD-er » 24 May 2020, 11:51

Hello and welcome.

I don't see right now why it would trigger at midnight.
Does it trigger always at midnight? (you can set the time using a command for testing)

About the difference between 'old' and 'new' rules engine.
The 'new' one tries to split the rules into smaller files. One per on...do ... endon block
The intended improvement here was to make rules processing faster and less resource intensive.
However, it is a pain to edit rules this way and not even all trigger events can be used like this.

So just keep using the 'old' rules engine.

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

Re: Hello from Bristol, UK

#3 Post by ChrisT » 24 May 2020, 12:32

Hi @TD-er,
thank you for the welcome.

I've been running the rule(s) now for a few days and when I look at the logs every morning I see the rule triggered at midnight and the timer runs to completion. So the rule is executed, but at midnight rather than sunrise. The system variable is set to the right time for my location. I don't have a full log now for today so can't share, I'll copy tomorrow.

I've set the time to a few minutes before the system variable says sunrise and still nothing happens at the system variable time. I've edited my rule and removed the +1h, just the plain system variable and the same thing happens.

Is there a way to print/examine the system variable other than from the advanced menu? Also, just a by the way the same thing happens to the sunset variable.


Chris

edit: clarification

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

Re: Hello from Bristol, UK

#4 Post by TD-er » 24 May 2020, 13:14

You can see the values for all system variables via the web interface: Tools => System Variables.

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

Re: Hello from Bristol, UK

#5 Post by ChrisT » 24 May 2020, 15:31

Yes that's where I'm looking. I'll keep at it.

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

Re: Hello from Bristol, UK

#6 Post by ChrisT » 24 May 2020, 23:29

My error, forgot to add the ALL to the ClockTime. I'm blaming old age!

All working now.

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

Re: Hello from Bristol, UK

#7 Post by grovkillen » 25 May 2020, 07:10

Thanks for the feedback.
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
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Hello from Bristol, UK

#8 Post by dynamicdave » 25 May 2020, 08:54

As your turn-off times are the same in both cases, you could use just one timer.

Code: Select all

on System#Boot do
 GPIO 0,1
endon

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

on Clock#Time=ALL,13:30 do    // Give the plants some lunch...
 GPIO 0,0                     // turn on relay
 TimerSet,1,600               // wait for 10 minutes
endon

on Rules#Timer=1 do           // When the time runs out
 GPIO 0,1                     // turn off relay
endon
Just one other point, I normally write the GPIO commands with a comma so the syntax matches TimerSet.
E.g. GPIO,0,1

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

Re: Hello from Bristol, UK

#9 Post by TD-er » 25 May 2020, 09:13

ChrisT wrote: 24 May 2020, 23:29 My error, forgot to add the ALL to the ClockTime. I'm blaming old age!

All working now.
Well, maybe we could also indicate in the logs what we think we're matching.
Not sure if it is still there in the DEBUG logs. I know I have had more elaborate debug logs when re-writing it.

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

Re: Hello from Bristol, UK

#10 Post by ChrisT » 25 May 2020, 12:12

@TD-er I've reintroduced my error, set the clock back and turned web debug to Debug More and this what i get:

Code: Select all

148451: EVENT: Clock#Time=Sun,23:59
152993: WD : Uptime 3 ConnectFailures 9 FreeMem 19840 WiFiStatus 3
182993: WD : Uptime 3 ConnectFailures 9 FreeMem 19864 WiFiStatus 3
208438: EVENT: Clock#Time=Mon,00:00
208484: ACT : GPIO 0,0
208485: Command: GPIO
208487: SW : GPIO 0 Set to 0
208490: ACT : TimerSet,1,600
208491: Command: TimerSet
212993: WD : Uptime 4 ConnectFailures 9 FreeMem 19848 WiFiStatus 3
Nothing extra other than triggered at midnight.

@dynamicdave Thanks for the tips. I like the consistency of your syntax GPIO and I'll change that. The two timers are there for me to experiment with variables next, but all for simpler code!

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

Re: Hello from Bristol, UK

#11 Post by TD-er » 26 May 2020, 00:34

Can you add a logentry line in those blocks that set the GPIO?
Just use some identifiable string as logentry so we make sure those triggers on the GPIO pin originate from the rules and not something else. (and also to see which block is triggered)

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests