Serial BINDING - REGEX

Hi there, for almost one year, trying to STARTUP my smarthome APPLICATION … up today I was able to find every solution in this rich community, but today I am stuck.

I’ve got SERIAL BINDING WORKING perfect, but I would like to do some IMPROVMENTS:

I have these ITEMS:

String SerialLinkSwitches "[%s]" (arduinoSwitches) {serial="/dev/ttyUSB0"}
String SerialLink "[%s]" (arduinoCentralUnit)  {serial="/dev/ttyUSB0"}

And what I would like to do is, pass to the SerialLinkSwitches only the comming values starts with string “S:”

for eg.

S:18:1:60
S:19:5:60

but not

V:15:16:5
L:15:14:1

so I was expecting to do something like

String SerialLinkSwitches "[%s]" (arduinoSwitches) {serial="/dev/ttyUSB0, REGEX(^S:)"}

but this is not working as I would expected, cause no values changed SerialLinkSwitches content …

any hint ? THX

All the examples in the README do not put a space between the , and the REGEX. Beyond that I always assumed that the REGEX was for incoming data, not to parse outgoing data.

An alternative way to implement this, assuming that the REGEX won’t work at all once you remove the space, is to use one Item to represent the Serial link to ttyUSB0 and use Proxy Items and Rules to control what gets published to the device.

Is not even working without the space, probably the “Proxy Item Pattern” will do the job ! Thx …

i have a problem with serial bindong and regex.
The incoming string look like -100;12100;ON;ON

My items is:

Number   UPS_Current     "Ток АКБ [%d]"                 { serial="/dev/ttyS0@19200,REGEX(^(-?\\d{1,5}))" ,autoupdate="true"} 
Number   UPS_Voltage     "Напряжкение АКБ  [%d]"         { serial="/dev/ttyS0@19200,REGEX(;(\\d{1,5});)" ,autoupdate="true"}   
Switch   Main_Power_220      "Сеть 220V [%s]"                 { serial="/dev/ttyS0@19200,REGEX(.*;(\\D{2,3});)" ,autoupdate="true"} 

My log:

2019-12-24 20:01:24.751 [thome.event.ItemStateEvent] - UPS_Current updated to 6380
2019-12-24 20:01:24.793 [thome.event.ItemStateEvent] - Main_Power_220 updated to OFF
2019-12-24 20:01:24.815 [vent.ItemStateChangedEvent] - UPS_Current changed from 6305 to 6380
2019-12-24 20:01:24.842 [thome.event.ItemStateEvent] - UPS_Voltage updated to 12472
2019-12-24 20:01:24.856 [vent.ItemStateChangedEvent] - UPS_Voltage changed from 12516 to 12472
2019-12-24 20:01:26.253 [thome.event.ItemStateEvent] - UPS_Current updated to 6180
2019-12-24 20:01:26.290 [vent.ItemStateChangedEvent] - UPS_Current changed from 6380 to 6180
2019-12-24 20:01:26.307 [thome.event.ItemStateEvent] - Main_Power_220 updated to OFF
2019-12-24 20:01:26.341 [thome.event.ItemStateEvent] - UPS_Voltage updated to 12492
2019-12-24 20:01:26.354 [vent.ItemStateChangedEvent] - UPS_Voltage changed from 12472 to 12492
2019-12-24 20:01:27.754 [thome.event.ItemStateEvent] - UPS_Current updated to 4640
2019-12-24 20:01:27.791 [thome.event.ItemStateEvent] - Main_Power_220 updated to ON
2019-12-24 20:01:27.841 [vent.ItemStateChangedEvent] - UPS_Current changed from 6180 to 4640
2019-12-24 20:01:27.859 [thome.event.ItemStateEvent] - UPS_Voltage updated to 12720
2019-12-24 20:01:27.876 [vent.ItemStateChangedEvent] - UPS_Voltage changed from 12492 to 12720
2019-12-24 20:01:29.255 [thome.event.ItemStateEvent] - UPS_Current updated to -122
2019-12-24 20:01:29.304 [thome.event.ItemStateEvent] - Main_Power_220 updated to ON
2019-12-24 20:01:29.345 [thome.event.ItemStateEvent] - UPS_Voltage updated to 12744
2019-12-24 20:01:29.361 [vent.ItemStateChangedEvent] - UPS_Current changed from 4640 to -122

as we can see data parced correctle bu why item Main_Power_220 updated not changed from OFF to ON?

this is sitemap:

		Group item=Hardware label="UPS" icon="heating" {
			Text item=UPS_Current
			Text item=UPS_Voltage
	        Switch  item=Main_Power_220   valuecolor=[Main_Power_220=="ON"="red",Main_Power_220=="OFF"="black"]
				}

UPS_Current and UPS_Voltage displayed fine. But Main_Power_220V does not change depending on item state. @rlkoshak

First, you should have started a new thread for this.
Second, have you checked the openhab.log to see what the serial binding is doing?