Motion Sensor Bug - how to solve

Hi there,

I use node red at my home assistant.
This is my current flow:

[{"id":"af7416ee.37c178","type":"tab","label":"Deckenlampe Flur","disabled":false,"info":""},{"id":"973114867756a562","type":"switch","z":"af7416ee.37c178","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":260,"wires":[["bf52dbcb745d6dd0"],["bcd0fd015afa5557","f3ee92165a0a5b36"]]},{"id":"34879843e54e2e97","type":"api-call-service","z":"af7416ee.37c178","name":"Tag 100%","server":"818794df.29c548","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"","data":"{\t   \"entity_id\": \"light.deckenlampe_flur\",\t   \"brightness_pct\": 100\t}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1420,"y":100,"wires":[["bcd0fd015afa5557","f3ee92165a0a5b36"]]},{"id":"669e14131ca9294b","type":"trigger-state","z":"af7416ee.37c178","name":"","server":"818794df.29c548","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"binary_sensor.flur_bewegungsmeldung_occupancy","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"bool","comparatorValue":"true","propertyValue":"new_state.state"},{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"bool","comparatorValue":"false","propertyValue":"new_state.state"}],"inputs":1,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"habool","enableInput":true,"x":290,"y":260,"wires":[["973114867756a562"],["973114867756a562"]]},{"id":"bf52dbcb745d6dd0","type":"time-range-switch","z":"af7416ee.37c178","name":"Tag 5:30-22:00","lat":"50.11092","lon":"8.68213","startTime":"5:30","endTime":"22:00","startOffset":0,"endOffset":0,"x":1120,"y":140,"wires":[["6db1b2fb28cec70d"],["f34ae9890e2488d0"]]},{"id":"2d6d31857865b99f","type":"api-call-service","z":"af7416ee.37c178","name":"Nacht 30%","server":"818794df.29c548","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"","data":"{\t   \"entity_id\": \"light.deckenlampe_flur\",\t   \"brightness_pct\": 30\t}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1710,"y":200,"wires":[["bcd0fd015afa5557","f3ee92165a0a5b36"]]},{"id":"6db1b2fb28cec70d","type":"api-current-state","z":"af7416ee.37c178","name":"< 30 lx","server":"818794df.29c548","version":2,"outputs":2,"halt_if":"30","halt_if_type":"num","halt_if_compare":"lte","entity_id":"sensor.flur_bewegungsmeldung_illuminance","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1290,"y":120,"wires":[["34879843e54e2e97"],[]]},{"id":"f34ae9890e2488d0","type":"time-range-switch","z":"af7416ee.37c178","name":"Nacht 22:00-23:00","lat":"","lon":"","startTime":"22:00","endTime":"23:00","startOffset":0,"endOffset":0,"x":1370,"y":240,"wires":[["2d6d31857865b99f"],["820a1a31516b2f7d"]]},{"id":"e57280f09f8f90c9","type":"api-call-service","z":"af7416ee.37c178","name":"Nacht 10%","server":"818794df.29c548","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"","data":"{\t   \"entity_id\": \"light.deckenlampe_flur\",\t   \"brightness_pct\": 10\t}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1710,"y":300,"wires":[["bcd0fd015afa5557","f3ee92165a0a5b36"]]},{"id":"297d51b5077d171c","type":"time-range-switch","z":"af7416ee.37c178","name":"Tag 5:30-22:00","lat":"","lon":"","startTime":"5:30","endTime":"22:00","startOffset":0,"endOffset":0,"x":400,"y":500,"wires":[["7f7c3ec279475b35"],["1628aa0897b1860a"]]},{"id":"1628aa0897b1860a","type":"time-range-switch","z":"af7416ee.37c178","name":"Nacht 22:00-23:00","lat":"","lon":"","startTime":"22:00","endTime":"23:00","startOffset":0,"endOffset":0,"x":610,"y":500,"wires":[["9c47284691d735a3"],["f47eec82f5e7475f"]]},{"id":"863098b73f51e85e","type":"server-state-changed","z":"af7416ee.37c178","name":"Deckenlampe Schlafzimmer","server":"818794df.29c548","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.deckenlampe_schlafzimmer","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":180,"y":500,"wires":[["297d51b5077d171c"],[]]},{"id":"f47eec82f5e7475f","type":"api-call-service","z":"af7416ee.37c178","name":"Nacht 10%","server":"818794df.29c548","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"","data":"{\t   \"entity_id\": \"light.deckenlampe_schlafzimmer\",\t   \"brightness_pct\": 10\t}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":810,"y":540,"wires":[[]]},{"id":"9c47284691d735a3","type":"api-call-service","z":"af7416ee.37c178","name":"Nacht 30%","server":"818794df.29c548","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"","data":"{\t   \"entity_id\": \"light.deckenlampe_schlafzimmer\",\t   \"brightness_pct\": 30\t}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":810,"y":480,"wires":[[]]},{"id":"7f7c3ec279475b35","type":"api-call-service","z":"af7416ee.37c178","name":"Tag 100%","server":"818794df.29c548","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"","data":"{\t   \"entity_id\": \"light.deckenlampe_schlafzimmer\",\t   \"brightness_pct\": 100\t}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":560,"y":440,"wires":[[]]},{"id":"820a1a31516b2f7d","type":"api-current-state","z":"af7416ee.37c178","name":"< 30 lx","server":"818794df.29c548","version":2,"outputs":2,"halt_if":"30","halt_if_type":"num","halt_if_compare":"lte","entity_id":"sensor.flur_bewegungsmeldung_illuminance","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1570,"y":280,"wires":[["e57280f09f8f90c9"],[]]},{"id":"bcd0fd015afa5557","type":"api-current-state","z":"af7416ee.37c178","d":true,"name":"","server":"32e60e8e.d121f2","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.flur_beleuchtung_pause","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"x":1120,"y":320,"wires":[["df1b3d400e375aba"],["f3ee92165a0a5b36"]]},{"id":"df1b3d400e375aba","type":"api-call-service","z":"af7416ee.37c178","name":"","server":"32e60e8e.d121f2","version":3,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.flur_beleuchtung_pause","data":"","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1600,"y":360,"wires":[[]]},{"id":"f3ee92165a0a5b36","type":"trigger","z":"af7416ee.37c178","name":"","op1":"","op2":"off","op1type":"nul","op2type":"str","duration":"1","extend":true,"overrideDelay":false,"units":"min","reset":"true","bytopic":"all","topic":"topic","outputs":1,"x":1550,"y":420,"wires":[["9d0321800f18252e"]]},{"id":"9d0321800f18252e","type":"api-call-service","z":"af7416ee.37c178","name":"","server":"818794df.29c548","version":3,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.deckenlampe_flur","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1750,"y":420,"wires":[[]]},{"id":"d64a386e60b2fb73","type":"server-state-changed","z":"af7416ee.37c178","name":"Deckenlampe Flur","server":"818794df.29c548","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.deckenlampe_flur","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":320,"wires":[["67e152a12832f65f"],[]]},{"id":"67e152a12832f65f","type":"trigger","z":"af7416ee.37c178","name":"","op1":"","op2":"1","op1type":"nul","op2type":"str","duration":"5","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":450,"y":320,"wires":[["973114867756a562"]]},{"id":"818794df.29c548","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30},{"id":"32e60e8e.d121f2","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

I have the problem, that the sensor not always detect motion.
Or sometimes the light turns on and 5 sec later it turns off.

The motion sensor is a philips hue motion sensor and the light is controlled by a shelly dimmer 2.

Can anybody find the bug in my flow?

Regards
Timo

Nobody any idea, what could be the problem with the detection?
happy x-mas :slight_smile:

Looking at your flow i see it is a lot of HA nodes. Most here don't use HA so it will be hard to debug. If I was you I would post the question on the HA forum they have a node-red section.

1 Like

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