N.B nothing to do with dashboard!
I've created a node to work like a push button switch which (de)activates a facility in a connected physical device. The idea comes from the switch of the common Debug node which deactivates or activates the debug output. My node is configured as a toggle button whose onclick function injects a custom "start" or "stop" message back to js code using the RED.httpAdmin.post facility.
It all works perfectly. My problem is that when the flow restarts, the initial state of the button is always "in" i.e. like the deactivated state of a Debug node.
How can I make it start in the activated state?
Here's the relevant code from the node's configuration:
buttonState: {value: true},
button: {
toggle: "buttonState",
onclick: function() {
console.log("ClICK " + this.buttonState);
doInject(this, {"payload":{"action": this.buttonState?"stop":"start"}});
}
}
where doInject() is an abbreviated version of the doInject function from the Inject node:
function doInject(node, customMsg) {
console.log("doInject: " + JSON.stringify(customMsg));
$.ajax({
url: "xkeys_led_inject/" + node.id,
type: "POST",
data: JSON.stringify(customMsg),
contentType: "application/json; charset=utf-8"
});
}
I don't think there's anything controversial in there. Of course I've tried both true and false as the initial value of buttonState but the problem remains that the initial state always appears as deactivated.
Any ideas on how to set the initial state?