Page 1 of 1

How to read an IO pin state in rules ?

Posted: 25 Feb 2019, 17:07
by DaveS
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

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

Posted: 25 Feb 2019, 19:24
by grovkillen
If you use custom events you can use those to do more advanced rules.

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

Posted: 26 Feb 2019, 12:04
by kimot
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.

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

Posted: 26 Feb 2019, 19:03
by DaveS
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:

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

Posted: 26 Feb 2019, 19:30
by grovkillen
Great! Thanks for the feedback! :D