Status of a switch - related if a script is running or not

I have a solarsystem, that is doing some battery charging stuff with scripts in iobroker.

  1. script: pi controlled solarcharging
  2. script: manual charging

both scripts can be switched on/off by a switch in a node-red dashboard

so my system is in "auto" mode, as long as the switch "pi on/off" is in on state.

sometime, i want a manual charging by a battery charger, that i can start manually with another script. in that case, the pi script will be stopped and the charger started.

but in my dashboard, my "pi on/off" switch, dont change its state - si it looks, that both are at the "on" state.

how do i fix that, that the switches have the status of the scripts? if enabled script, the switch should state on and vice versa.

the scripts will change its status, but the switches doesnt.

lg
Chris

You can feed the required state into the front of the switch to change it from your flow when necessary.

how? im new to node-red ^^

As you are a new Node-red user, can you confirm that you have installed the new dashboard @flowfuse/node-red-dashboard and not the outdated one node-red-dashboard?

The way you achieve things are slightly different between the two.

You can check by going to the hamburger menu at the top right then Manage Palette.

i have this version:

image

The appearance of a switch node can reflect message payloads sent to it.
If the payload is boolean false, the switch appearance will change so it looks off, and the status shown in the dashboard will be "off".
if it's true, the switch will appear to be on.

  1. This is not the same as clicking on the switch because no message is sent on from the switch (Unless you tick the pass through box on the switch config).
  2. The same thing happens if you send a payload matching the switch output payload, in this case "ON" or "OFF"

[{"id":"17fc961cb50dfe80","type":"ui-switch","z":"4f13805766521cb5","name":"","label":"Switch 1","group":"a78c26d96284e55f","order":1,"width":"2","height":"1","passthru":false,"decouple":false,"topic":"switch1","topicType":"str","style":"","className":"","onvalue":"ON","onvalueType":"str","onicon":"","oncolor":"","offvalue":"OFF","offvalueType":"str","officon":"","offcolor":"","x":360,"y":320,"wires":[["ef70457f42b7719a"]]},{"id":"ef70457f42b7719a","type":"ui-text","z":"4f13805766521cb5","group":"a78c26d96284e55f","order":2,"width":"2","height":"1","name":"","label":"Last msg from 1","format":"{{msg.payload}}","layout":"row-spread","style":false,"font":"","fontSize":16,"color":"#717171","className":"","x":560,"y":320,"wires":[]},{"id":"f32c3f04d030864a","type":"ui-button","z":"4f13805766521cb5","group":"20d91987fba15c6a","name":"","label":"ON","order":1,"width":"2","height":"1","emulateClick":false,"tooltip":"","color":"","bgcolor":"","className":"","icon":"","iconPosition":"left","payload":"ON","payloadType":"str","topic":"topic","topicType":"msg","buttonColor":"","textColor":"","iconColor":"","x":150,"y":300,"wires":[["17fc961cb50dfe80"]]},{"id":"2cd03e69b3f143b6","type":"ui-button","z":"4f13805766521cb5","group":"20d91987fba15c6a","name":"","label":"OFF","order":2,"width":"2","height":"1","emulateClick":false,"tooltip":"","color":"","bgcolor":"","className":"","icon":"","iconPosition":"left","payload":"OFF","payloadType":"str","topic":"topic","topicType":"msg","buttonColor":"","textColor":"","iconColor":"","x":150,"y":340,"wires":[["17fc961cb50dfe80"]]},{"id":"e577b8e8c2c56ae1","type":"ui-button","z":"4f13805766521cb5","group":"20d91987fba15c6a","name":"","label":"true","order":3,"width":"2","height":"1","emulateClick":false,"tooltip":"","color":"","bgcolor":"","className":"","icon":"","iconPosition":"left","payload":"true","payloadType":"bool","topic":"topic","topicType":"msg","buttonColor":"","textColor":"","iconColor":"","x":150,"y":380,"wires":[["17fc961cb50dfe80"]]},{"id":"bb1054a276b982b0","type":"ui-button","z":"4f13805766521cb5","group":"20d91987fba15c6a","name":"","label":"false","order":4,"width":"2","height":"1","emulateClick":false,"tooltip":"","color":"","bgcolor":"","className":"","icon":"","iconPosition":"left","payload":"false","payloadType":"bool","topic":"topic","topicType":"msg","buttonColor":"","textColor":"","iconColor":"","x":150,"y":420,"wires":[["17fc961cb50dfe80"]]},{"id":"a78c26d96284e55f","type":"ui-group","name":"Group2","page":"a522d4a2f7307c8b","width":"4","height":"1","order":2,"showTitle":true,"className":"","visible":"true","disabled":"false"},{"id":"20d91987fba15c6a","type":"ui-group","name":"Buttons","page":"a522d4a2f7307c8b","width":"2","height":"1","order":1,"showTitle":true,"className":"red","visible":"true","disabled":"false"},{"id":"a522d4a2f7307c8b","type":"ui-page","name":"Demo","ui":"ac5e535515ebb9c6","path":"/demo","icon":"home","layout":"grid","theme":"f36403a3012e6880","order":1,"className":"","visible":"true","disabled":"false"},{"id":"ac5e535515ebb9c6","type":"ui-base","name":"My Dashboard","path":"/dashboard","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control"],"showPathInSidebar":false,"navigationStyle":"default"},{"id":"f36403a3012e6880","type":"ui-theme","name":"Default Theme","colors":{"surface":"#ffffff","primary":"#0094CE","bgPage":"#eeeeee","groupBg":"#ffffff","groupOutline":"#cccccc"},"sizes":{"pagePadding":"12px","groupGap":"12px","groupBorderRadius":"4px","widgetGap":"12px"}}]

You can use this so that clicking one switch ON will turn another one OFF

  1. Be careful with this; if you have the pass through ticked you can make an infinite loop!
  2. If the switches trigger some additional processing, you may need extra code to interrupt it.
  3. Also take a look at the Button Group node which has this sort of processing built-in