Wired inputs in openhab

So i jst installed openhab on raspberry pi 2 and tested with gpio led. I plan to make a home automation wi relay module and pir sensors. I have a few things that i couldn’t understand.
1.How to connect pir motion sensor to the pi in wired way.
2. If there are two function that control a gpio pin e.g there is a switch in sitemap to control a led and a rule which controls the pin.
If one function turns the pin high will it be updated in other.

You would use the GPIO binding for interacting with the pins the pirs are connected to. They would be represented in OH as either a switch or a contract.

Manual triggering of a switch from the sitemap and triggering it from a rule is operating on the same entity within OH so there isn’t a need to keep anything in sync.

I understand that if any 1 case sets the pin high then it will make the pin high electronically. But will it be updated in the sitemap. Will the page show the switch as on

Assuming that the only thing controlling the pin is openHAB then of course the sitemap will update when the pin goes to high either from a rule, commanded from the sitemap, or through the REST API. The sitemap shows the current state of the Switch no matter where within openHAB it is commanded.

However, GPIO Binding is a somewhat special case in that it only allows read or write on a pin. If you set up a pin as a Switch you can only write to that pin. So if you have something set up completely external to openHAB that can change the pin’s state then that change will not be represented within openHAB.

Similarly, if you set up a pin as a Contact you can only read the state of a pin and not write to it. So if you won’t be able to change the state of the pin.

If you need to have it set up where the pin can be changed from external to openHAB, you will need to also set up a Contact and a rule that will postUpdate to the Switch any changes to the Contact.