Route a message based on the state of a global variable

Hello. I previously asked a question about global variables, and received a very helpful message. I am now able to store the information in a global variable.

However the way I thought I was going to be able to use the state of the variable does not work the way I thought it would.

Here is the current flow that I have :

[{"id":"1ad4aca0.44962b","type":"trigger-state","z":"ce6ada58.4431f8","name":"Below 70 to above 70","server":"ede8b68b.117128","entityid":"sensor.dark_sky_temperature","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"zg4qd7t2zw","targetType":"this_entity","targetValue":"","propertyType":"previous_state","propertyValue":"old_state.state","comparatorType":"<","comparatorValueDatatype":"str","comparatorValue":"70"}],"constraintsmustmatch":"all","outputs":3,"customoutputs":[{"outputId":"zkdz2m66sxp","messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":">=","comparatorValue":"70"}],"outputinitially":true,"state_type":"str","x":140,"y":260,"wires":[[],[],["a5d43467.2c1fa"]]},{"id":"a5d43467.2c1fa","type":"switch","z":"ce6ada58.4431f8","name":"Check PresenceState","property":"PresenceState","propertyType":"global","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":280,"wires":[["912a5f2.cdc332"],[]]},{"id":"912a5f2.cdc332","type":"time-range-switch","z":"ce6ada58.4431f8","name":"","lat":"41.661837","lon":"-72.910265","startTime":"sunrise","endTime":"2:00","startOffset":"+120","endOffset":"","x":600,"y":280,"wires":[["52a664b6.4932f4"],[]]},{"id":"52a664b6.4932f4","type":"api-call-service","z":"ce6ada58.4431f8","name":"Google Home broadcast above 70 degrees","server":"ede8b68b.117128","version":1,"service_domain":"notify","service":"google_assistant","entityId":"","data":"{\"message\":\"The temperature is currently {{entity.sensor.dark_sky_temperature}}. Please close the windows.\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":910,"y":280,"wires":[[]]},{"id":"ede8b68b.117128","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]

So the way I thought this would work is that I have a trigger state that determines if the temperature outside has risen above 70 degrees and sends out a default message. It then goes into a switch node that looks at my global variable (global.PresenceState) and moves the default message to an output if it’s true or false. It then goes into a timecheck node to only act if it’s within a certain time frame. And finally it spits out a message to my google home.

If I take out the global variable, it works fine. My question is how do I route a message based on the state of a global variable?

Looks ok to me, make sure the global context variable is actually a boolean, and not a string ‘true’ or ‘false’. If you look at the side panel in the context tab the variable value should be displayed in blue.

image

Thank you - I had no idea you could look at the global variable states - I found that when I was trying to put information into the global variable I was using a change node. I had used a “set” option, which was not working. Changing that setting to “move” did the trick, and now the other flow is working well.

Thanks for all of your help!