Alarm System with ON/OFF switch

Hi, I want to create an alarm system in node red. I have a Xiaomi Door Sensor which is already implemented in iobroker.
The iobroker node sends a message to the Telegram node when the sensor is open, which is already working.
Now i want to add a switch, where I can toggle on and off the alarm system. So if the switch is off and sensor is open no message should be send to telegram, only when the switch is on.

Many Thanks for helping

Take a look at the context examples in the cookbook

https://cookbook.nodered.org/basic/route-on-context

Hi, i tried to adapt the flow based on the cookbook example. Thanks for the hint.

But I cannot get on there.

If I click on close or open on the incjet node, there only should be an output,
if Alarm ist set to ON (armed). If Alarm is set to OFF there should be no output. (disarmed)

I don't know how to implement the additional code.

Many Thanks for your help.

flow.json (2.2 KB)

I’m on my phone so can’t look at your flow.

But basically you set the context value in the manual flow (eg alarm_set = “On”)

Then in the switch in your Door sensor flow,
have a switch that only allow messages through if alarm_set is “On”

hmmm, i don't know exactly what you mean, maybe you can show me later in the flow?

thx

Play with the example in the cookbook it’s exactly what it does

Hi, i tried many things to get this running, but unfortunately i failed.

Maybee any suggestions, this would be great.

Thank you

The flow as shown works as I expect.

I am missing what you mean when you say:

That is what happens, or what I see.

Ok, rethinking it.
You are a bit confused I think.

If you only want to see messages when the alarm is activated, then you already have that. It is just you don't need to see/have the other debug node.

(By the way the alarm ON node has a blue dot. I'm guessing that is because you activated it's output?)

Deactivate the Alarm OFF node and just ignore it.

You get an output in the Alarm ON node if the alarm is active.

What else do you want?

Hi,

ah , ok now I got it. I had an error in reasoning.

thanks all for the feedback.