Can't get Rules Tutorial to work

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
whatsupskip
Normal user
Posts: 89
Joined: 28 Feb 2018, 07:40

Can't get Rules Tutorial to work

#1 Post by whatsupskip » 21 May 2018, 08:28

I am just starting out with Rules, so I thought I would do the most basic example: https://www.letscontrolit.com/wiki/inde ... rial_Rules
However it doesn't seem to work. The LED turns on and then just stays on.

Have a made a basic mistake in the code?

Code: Select all

On System#Boot do
 gpio,12,0
 timerSet,1,10
endon

On Rules#Timer=1 do
 if [E1SW1#Switch]=1
 gpio,12,0
else
 gpio,12,1
 endif
 timerSet,1,10
endon
GIT version: mega-20180515
Wemos D1 Mini (v1 clone)

Any ideas would be great!

cyberclwn
Normal user
Posts: 20
Joined: 25 Aug 2017, 21:19

Re: Can't get Rules Tutorial to work

#2 Post by cyberclwn » 21 May 2018, 09:52

Hi,

Did you also do this part:
To be able to read the state of the LED (on or off) a switch input is created with the same GPIO port
?

danmero
Normal user
Posts: 64
Joined: 11 May 2017, 01:19

Re: Can't get Rules Tutorial to work

#3 Post by danmero » 21 May 2018, 13:04

Code: Select all

On Rules#Timer=1 do
 if [E1SW1#Switch]=1  # DEVICE
 gpio,12,0 # GPIO
 else
 ....
- You can SET the the state of GPIO from Rules.
- You can't GET the state of the GPIO from Rules. For this you have to use plugins , aka declare the GPIO as device on Device Tab.
  1. Device name: E1SW1
  2. Type: Switch
  3. GPIO: 0
As you can see from your example you call the device name: [E1SW1#Switch]

Regards,

whatsupskip
Normal user
Posts: 89
Joined: 28 Feb 2018, 07:40

Re: Can't get Rules Tutorial to work

#4 Post by whatsupskip » 24 May 2018, 05:06

Thank you both for your help.

I hadn't set up the switch device.

I edited the Wiki page to clarify the set up of the switch.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests