@ramy_rutu please use code fences to make you code readable.
Use the buttons at the top row of the text box. Or use the trippel quotation mark.
```
your code goes here
```
Please edit you previous post, thank you.
First I dont think using “.” and “/” in the thing name is a good idea.
Second you have two items called DOORSENSOR one Switch and one String, how schould openhab know which you want to control?
Third typos “chaned” is not “changed”
I will add some comment to your code:
.things
THINGS :Thing exec:command:./RFSniffer [ /* dot and slash are pretty bad in names */
command="/home/pi/433Utils/RPi_utils/./RFSniffer 14756833", /* does RFSniffer work like this ?*/
interval=2,
autorun=true]
/* as the sniffer usually sniff continously the first execution will never stop, untill someone stops it*/
.items
/* two items with the same name, this won´t work */
Switch DOORSENSOR { channel=“exec:command:./RFSniffer:run” } /* with this switch connected to the Thing run channel you can start the execution when toggleing to on */
String DOORSENSOR { channel=“exec:command:./RFSinffer:input” } /* this is the channel where you can input some data to the thing, not what the thing will answer back to you */
/* no output channel so if the command line gets executed we will never know what the result was.*/
.rules
rule "DOORSENSOR"
when Item DOORSENSOR chaned /*changed*/ to OPEN
then
postUpdate (433Utils/RPi_utils.state == OPEN){}
/*? Where is this item defined? And "/" in a name is a no go.*/
/* this is a mix if a postUpdate and if clause ? */
if(receivedCommand == 14756833){ /* probably should be compared with a string "14756833" if i asume DOORSENSOR is the string item. */
postUpdate DOORSENSOR.statusCommand =(“OPEN”)
/* postUpdate(DOORSENSOR, OPEN) DOORSENSOR.postUpdate(OPEN) or When i asume DOORSENSO is the switch but who knows */
}else{
if DOORSENSOR.stateCommand =(“CLOSE”)
postUpdate (433Utils/RPi_utils.state == CLOSE)
}
/* else if (DOORSENSOR.state == CLOSED){ postUpdate(DOORSENSOR, CLOSE ) } , and here is the best thing posting to the same item the allready known state. You have to give each item an unique name.*/
end
Please start over again, read carefully try some simple things for which you find Tutorials and first try to reproduce them and understand how everything works. Don´t rush fast. For Openhab there is a lot which has to be learned.
But, to answer your question:“This does not work at all”.
If RFSniffer would only listen to the given code and returns the recieved command, it wont stop.
So starting a RFSniffer every 2 second is not a good idea, besides the Reciever is allready in use by the first Sniffer.
imagine you would like to lsiten to multiple contacts, but if the one Thing you allready block the receiver.
You don’t want to regularly trigger something, you want to continously wait for an event like a received contact status.
Thus you will need to set up somthing like a MQTT server, which will wait for incomming data and forwards it to the Openhab MQTT Binding client.
And you will need a process which listens to the receiver and publish the data to the MQTT Server.
Have a look here, here and here for more info.
Or at least something like that.