Closed Yordan1976 closed 1 year ago
Hi @Yordan1976,
thanks for raising the issue. I've integrated the 3 missing parameters into the newest Dev-Version in #5
Altough the Code works, i have no possibility to test it in a real world scenario. Could you verify that the
image version uupascal/rest-light:DEV-2023.01.06
on docker hub works as desired, before i push to master?
Cheers, Pascal
Thanks for the quick response and the update!
I tested it without the third parameter, which I don't need and it works like expected. Should do so with all three paramters.
If you want to add an example for a codesend rule, you can use this for the "then part" (which is the only one which is part of the user-defined script in Openhab3). The ZAP-Plugs use two different codes for on and off:
logInfo("REST_light", "Member " + triggeringItem.name + " to " + receivedCommand)
try {
// receive decimal codes from item name, e.g. zap_1234567_2345678_key1
var decimal_code = ""
if(receivedCommand == ON) {
decimal_code = triggeringItem.name.toString.split("_").get(1)
} if(receivedCommand == OFF) {
decimal_code = triggeringItem.name.toString.split("_").get(2)
}
var protocol = "1"
var pulselength = "150"
var String jsonstring = ('{"api_key" : "<INSERT KEY HERE>", "decimalcode" : "' + decimal_code + '", "protocol" : "' + protocol + '", "pulselength" : "' + pulselength + '"}')
sendHttpPostRequest("http://<INSERT IP HERE>:4242/codesend", "application/json", jsonstring.toString, 5000)
logInfo("REST_light", jsonstring.toString)
logInfo("REST_light", "Finished command!")
} catch(Throwable t) {
logInfo("REST_light", "Caught exception during attempt to contact REST_light API!")
}
Danke nochmal :)
Oh, and I didn't test the whole image, but updated the rest-light.py in my container.
Thanks for the example, i've included it in the README 👍🏻
I've tested the container and the send
API, so everything should work.
Viele Grüße nach Ratingen :)
Hello Pascal,
codesend from 433Utils uses some optional paramters which can't be passed with REST-light:
https://github.com/ninjablocks/433Utils/blob/master/RPi_utils/codesend.cpp
In my case a pulseLength of 150 is needed to get things working. Can you please add the optional parameters?