Level control or rules ?
Moderators: grovkillen, Stuntteam, TD-er
Level control or rules ?
I admit that initially thought was easyer to do a very little project I had in mind, but it was more complicated than expected in practice.
It seems that sometime Esp Easy makes what is difficult easy and makes what seems easy difficult.
I need to toggle two relays, the first when a sensor connected to the board read a 0 value and the second one when the same sensor read 1 value.
No controller needed in this project ( domoticz or others), only a local board control ( nodemcu V3 in this case).
I read examples and tutorials about "control level" but on lets control it wiki support is not clear what kind of firmware is charged in the example. Mine is the last firmware released ( Mega, may 2019) and there are'nt the same options seen on the wiki ( ds18b20 that read a temperature if I right remember). In my case the sensor is a photoresistor mounted on a LM393 board that shows on the devices page of Esp Easy a value of 0 or 1 if exposed or not to the light.
But I cannot translate this value to an action that toggle each of the two relays.
Thanks in advance for any suggestion.
It seems that sometime Esp Easy makes what is difficult easy and makes what seems easy difficult.
I need to toggle two relays, the first when a sensor connected to the board read a 0 value and the second one when the same sensor read 1 value.
No controller needed in this project ( domoticz or others), only a local board control ( nodemcu V3 in this case).
I read examples and tutorials about "control level" but on lets control it wiki support is not clear what kind of firmware is charged in the example. Mine is the last firmware released ( Mega, may 2019) and there are'nt the same options seen on the wiki ( ds18b20 that read a temperature if I right remember). In my case the sensor is a photoresistor mounted on a LM393 board that shows on the devices page of Esp Easy a value of 0 or 1 if exposed or not to the light.
But I cannot translate this value to an action that toggle each of the two relays.
Thanks in advance for any suggestion.
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Level control or rules ?
Have you a rule that we can look at? I'm always here to help but find it easier if you already have something to look at instead trying to guess your setup.
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: Level control or rules ?
Thanks for your fast feedback at first.
No I don't have any rule wrote !
Your answer already sounds like a first suggestions: I need a rule!
Until now I was uncertain about this. So it's not enough to use level control plugin alone for this project?
I'll read with more attention wiki and so on, because probably don't payed enough attention on level control settings, if there where rules suggested or not.
On the other hand this statement suggested me an easy way to do what I need:
No I don't have any rule wrote !
Your answer already sounds like a first suggestions: I need a rule!
Until now I was uncertain about this. So it's not enough to use level control plugin alone for this project?
I'll read with more attention wiki and so on, because probably don't payed enough attention on level control settings, if there where rules suggested or not.
On the other hand this statement suggested me an easy way to do what I need:
You have to enter some IDX, even if this is not used. In this sample, we have connected a DS18B20 sensor and the heater is controlled using GPIO 12. We have set the required temperature to 21 degree with a hysteresis of 1 degree.
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Level control or rules ?
The wiki is outdated in many parts, we are moving to "read the docs". And yes rules are the way to do it.
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: Level control or rules ?
Ok,
My photoresistor read on the GPIO 16
Flagged internal pull up on the devices section and selected GPIO 16 with switch type.
So I wrote this rule:
Where on GPIO 12 and 14 I'll connect the two relays. I'd like that each relay should be on for 30 seconds.
How far I am from a correct rule ?
My photoresistor read on the GPIO 16
Flagged internal pull up on the devices section and selected GPIO 16 with switch type.
So I wrote this rule:
Code: Select all
On Rinnaimonitor#Rinnaimonitor=1 do
gpio,12,1
timerset,1,30
Endon
On Rinnaimonitor#Rinnaimonitor=0 do
gpio,14,1
timerset,1,30
Endon
How far I am from a correct rule ?
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Level control or rules ?
Good start, this is how I would do it. Please observer that is considered bad practice to have the same name for the task as well as its value. So I have used shorter and unique naming.
But I'm not sure this is how you would want it?
Code: Select all
On Rinnai#State do
If [Rinnai#State]=1
gpio,12,1
timerset,1,30
Else
gpio,14,1
timerset,1,30
Endif
Endon
On Rules#Timer=1 do
gpio,14,0
gpio,12,0
Endon
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: Level control or rules ?
Oh, not so far then......
Sure, I had already made some correction before your answer, i.e. state instead of Rinnaimonitor,
but now with your help I have some concrete roots for a bench test and then transfer it in the "real life".
Thanks a lot !
edit:
but the code probably should be this:
Sure, I had already made some correction before your answer, i.e. state instead of Rinnaimonitor,
but now with your help I have some concrete roots for a bench test and then transfer it in the "real life".
Thanks a lot !
edit:
but the code probably should be this:
Code: Select all
On Rinnai#State do
If [Rinnai#State]=1
gpio,12,1
timerset,1,30
If [Rinnai#State]=0
gpio,14,1
timerset,1,30
Endif
Endon
On Rules#Timer=1 do
gpio,14,0
gpio,12,0
Endon
-
- Normal user
- Posts: 307
- Joined: 06 Nov 2016, 13:45
Re: Level control or rules ?
Endif missing
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.
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Level control or rules ?
In your case you only have two states (1/0 or a Boolean gate) so even if you can do multiple if it's not necessary. I mean, if it's not one then it must be zero right?
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: Level control or rules ?
@ grovkillen
Ah,
so isn't necessary to repeat the same instruction for the second relay when the state is different from 1 ?
Is this the sense of "else" ?
@ Domosapiens: where is endif missing ?
Ah,
so isn't necessary to repeat the same instruction for the second relay when the state is different from 1 ?
Is this the sense of "else" ?
@ Domosapiens: where is endif missing ?
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Level control or rules ?
The "EndIf" was missing after your first if chunk. But given that you use "else" instead you don't have have add that EndIf between.
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



- dynamicdave
- Normal user
- Posts: 258
- Joined: 30 Jan 2017, 20:25
- Location: Hampshire, UK
Re: Level control or rules ?
You could probably re-write it as..
Code: Select all
On Rinnai#State do
If [Rinnai#State]=0
gpio,14,1
else
gpio,12,1
Endif
timerset,1,30
Endon
On Rules#Timer=1 do
gpio,14,0
gpio,12,0
Endon
Last edited by dynamicdave on 18 May 2019, 07:23, edited 1 time in total.
Re: Level control or rules ?
Ah, OK, thanks to everyone.
Re: Level control or rules ?
Sorry, does not work with any rules.
Not found any way to toggle the relay, one or other.
I resume here:
The lux sensor who makes as switch ( state 1 or 0) is connected to GPIO 16 ( setting or not in <<pull up>> mode).
The Input switch is setted in <<normal switch>> mode ( does not work in any mode)
The two relays are connected to the GPIO 14 and 12 ( all the GPIO are in default mode).
The relays are connected to the vin (5v) and ground of the nodemcu that's powered by USB port.
The IN of the relays are connected to 14 and 12 GPIO.
The sensor changes the state when exposed to enough light and espeasy actually shows the state from 1 to 0 ( only refreshing page in this esp easy version 2.0.0-dev12).
No one of the relay is switched on in any case.
Not found any way to toggle the relay, one or other.
I resume here:
The lux sensor who makes as switch ( state 1 or 0) is connected to GPIO 16 ( setting or not in <<pull up>> mode).
The Input switch is setted in <<normal switch>> mode ( does not work in any mode)
The two relays are connected to the GPIO 14 and 12 ( all the GPIO are in default mode).
The relays are connected to the vin (5v) and ground of the nodemcu that's powered by USB port.
The IN of the relays are connected to 14 and 12 GPIO.
The sensor changes the state when exposed to enough light and espeasy actually shows the state from 1 to 0 ( only refreshing page in this esp easy version 2.0.0-dev12).
No one of the relay is switched on in any case.
Re: Level control or rules ?
Found the answer by myself. Could be an help for guys interested in.
On devices page of your v2.0.0-dev12 esp easy , you CANNOT change the name of value as you want (i.e. State or Fantasy) ! You must leave the name SWITCH !
So, if you do it, leaving the name of value as is by default (Switch) your gadget will works, but the rule mast be as follow:
So when your sensor change fro 0 to 1 or viceversa, your relays board switches one of the relays.
On devices page of your v2.0.0-dev12 esp easy , you CANNOT change the name of value as you want (i.e. State or Fantasy) ! You must leave the name SWITCH !
So, if you do it, leaving the name of value as is by default (Switch) your gadget will works, but the rule mast be as follow:
Code: Select all
On Rinnai#Switch do
If [Rinnai#Switch]=1
gpio,12,1
gpio,14,0
Else
gpio,14,1
gpio,12,0
Endif
Endon
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Level control or rules ?
I wasn't aware that you're using dev12. Sorry
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: Level control or rules ?
My fault if missing on first post wich v was flashed on the board. A lot of attempts to install a fresh updated bin was made with an old flasher exited with a wifi failure or a bootloop of the board, since the new flasher included in the new release does'nt work in my PC. I'll try to work with another one with win7.
But absolutely tanks anyway.
But absolutely tanks anyway.
Who is online
Users browsing this forum: No registered users and 10 guests