I’m messing around with functionality.
One of my devices requires POSTing a JSON string.
I can do this in the HTTP Binding using a MAP transform, but this is a little tedious (never mind requiring another file, and I don’t think works for dynamic stuff, such as colours).
Am I missing an obvious (combination of) feature(s) in the HTTP Binding which would allow me to do something like the MQTT Binding’s formatBeforePublish
feature?
My current configuration:
Things
Thing http:url:wled "WLED " [
baseURL = "http://192.168.1.126/json",
refresh = "10",
ignoreSSLErrors = "true",
commandMethod = "POST",
contentType= "application/json"
]
{
Channels:
Type switch : on "Power" [
mode = "READWRITE",
stateTransformation = "JSONPATH:$.state.on",
commandTransformation = "MAP:wledonoff.map",
onValue = "true",
offValue = "false"
]
}
MAP
false={"on":false}
true={"on":true}
What would be awesome is if I could get rid of the MAP transformation (and file), and do this directly within the Thing. If I pretend that formatBeforePublish
is available in the binding, my Thing would look like:
Thing http:url:wled "WLED " [
baseURL = "http://192.168.1.126/json",
refresh = "10",
ignoreSSLErrors = "true",
commandMethod = "POST",
contentType= "application/json"
]
{
Channels:
Type switch : on "Power" [
mode = "READWRITE",
stateTransformation = "JSONPATH:$.state.on",
formatBeforePublish = "{\"on\":%s}",
onValue = "true",
offValue = "false"
]
}