Parshing Serial data and updating item state

Tags: #<Tag:0x00007fc8ed93ab80>

I have setup serial connection between Openhab2 and arduino. A keypad is connected to the arduino. whenever a key is pressed the arduino will be sending the key number to OH. There are 7 switches which will then be toggled acording to that number. So how can i write this rule. I tried a String data “test” then used test.state==“ON” but it didnt work.
SO i want a rule that can toggle the switch number with respect to the recieved data. please help.

Hey! I could try to instruct in lengthy details but I think you’ll learn more by looking at this similar example:

Let us know if you need more help

well i read it and i did’t understand it totally. But it looks like a overkill for my problem. isnt there any simpler solution.

Your specific question is fully covered in the rules docs and dozens to hundreds of examples.

To change an Item’s state use sendCommand or postUpdate.

Test.sendCommand(ON)
1 Like