Pointer please - How to If Then

I am new to Node Red.

I am loving it but still banging my head against a wall - really nice when I finally get it through my thick head :slight_smile:

A quick question please.

I am trying to create flow that

Every 30 minutes IF the Global Var Home==true THEN start a TRIGGER (Send ON wait for 3 mins THEN Send OFF

This all goes to a zigbee2MQTT Device through an MQTT Broker.

I have everything working so far EXCEPT the Switch 'IF the Global Var Home==true ' I tried adding this inline between Inject and Trigger then the whole thing fails and no debug out of the Switch.

I am sure there is a simple explanation but as a novice I am stumped..

Any assistance most welcome - despite watching many YouTube tutorials and trawling of docs I cannot figure this one out.

I stand ready to be chastised for my ignorance :slight_smile:

You probably need to select is true or is false in the switch node


Hard to say where it should be as you have not exported an example flow.

You need an inject node which fires every 30 minutes. (If it has to be on the hour and the half hour, use "interval between times" repeat option.) It doesn't really matter what it injects, timestamp is fine,

Next a switch node to test if global.Home is true.

FInally a trigger node to send ON and then OFF.

It sounds like this is what you have tried, but maybe some significant difference.

[{"id":"e9903743cbc8a414","type":"inject","z":"52d3a9a7a5712824","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"topic/for/mqtt","payload":"","payloadType":"date","x":300,"y":840,"wires":[["4e646c2770b8138d"]]},{"id":"4e646c2770b8138d","type":"switch","z":"52d3a9a7a5712824","name":"","property":"Home","propertyType":"global","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":490,"y":840,"wires":[["753d087941a80867"]]},{"id":"753d087941a80867","type":"trigger","z":"52d3a9a7a5712824","name":"","op1":"ON","op2":"OFF","op1type":"str","op2type":"str","duration":"3","extend":false,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":650,"y":840,"wires":[["45555d640325fcac"]]},{"id":"45555d640325fcac","type":"debug","z":"52d3a9a7a5712824","name":"debug 273","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":850,"y":840,"wires":[]},{"id":"1470a7712e983e1d","type":"inject","z":"52d3a9a7a5712824","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":230,"y":740,"wires":[["3ae485b9a984a785"]]},{"id":"3ae485b9a984a785","type":"change","z":"52d3a9a7a5712824","name":"","rules":[{"t":"set","p":"Home","pt":"global","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":760,"wires":[[]]},{"id":"f892b72d18f36c35","type":"inject","z":"52d3a9a7a5712824","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":230,"y":780,"wires":[["3ae485b9a984a785"]]}]

Thank you for your response - much appreciated

Screenshot 2023-02-24 at 18.00.51

With the If anyone at Home Switch in place it never fires and Home==true

If I remove the Switch all works - except of course it does if no-one is at home.

look at my image again == true is not is true.

Also show us the global home and what it is actuall set to.

1 Like

Yes, you are comparing boolean true/false with string "true"/"false" which doesn't work.

1 Like

You are a STAR!!!!!!!

My bad thank you soooooooooo much - that makes Sense - I couldn't see a Boolean in the drop down so did what I thought was an alternative.

It works great.

Thank you again - a Noob error - learned something new today -

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.