[SOLVED] Combined transformations REGEX and MAP using HTTP binding

I have a device in my local network, which exposes its information for reading purposes via HTTP. The output is not structured (e.g. json or xml), but plain text and can be:

Device is ACTIVE


Device is DISABLED

I use the HTTP binding to read the message frequently:

String MyDevice_Status “Status” { http="<[http://device-host/endpoint:5000:REGEX(.* ([A-Z]+))]"} }

This reads the “ACTIVE” or “DISABLED” into the item MyDevice_Status. Now I want to map the extracted string (ACTIVE or DISABLED) to a good practice item state (ON or OFF). I can use a mapping for this:


However, I don’t see any possibility to combine MAP and REGEX in the item definition using the HTTP binding. I tried “chaining” them through

String MyDevice_Status “Status” { http="<[http://device-host/endpoint:5000:REGEX(.* ([A-Z]+)):MAP(device.map)]"} }

which brings an error.

Is it possible to combine transformations REGEX and MAP inside the item definition using an HTTP binding?

Shot answer: no. It is not possible to “chain” transformations.

You solution will be a proxy item:
Make your HTTP item as proxy and create a switch:

String MyDevice_Status_Proxy “Status” { http="<[http://device-host/endpoint:5000:REGEX(.* ([A-Z]+))]"} }
Switch MyDevice_Status

and a rule:

rule "Proxy mydevice"
    Item MyDevice_Status_Proxy changed
    MyDevice_Status.postUpdate(transform("MAP", "device.map", MyDevice_Status_Proxy.state.toString))
1 Like

Thanks much for the quick reply! I thought about a similar solution. Follow up question:

A second endpoint at the device I mentioned exposes to write a state change to the device (switching something on or off). I want to combine the status (ON/OFF) in Device_Status along with an additional HTTP binding to post the state to the device downstream.

Something like:

String MyDevice_Status_Proxy "Proxy" { http="<[http://device-host/endpoint:5000:REGEX(.* ([A-Z]+))]"} }
Switch MyDevice_Status "Status" { http=">[ON:POST:http://device-host/another-endpoint?active] >[OFF:POST:http://device-host/another-endpoint?disabled]"}

Assuming your suggested rule above posting an update to the switch, will this work together with the HTTP binding?

No, now you need to use .sendCommand in order to pass the state to the binding:

rule "Proxy mydevice"
    Item MyDevice_Status_Proxy changed
    MyDevice_Status.sendCommand(transform("MAP", "device.map", MyDevice_Status_Proxy.state.toString))
1 Like



force the HTTP binding to issue the POST call?

Yes… That’s the difference between postUpdate and sendCommand

Then I would say, in my case


is the proper thing.

I’m reading the state from the device frequently, through MyDevice_Proxy (and its HTTP binding). If the state of the device has changed, I don’t want to write the same state back to the device.

Correct, in your case.
Please tick the solution post, thanks