Problem with current state

Btw, this behavior is what I also observe for the hue motion sensors. Took me a while to find that out.

yeah, indeed, without the occupied message repeating, the light would turn off after 2 minutes

Nevertheless, I solved that a bit differently. Still based on the trigger node. Will show you my solution later when again being at home (in a few hours).

But the occupied message will only be repeated if there is a break in moving. The "stop detecting occupied" message will appear first, then the occupied message will repeat. If the movement is continuous without breaking, the message will not be repeated.

I would not rely on there being no repeated 'occupied' messages, or indeed repeated 'unnocupied' messages. Your flow should cope with that.

1 Like

Certainly. I just wanted to say that the flow by deputynl will not work correctly. Does anyone know a working solution?

Can you explain again what you are trying to achieve, I have lost track of this along the way.

Also remind me what the incoming payload looks like and what output you want for On and Off.

There is a motion sensor and a lamp. Normally, the motion sensor turns off the lamp after 1 min without detecting motion. I just want to increase this period.

And the payload values?

payload values ​​from motion sensor i can do anything

The trick is firstly to use a Switch node to separate motion start and stop. Pass the start message on directly to switch the light on, send the Off message to a Trigger node that waits for the time required and then switches the light off. To stop the light being turned off if the motion starts again before the trigger has timed out, also feed the start message to the trigger, but configure the 'Reset Trigger If' option in the Trigger node to reset if the payload is equal to the start motion payload, so that it resets the trigger and it does not send the light off command. I have set the trigger to 10 seconds in the demo flow to make it easier to test.

[{"id":"1511d45dd7baee43","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":110,"y":1260,"wires":[["d09f74b5913ecad9"]]},{"id":"583a7755e99f5859","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":110,"y":1320,"wires":[["d09f74b5913ecad9"]]},{"id":"dded18b24cc7b073","type":"change","z":"bdd7be38.d3b55","name":"Lamp on","rules":[{"t":"set","p":"payload","pt":"msg","to":"On","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1280,"wires":[["8899f8e7fdb89ad6"]]},{"id":"d09f74b5913ecad9","type":"switch","z":"bdd7be38.d3b55","name":"Occupied?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":270,"y":1300,"wires":[["86113191cf89969d","dded18b24cc7b073"],["86113191cf89969d"]]},{"id":"86113191cf89969d","type":"trigger","z":"bdd7be38.d3b55","name":"","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"1","bytopic":"all","topic":"topic","outputs":1,"x":470,"y":1320,"wires":[["7bdb253098f142aa"]]},{"id":"7bdb253098f142aa","type":"change","z":"bdd7be38.d3b55","name":"Lamp off","rules":[{"t":"set","p":"payload","pt":"msg","to":"Off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1320,"wires":[["8899f8e7fdb89ad6"]]},{"id":"8899f8e7fdb89ad6","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":830,"y":1300,"wires":[]}]

Is it normal that the command to turn on the lamp will come every time, even if the lamp is already on?
And it seems that the switch node is not needed here. Messages can be received directly from timestamp 1 and 2.

The flow will do that. It shouldn't matter, but if it bothers you put a Filter node in the output to stop the repeats

If you haven't got the Switch then a motion end message when motion has not started will switch the light on.


You have removed the wire from the bottom inject to the change node

This is exactly how I realized it with my Hue Motion Sensors

Leopoll, of course you are right if considering this simple example. However, the occupied/not occupied message usually comes from one and the same node. Therefore, a switch node is required.

I am using the library "node-red-contrib-home-assistant-websocket" because the server based on Home Assistant. This library has a device node. This node specifies a trigger, so you get two different nodes for occupied/not occupied.

1 Like

In that case then yes, you don't need the switch as that is effectively included in the HA nodes.

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