I’m trying to update a Switch Item from a json field via the http binding.
I can receive the value however this is numeric either 1.0 which would represent ON and 0.0 which represents OFF which the Switch Item does not understand.
I have created a second Number Item to receive the number and then a rule to update the Switch Item by sending an ON / OFF update but I’m sure there must be a better way??? I need to duplicate this a number of times.
rule "MuteN"
when
Item MuteN received update
then
// logInfo("Mute State", (MuteN.state).toString)
if ((MuteN.state) == 1) {
Mute.postUpdate(ON)
}
else
Mute.postUpdate(OFF)
end
Perfect… Thank you very much for keeping me sane!!!
I think learning some JS is next on my list…
So is ‘i’ always taken as the input from where the script is referenced in the http binding for example… so a different function would need to be in a different .js file?
It is the variable-name behind the “function” that is taken, changing the name in this position would change the variable name in the function badly.
And yes a different function would be in a different file.
I’ll have a play then, if I go up a few levels to http://10.10.1.52/datastore/mix/main/0 for example then there are more variables; so in this case I presume the whole lot would come through as ‘i’ and could be filtered (probably not the right word)…