Toggle boolean switch WITHOUT any action

I have created a boolean switch for my dashboard “watching a movie”.
I have created a flow which will turn off some light, put other light to a certain brightness level (and will most likely be extended in the future with other ‘smart things (ie. curtains)’.

My goal is to start this flow by reading all entities ‘states’, so when I’m done watching the movie I can simply press the button and everything returns to its state from before. But this is a future goal.

What I now would like to achieve is the following:
When I watch the movie (so the lights are all in a certain state) and I decide to go to bed and switch everything off (other switch, other flow), how can I only flip the boolean of ‘watching a movie’ without doing te action (put all the lights in a certain state)?
Now the next day the boolean is in the wrong state, so I need to press it twice to start the flow I need
And when I integrate it in the ‘turn everything off state’ by checking if ‘watching movies’ is off it will turn everything on before turning the lights off… which is kind of unneeded

I don’t know if you want to show the state of the flow but you could do it with a momentary push button and toggle your watch movie flow with it. That way you can turn it on/off if you push the button and don’t have to reset it.

This sound like a solution, but in that case it will only send ‘on’ (or off) and I can’t return the lights to it’s original states.
This can be resolved by 2 momentary switches which checks when the first one is pushed, but don’t know if this 100% working

you can get the state with the current state node and store it by using a change node. here is an example:

[{"id":"295e4a38.729146","type":"inject","z":"cc639dbb.119d5","name":"signal 1","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"test1","payloadType":"str","x":160,"y":60,"wires":[["82b2b76a.4de208"]]},{"id":"6a3a12b8.a9886c","type":"inject","z":"cc639dbb.119d5","name":"signal 2","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":160,"y":180,"wires":[["ea4432d9.25744"]]},{"id":"82b2b76a.4de208","type":"change","z":"cc639dbb.119d5","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"var1","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":60,"wires":[[]]},{"id":"ea4432d9.25744","type":"change","z":"cc639dbb.119d5","name":"","rules":[{"t":"move","p":"var1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":180,"wires":[["3e2fe1c7.22a59e"]]},{"id":"3e2fe1c7.22a59e","type":"debug","z":"cc639dbb.119d5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":180,"wires":[]}]

Thanks for the sugestion, I will play around with this… Now I need to find out how to make a momentary push button.

I think there’s a better option than using input booleans for that.

I don’t know if your are using HACS but there is a momentary switch repository that I’m using:

Another solution would be this:

[{"id":"5010e08.b51242","type":"function","z":"cc639dbb.119d5","name":"T-Flipflop","func":"var currentState = context.get('state') || \"on\";\n\n\nif (currentState == \"on\")\n{\n    context.set(\"state\",\"off\");\n    msg.payload = \"off\";\n}\nelse if (currentState == \"off\")\n{\n   context.set(\"state\",\"on\");\n   msg.payload = \"on\"; \n}\nelse\n{\n    return;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":180,"wires":[["119ed7f6.6a5288"]]},{"id":"9a200f12.51c8c","type":"server-state-changed","z":"cc639dbb.119d5","name":"test switch","server":"44b2605f.5d41","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.test_switch","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":100,"y":120,"wires":[["336833a4.08971c"]]},{"id":"336833a4.08971c","type":"switch","z":"cc639dbb.119d5","name":"only when on","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":250,"y":120,"wires":[["5010e08.b51242","2f606a03.e9a0c6"]]},{"id":"2f606a03.e9a0c6","type":"delay","z":"cc639dbb.119d5","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":440,"y":120,"wires":[["29ed3cda.0cba74"]]},{"id":"29ed3cda.0cba74","type":"api-call-service","z":"cc639dbb.119d5","name":"tor test switch off","server":"44b2605f.5d41","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.test_switch","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":640,"y":120,"wires":[[]]},{"id":"119ed7f6.6a5288","type":"debug","z":"cc639dbb.119d5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":180,"wires":[]},{"id":"44b2605f.5d41","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"on","connectionDelay":false,"cacheJson":false}]

EDIT:
this is a good guide about node red variables:
http://www.steves-internet-guide.com/node-red-variables/

1 Like