[SOLVED] MAP in http binding

Hi!

Just use http binding. example:

String Lagerraum_Light_OutValue { http="<[https://raspberrypi/x.php{Authorization=Basic base64codedvaluehere}:2000:JSONPATH($.Lagerraum_Light)]" }
Switch Lagerraum_Light_Out "Lagerraum" <light> (UG) ["Alexa Lagerraum setzen"] { http=">[ON:POST:https://raspberrypi/x.php?lagerraum=true{Authorization=Basic base64==}] >[OFF:POST:https://raspberrypi/x.php?lagerraum=false{Authorization=Basic base64}]" }

my Lagerraum_Light_OutValue gets an ‘on’ or ‘off’ so I have a separat rule for Switching Lagerraum_Light_Out from ‘on’ to ON.
How this be done in an easier way without any rule?
I want a Light bulb showing yellow (for on) and white (for off). and next to it a switch to control…
Is this the best solution with an rule ?

rule "lagerraum"
when
	Item Lagerraum_Light_OutValue received update
then
	Lagerraum_Light_Out.postUpdate(if(Lagerraum_Light_OutValue.state == "on") ON else OFF)
end

Unfortunately, since you are already using a transformation you really only have two choices:

  • continue to use a Rule
  • use a JS transformation and extract the JSON value and transform it in JavaScript.

Your rule can be simplified though:

Lagerraum_Light_Out.postUpdate(Lagerraum_Light_OutValue.state.toString.toUpperCase)
3 Likes