Pass parameter to JS Transformation scripts without rules?

Hi,

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:192.168.0.15:49880:JS(getTXPValue.js):'01001 01000 %s'], >[OFF:192.168.0.15:49880:JS(getTXPValue.js):'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: Connair Elro TXP script - Pastebin.com (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:

script.sh 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 192.168.0.15 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: http://www.fhemwiki.de/w/images/6/6a/ELRO_0100110111.png

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

Update

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=“>[*:192.168.0.15:49880:EXEC(tx433 01100 10010 %s)]”

Here is the script: Updated Elro TXP script - Pastebin.com
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:192.168.0.15:49880:‘EXEC(elro433 10110 01100 on)’], >[OFF:192.168.0.15:49880:‘EXEC(elro433 10110 01100 off)’]”