How to use the output of a door - window sensor [SOLVED]

I am a total newbie with H.A. and Node red and need some help on using the status of several door and window sensors.
What I want to achieve is that if a sensor reports to be open, an action takes place (f.e. a light switches on) and when it closes the same light switches off.
Should be very easy but I can’t make it work.

If I put a debug on the sensor (2 different types) I get the following results:


I guess that I should use a switch to make 2 different outputs but I don’t understand what criteria I should use as an input.

Debug on the output of the switch shows no output at all.
To be complete 2 pictures of the properties of the sensors:


Anybody can help me to make this come true?

Preferably a simple explanation which tells me what I do wrong and why.

Thank you all.

(forgive my English, I am Dutch)

You have to make an “Automation” using the sensor (/ Settings /Automations)

i.e
If sensor.door.entity == to:on … Action: turn on light(light.switch.entity)

Door/window sensors usually only have the 2 states on/off

EDIT:
Trigger = state “to on” entity (your door/window switch-sensor)
Action = call_service ( switch_turn-on ) Target: (your light-switch-entity)

Boheme61

Thanks for your quick response.

For the sensor terras it worked well with a switch behind it
For the sensor “gate” I don’t manage.
these are the possible settings for the sensor:

No possibility to choose “State Closed”
Next picture is the settings of the switch plus the debug of the sensor.
No debug results at the output of the switch
Am I missing something?

try use Trigger = Device … device = gate-sensor
And it’s the actual reported “State” you use, in this case true/false

PS: true/false might be an Attribute thou, in this case … i don’t know that Device , you better check in Developer Tools /State, … Don’t post pics from NodeRed, when you don’t seems to have issues with NodeRed
Maybe you can change the payload in NR, i don’t know nothing about NR

Did you see a “State Open” ? , if so you might need an “condition” if -State Open = true/false

Thank you again for your help with this problem
With your suggestions I managed to make it work.
The trick was indeed in the true/false department, when I changed the “payload” of the sensor to “state open false” a switch with this values made it work.

FYI itis a very cheap Aubess Zigbee sensor of less than € 5.00 at Ali.
Reason I choose it is that it will be outside (gate you can guess) so if it stops working I can replace it cheap.

Thanks again for your help and sorry for posting pictures, I thought that this group is for problems with using Node Red not realizing it is for problems with Node Red itself.

But despite my mistake the problem is solved and that is what this forum is about!

1 Like

ok, i assumed it was an Automation in HA you needed :slight_smile: