Motion sensor with GPIO

hi guys, my english is too bad but i sure that you can help me
i would like my motionsensor working

  1. printing “INTRUSE” when detected movement and none when nothing detect.
  2. let me show to another way when sensor motion detected something but no LED.

this is my code:

Contact PIR “PIR” { gpio=“pin:18” }

the sensor in sitemap was created as Text.

the rule is:
rule "pirrule"
Item PIR changed to OPEN
postUpdate( PIR, ON)


The rule makes no sense. PIR is a Contact which is fine. Your rule triggers when PIR changes to OPEN which is fine. But you then try to postUodate ON to PIR?

What are you trying to accomplish with this rule? A Contact can only be OPEN or CLOSED.

i was probing because i don’t know how can i make that PIR show me a message (text) in real time trough the app when detect something. it´s similar when you check the temperature in openhab. state of the motion sensor. thanks for help me

You can’t. You need a separate String Item to show text. Something like:

String PIR_str "PIR [%s]"

But if you use a contact icon it will automatically switch between the open and closed versions of the Item.

Contact PIR "PIR" <contact> {gpio="pin:18"}

If you want to see the state of the Item printed as a String (i.e. OPEN, and CLOSED for a Contact) just supply the [%s] as part of the label.

Contact PIR "PIR [%s]" {gpio="pin:18"}

If you want something fancier to be printed instead of OPEN and CLOSED you can use a MAP.

Contact PIR "PIR [MAP(]" {gpio="pin:18"}

where contains:

-= Undefined

I recommend spending some time with the openhab wiki, in particular the Items and Sitemap pages.

thank you Rich, your information has been very useful, i have been checking wikis but is not easy for me because my native language is Spanish. I’m Colombian. just I’m learning English.