Motion light exception above a certain value

Hello i'm new here,

Don't know how paste an exported flow here, stil got to figure that out.

I have a motion light that go on and off by motion in the bathroom. But i don't want the light go of when i manualy set the dimmer above a certain brightness and ofcourse stay's there until i manualy set the light to off. can anyone help me with this?

[{"id":"f287086532e02894","type":"switch","z":"24aaf87c7c99fa4c","name":"","property":"data.attributes.brightness","propertyType":"msg","rules":[{"t":"lt","v":"\"brightness:80\"","vt":"jsonata"}],"checkall":"false","repair":false,"outputs":1,"x":570,"y":480,"wires":[["a4d3c3d3b90a95da"]]},{"id":"8e5fcf27c4299107","type":"debug","z":"24aaf87c7c99fa4c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1030,"y":260,"wires":[]},{"id":"73e51a50a45f664d","type":"inject","z":"24aaf87c7c99fa4c","name":"","props":[{"p":"payload"},{"p":"payload.brightness","v":"81","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"str","x":110,"y":400,"wires":[["d512bdd1adf4b32c"]]},{"id":"4688893d38f24c92","type":"api-call-service","z":"24aaf87c7c99fa4c","name":"","server":"9b99f28.437031","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.lampen_badkamer"],"data":"{\"brightness_pct\":33}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":850,"y":260,"wires":[["8e5fcf27c4299107"]]},{"id":"9da2ef218b8a8860","type":"api-call-service","z":"24aaf87c7c99fa4c","name":"","server":"9b99f28.437031","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.lampen_badkamer"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"brightness_pct","propertyType":"msg","value":"35","valueType":"str"}],"queue":"none","x":910,"y":400,"wires":[["8e5fcf27c4299107"]]},{"id":"bf61ce35077eeb7e","type":"server-state-changed","z":"24aaf87c7c99fa4c","name":"badkamer beweging","server":"9b99f28.437031","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.bewegingsmelder_badkamer_occupancy","entityidfiltertype":"substring","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":110,"y":460,"wires":[["c86f745b4d555a37"],["c86f745b4d555a37"]]},{"id":"b9a1ad2dcecf0e64","type":"inject","z":"24aaf87c7c99fa4c","name":"","props":[{"p":"payload"},{"p":"payload.brightness","v":"79","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"str","x":110,"y":360,"wires":[["d512bdd1adf4b32c"]]},{"id":"c86f745b4d555a37","type":"time-range-switch","z":"24aaf87c7c99fa4c","name":"","lat":"53.13405","lon":"6.56995","startTime":"22:00","endTime":"sunrise","startOffset":0,"endOffset":0,"x":280,"y":260,"wires":[["d512bdd1adf4b32c"],[]]},{"id":"d512bdd1adf4b32c","type":"api-current-state","z":"24aaf87c7c99fa4c","name":"","server":"9b99f28.437031","version":3,"outputs":2,"halt_if":"payload","halt_if_type":"msg","halt_if_compare":"is","entity_id":"light.lampen_badkamer","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":510,"y":360,"wires":[["ddb2e8c872f5e90d"],["f287086532e02894"]]},{"id":"a4d3c3d3b90a95da","type":"delay","z":"24aaf87c7c99fa4c","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":760,"y":460,"wires":[["9da2ef218b8a8860"]]},{"id":"ddb2e8c872f5e90d","type":"switch","z":"24aaf87c7c99fa4c","name":"","property":"data.attributes.brightness","propertyType":"msg","rules":[{"t":"lt","v":"80","vt":"num"}],"checkall":"false","repair":false,"outputs":1,"x":710,"y":300,"wires":[["4688893d38f24c92"]]},{"id":"9b99f28.437031","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":true,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"}]

Easiest way - do a check of the dimmer level (what are you using for dimming - a shelley or similar) run this check every 1s

If Dimmer > x percentage - set a context variable to something like DimmerControl=Yes
If Dimmer < x percentage then DimmerControl=No

In your motion routine check using a switch node if the DimmerControl=Yes and do not turn off based on lack of motion

Edit - just had a look and saw that you are using HA and the associated nodes

What dimmer States are available and reported in HA ? Go to the Developer console and then States at the top of the screen and find your dimmer module and see what it reports - you maybe able to use that with a switch node instead of having to poll every second

Craig

OK just stepped through the nodes and Google translate !

Looks like you are doing the followng

  1. Checking for motion
  2. If there is motion then check if the time falls within a certain range (i do not use that time node)
  3. Check the Current state of the light - this is where i can not understand what you are then doing - you compare the state to the message.payload ? Why ? Are you just trying for the edge case that they have manually left the light turned on ?
  4. If the light is on you then test for the dimmer % so which part is breaking down ?

Usually when you post something like this up it is a good idea to put in more debug nodes and to set them to the whole message object (and give them a meaningful name) - you can then post screen shots to show what the flow is seeing as it progresses

Craig

Hello, i pasted an print screen.

It's checking for motion within a certain time range and then turns the light on with motion, off with no motion.

But it's in the bathroom and i have an smart dimmer switch. My goal is that the light stays on when i manualy dim the light above a certain brightness and stay there until i manualy set it off.

I'm new to node red and don't understand how set it al up. How to fill in al the fields. you are saying not to use message.payload?

How can i set it up the right way?

I need to see the screen shots from the debug nodes as this runs to see what each node is outputting - for instance i have no idea what states are available for the dimmer or what states your motion detector produces

Craig

I made a screen shot of what i'm getting. I seem to do something wrong, but don't know what.

My home assistant instance gives me this states:
image

And brightness is 0 to 255.

It would realy help met understand node red if i could find a good site to learn and understand about how to use node red. Any tips?

Yep there are a series of videos from the creators of node red here

Craig

1 Like

Once you watch those videos then watch this to do with HA and Node Red and some of it addresses what you want to do

Craig

1 Like

In your 2 inject nodes, (true and false) you have set:
payload.brightness.
And in your 2 switch nodes, you have set:
data.attributes.brightness.
Maybe data.attributes.brightness should be set
in instead of payload.brightness.

In the upper switch you test for < 80 (number).
In the bottom switch you test for < "brightness:80" (J: expression)

yes it looks a bit messy, i'm trying different thing. cause is just don't know what to fill in. but i'm taking a look in the youtube video now. maybe it can help me learning things with node red.