Pass parameter to JS Transformation scripts without rules?


I want to pass parameters to a transformation Javascript without having to use rules, is this possible? Like this for example?

Switch Brennenstuhl_3A "Test Connair" (Outdoor, Lights) { udp=">[ON:'01001 01000 %s'], >[OFF:'01001 01000 %s']" }

(The purpose of the javascript is to convert 01001 01000 + ON/OFF into a TXP string which can be sent to my LAN gateway which turns my 433mhz wireless switches on or off)

Alright, I’ve written a shell script which does the job.

Interested in this. Can you provide the script?

Here you go: (used a template from the simple solutions forum, so credit goes mostly to that guy, I only improved some of the coding)
It probably got some coding flaws and also doesn’t have working error handling, but that doesn’t really matter anyway. (to me atleast)
If you want to use OpenHABs UDP binding, look down below for my new script

Usage is: elro masterdip slavedip on|off gatwayip gatewayport

Netcat has to be installed, else it won’t work. Here is the example usage with OpenHAB:

exec=">[*:tx433 elro 10110 11000 %2$s 49880]"

(my script tx433 is located in the /usr/bin folder, else you’d have to put in the full path)

This should work with SimpleSolutions Connair LAN Gateway, with the Intertechno Gateway and also the Brennenstuhl Gateway, can’t confirm the last both though, but from what I’ve read they use the same TXP string. If that’s not the case you probably have to rewrite it a little.

Also probably only devices with this kinda dip switches work with this script:

I use Elro AB440S socket switches, which work fine with the script.


I’ve also just written a script which just returns the TXP string via echo, so you can send the string via the TCP/UDP binding like this:

udp=">[*: 01100 10010 %s)]"

Here is the script:
Advantage over the other script is, that you don’t have to have Netcat installed on your machine. At the moment with OpenHAB 1.8.1, you can’t use wildcards with the UDP Binding, so my example above will throw an exception, you have to wait until my pull request gets accepted.

Until then you’d have setup your item like this.

udp=">[ON:‘EXEC(elro433 10110 01100 on)’], >[OFF:‘EXEC(elro433 10110 01100 off)’]"