[SOLVED] Transforming switch status from 0/1 to ON/OFF

Fairly new user here. I have a remote USB relay controlled via crelay. I can control the relays, but would like to get back status. This is what I would like to do:

Switch sprinklerVlve1 { http=">[ON:GET:http://192.168.10.142:8000/gpio?pin=1?status=1] >[OFF:GET:http://192.168.10.142:8000/gpio?pin=1?status=0] <[http://192.168.10.142:8000/gpio:1000:REGEX(.Relay 1:(\d).)]" }

However, the switch wants ON or OFF, not 1 or 0. I’d like to keep this logic all in one line if possible. It doesn’t appear that chaining transforms is possible. The documentation I’ve read is at least a year old, and I’m not sure if there are new features that would do this. I know there’s regex substitution now, but I can’t get this to work for this use case.

:MAP(onoff.map)]"

I don’t think that will work because it appears @brianmichalk needs the REGEX expression to get the 0/1 in the first place.

Now, if the entirety of the return from the http GET is “Relay 1: 0” and “Relay 1: 1” then you can replace the REGEX transform with MAP:

Relay\ 1\: 0 = OFF
Relay\ 1\: 1 = ON

You may have to play with the map file to figure out the correct formatting.

If that won’t work, you will need to use a Number Item and set up a Proxy Switch Item and Rule to convert from the Number to Switch state.

That might work, and it’s not something I thought of trying. I have downloaded the crelay project and have modified the (almost) json into actual json, and am going that route. Thanks.
I’ve now got another problem with the http cache. I’m looking at the connections to the remote web service, and I’m not seeing the requests for status.
in my http.cfg file:

<sprinklerCache>.url=http://192.168.10.142:8000/gpio
<sprinklerCache>.updateInterval=10000

UPDATE:
That’s the wrong syntax. the http.cfg file is:

http:sprinklerCache.url=http://192.168.10.142:8000/gpio
http:sprinklerCache.updateInterval=10000

Openhab is like a drug dependency. It’s hell slogging through this, but you get a button to show up here or there, and the gratification is there. For me, there’s been a lot of disappointment, but man, this is an amazing tool. There’s a few idiosyncracies, okay a lot. I’ve spent more than a few hours getting device tracking, MQTT, and now this remote web interface to my sprinklers. I may look into OpenSprinkler, but for now, I think I can deploy the new relays as OpenHab items.

For completeness, here’s a Switch item:

Switch sprinklerValve5 { http=">[ON:GET:http://192.168.10.142:8000/gpio?pin=5?status=1] > 
 OFF:GET:http://192.168.10.142:8000/gpio?pin=5?status=0] <[sprinklerCache:5000:JSONPATH($.Relay5)]" }