Switch a light via a motion detector

Hello to you.

I would like to switch a light via a motion detector. I have already done that with Node-Red.

BUT:
I want that the light is switched only if it was not already switched on by me manually.

That means:
Version A

  1. motion detected
  2. test: light is off
  3. light is switched on (red, brightness: 1%)

Version B

  1. movement detected
  2. test: light is on
  3. light is not switched on (red, brightness: 1%) but remains on manual setting

Is there a solution for this??

There is.
after the node with the PIR sensor fires, then put a current state node in with the entity of your light and the “If State” field set to string (az) and value on.
You will now have two exist points one for on and one for off.

Now the question is more with the automatically turning the light off, since you might want to turn it off, if it was turned on by the PIR, but maybe not turn it off automatically, if it was turned on manually.
In that case you can use the current state entity without a state field set and you will get the entire state and attribute settings, where you can make a comparison on values, so you can see if it is the values you set automatically or it is some other values. This assume manually and automatically set different values.
If they do not, then you need to set a helper_boolean up in HA to control when it is set manually.

Many thanks to you.
Turn on:
I had already thought of the first step. And it works.

Switch off:
I don’t understand the second step yet.
I attach the picture.

I suggest you make an input boolean in HA to keep the state of the manual/automatic light control.

Now when you do a manual turn on then set this boolean value to true/on and then you can test on that to see if you should turn off the light manually or automatic.

Thank you very much. Unfortunately, I am a beginner and do not quite understand.
I had another idea, I still have to tinker a bit.

An input_boolean makes a virtual switch in HA that you can switch on and off when you need it.
The idea was to make this switch show if the light was turned on manually (on) or automatically (off).

You already use call current state nodes and call service nodes, so you already have the skills to use this switch.