currently i am struggeling with a door contact. By rule the contact should switch a light on and if the door is closed the light should be switches off after a while.
I startet with the rule like this
rule "My Light"
when
Item MyContact received command
then
but it never receives a command. Next is that i would like to use receivedCommand in the rule. This is only known if i user the received command in the rule header.
With received update the rule is triggered, but there is no variable receivedUpdate that i can use.
Yes, Contact items do not receive commands. They are imagined to be passive devices, like … well, a door contact. Devices that it makes no sense for OH to command, to tell them to do something.
A Switch item on the other hand, usually represents some kind of device that can “do something”, like say a relay to turn on the light.
What you are probably looking to do is respond to changes in the (read-only) door Contact by sending commands to a Switch.
You can be specific about the change you want to trigger a rule, MyContact changed to OPEN for example
Within a rule, you can examine an Items state: MyContact.state , MyLight.state , etc.