How to read an IO pin state in rules ?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
DaveS
Normal user
Posts: 25
Joined: 12 Feb 2018, 17:35

How to read an IO pin state in rules ?

#1 Post by DaveS » 25 Feb 2019, 17:07

Hi All,

I have the rule below working fine,however I want to be able to disable both rules when needed by setting an IO pin high from openhab.

I can successfully toggle IO12 from openhab,I can see this in tools > pin state buffer,how do I read this pin state in rules to disable them when IO12 is high ?

Have tried setting up a switch under device tab using IO12 but it does not change state.

Code: Select all

on Pir_Sensor#Pir=1 do
   if [LDR#Analog]>1000 AND [Saturday#Inhibit]=0
     Publish RGB/0017F169/color/set,200,200,200
     Publish RGB/0017F169/brightness/set,200      
   endif
 endon

on Pir_Sensor#Pir=0 do
   if [LDR#Analog]>1000 AND [Saturday#Inhibit]=0
      Publish RGB/0017F169/state/set,OFF
  endif
endon
Thanks

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

Re: How to read an IO pin state in rules ?

#2 Post by grovkillen » 25 Feb 2019, 19:24

If you use custom events you can use those to do more advanced rules.
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:

kimot
Normal user
Posts: 165
Joined: 12 Oct 2017, 20:46

Re: How to read an IO pin state in rules ?

#3 Post by kimot » 26 Feb 2019, 12:04

You can assign input switch to your gpio12 and than tested its state.
Like at this example:
viewtopic.php?p=33716#p33716

But using events, like grovkillen wrote, is better way.

DaveS
Normal user
Posts: 25
Joined: 12 Feb 2018, 17:35

Re: How to read an IO pin state in rules ?

#4 Post by DaveS » 26 Feb 2019, 19:03

grovkillen wrote:
25 Feb 2019, 19:24
If you use custom events you can use those to do more advanced rules.
This now working well.
Thank you for the tip :idea:

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

Re: How to read an IO pin state in rules ?

#5 Post by grovkillen » 26 Feb 2019, 19:30

Great! Thanks for the feedback! :D
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:

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests