How to send "False" when there is no Flow?

Hello,

I would be happy if someone can help me solve my problem.

An "mqtt-in" receives every five seconds the signal strength of my Bluetooth device. If the "MQTT broker" sends "-67", for example, the "switch-node" forwards "is not null" and then to the "change node" which then sends a "TRUE". That works and is fine. :slight_smile:

But if my "Bluetooth Device" is not in the house, the "MQTT Broker" does not send any signal strength, there is no Flow, but the "change node" should send "FALSE"! But he doesn't send anything! :frowning:

I configured the "switch-node" to "otherwise" but it doesn't work. Can someone tell me how to configure the node so that I get a "False" if the "MQTT broker" does not send any signal strength for the "Bluetooth device"?

thank you and have a nice evening

[{"id":"c54c5caf.992f5","type":"inject","z":"e3fd25d8.62b308","name":"Payload from MQTT","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"-67","payloadType":"num","x":390,"y":340,"wires":[["defb83f0.b6d85"]]},{"id":"defb83f0.b6d85","type":"switch","z":"e3fd25d8.62b308","name":"","property":"payload","propertyType":"msg","rules":[{"t":"nnull"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":630,"y":360,"wires":[["169a1a1b.44f736"],["d71c683f.240f58"]]},{"id":"169a1a1b.44f736","type":"change","z":"e3fd25d8.62b308","name":"change to TRUE","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":280,"wires":[[]]},{"id":"d71c683f.240f58","type":"change","z":"e3fd25d8.62b308","name":"change to FALSE","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":460,"wires":[[]]}]

Connect a debug node showing what comes out of the MQTT node for the two cases.

I would probably check if value is true or false with JSONata expression. To send false if no message sent use a trigger node as in example below.

[{"id":"4ceecb5f.1df26c","type":"inject","z":"8d22ae29.7df6d","name":"Payload from MQTT","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"-67","payloadType":"num","x":150,"y":2760,"wires":[["5985cfb8.7d627","a0930bf2.00e26"]]},{"id":"5985cfb8.7d627","type":"trigger","z":"8d22ae29.7df6d","name":"","op1":"","op2":"false","op1type":"nul","op2type":"bool","duration":"10","extend":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":270,"y":2820,"wires":[["a0930bf2.00e26"]]},{"id":"a0930bf2.00e26","type":"change","z":"8d22ae29.7df6d","name":" TRUE or FALSE","rules":[{"t":"set","p":"payload","pt":"msg","to":"$boolean(payload) ","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":2760,"wires":[["849076c.5742d08"]]},{"id":"849076c.5742d08","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":680,"y":2760,"wires":[]}]

True. Kind of. Flow still exist but there is no events to move any data. And the change node is not meant to understand or do any triggering kind of action.

What you'll need is to listen the input and if there will be silence for some period, fire an event which contains data to indicate that silence period is now longer than it should.

Most easyest way is to use the trigger node

image

So in every input the trigger node does nothing and every next action resets the delay but if next input takes too long it fires the "then send" action and with your following flow you can then do what ever needed to be done if your primary flow has no triggering action anymore.

And don’t forget you can set the broker to automatically send an LWT message if a device disconnects by setting it correctly on connect.

I did that. If the special Bluetooth device is not in the house, MQTT of course also sends the MAC address and signal strength of the other Bluetooth devices ...

{"topic":"ergebnis","payload":{"39:51:fc:ea:bd:0a":-75,"44:b2:45:5a:f4:57":-65,.....}

Thanks for your help, but @E1cid and @hotNipi solved my problem very well.

Thank you, your example was perfect! I was able to adjust everything for myself and it works great! :slight_smile:

I didn't know the "trigger node" before! But thanks to you and @ E1cid it works for me too.:slight_smile:

LWT would not work because there is still an MQTT connection ...
But thanks for your hint.

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