I’m baffled! I’m playing with Remote-Spark, and I cannot get the read variable value 1 from the Spark to show “On” in the HTML.
Showing this thing for on/1 value…
instead of “on”
Originally it was:
var varKey2 = "relaysEnable";
var var2onLabel = "On.";
var var2offLabel = "Off";
var var2onState = 1; // Set to null to allow raw value to be displayed.
var var2offState = 0; // Set to null to allow raw value to be displayed.
var refresh2 = 0; // variable 2 refresh rate in milliseconds (set to 0 to disable)
function getVariable2() {
getVariable(varKey2, function (res) {
if(res === var2onState)
$("#var-val-2").val(var2onLabel);
else if(res === var2offState)
$("#var-val-2").val(var2offLabel);
else
$("#var-val-2").val(res);
});
}
which either showed
(binary 1 icon) or blank
I then tried if(res == var2onState) instead of if(res === var2onState)
and it worked for Off but not on.
I tried
function getVariable1() {
getVariable(varKey1, function (res) {
if(res == 1 || res == '1' || res == true)
$("#var-val-1").val(var1onLabel);
else if(res == var1offState)
$("#var-val-1").val(var1offLabel);
else
$("#var-val-1").val(res);
Which worked… once!!! WTF?? then went back to the binary icon 1
Any assistance appreciated.