When I press the button the connection is dropped and the status is displayed as disconnected (cool). Not working is the other way around. The connection drops from the server (btw status I can set correctly) but the button is now out of sync.
I tried to set the button state from javascript backend via
This is very confusing as you haven't really told us the full picture. Where, for example, is the button being shown? In the Editor, Dashboard, somewhere else?
Your code DOES have an effect if that is somewhere in the node's runtime. It sets that property to true. But what is node.config used for? It has no meaning unless you consume it somewhere else. But certainly it does not have any impact on the Node-RED Editor since that is not how to communicate between the runtime and the Editor.
The button is shown in the editor as on the inject or debug node and it works on click.
js
function notificationNode(config) {
RED.nodes.createNode(this, config);
var node = this;
node.config = config;
node.config.active = true;
I thought assigning toggle: "active", would somehow bind that variable to the button. But I might have to look in the DOM to find out how to toggle by hand.
I may be wrong but I don't believe that the inject-style button was ever meant to have its status changed dynamically. Though certainly you would be able to manually disable it (e.g. change colour and prevent input) by using jQuery, however, there is limited interactivity available on the Editor. Really though, you are pushing the boundaries of the architecture there I think. You would probably need to mess with Node-RED's internal comms or events.
Much easier though would be to implement a "gate" function within the runtime and use the status message (available from the runtime) to indicate that the "gate" was open or closed. Simply don't let the injected message go anywhere if the gate is closed.