Hello ya’ll… I am pretty new to node red, have been using YAML for my automations up to this point… Been doing some pretty simple automations with NR for some doors (sensor opens, turn on pantry light, sensor closes, turn off light.) Trying to do something a little more complex now… Have a 4 in 1 sensor in my bathroom, and want to have it read light levels after dark before turning on the light, so as not to wake a sleeping person. Problem is, before dark, everything works fine, light turns on to 100%. After dark, the current state node for the lux sensor isn’t passing to the switch. Not sure how to paste the code here, so i guess this is a 2 part question
I’m trying to make sense of your question… but for your second question you can select your nodes and then do a export. Then just paste it here within back-ticks.
The light level reported by the sensor might not be the state but an attribute. Can you provide a view of what HA reports under developer->states for the sensor so we can see what value you need to be checking.
Here’s my code for the flow for the bathroom lights.
[{"id":"f1f437d2.05ddf8","type":"server-state-changed","z":"62f9c9b4.0ff128","name":"Bathroom Motion","server":"468bbf33.22b11","version":1,"entityidfilter":"sensor.vision_security_zp3111_multisensor_4in1_burglar","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"8","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":150,"y":520,"wires":[["e1ad9c2b.873ab"],["f94280ca.7d42"]]},{"id":"f94280ca.7d42","type":"stoptimer","z":"62f9c9b4.0ff128","duration":"15","units":"Minute","payloadtype":"num","payloadval":"0","name":"Wait 5 minutes of no motion to turn off","x":350,"y":720,"wires":[["2cff3801.d57a18"],[]]},{"id":"e1ad9c2b.873ab","type":"time-range-switch","z":"62f9c9b4.0ff128","name":"","lat":"36.117058","lon":"-115.281512","startTime":"06:30","endTime":"night","startOffset":0,"endOffset":0,"x":350,"y":500,"wires":[["ea1d650.60c5698"],["fd8d1024.e9879"]]},{"id":"2cff3801.d57a18","type":"api-call-service","z":"62f9c9b4.0ff128","name":"","server":"468bbf33.22b11","version":1,"service_domain":"light","service":"turn_off","entityId":"group.master_bathroom","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":690,"y":680,"wires":[[]]},{"id":"2693b06e.f5006","type":"switch","z":"62f9c9b4.0ff128","name":"","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"25","vt":"str"},{"t":"gte","v":"26","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":570,"y":580,"wires":[["ddfa4af7.a5a008"],["ea1d650.60c5698"]]},{"id":"ddfa4af7.a5a008","type":"api-call-service","z":"62f9c9b4.0ff128","name":"","server":"468bbf33.22b11","version":1,"service_domain":"light","service":"turn_on","entityId":"group.master_bathroom","data":"{ \"entity_id\": \"group.master_bathroom\", \"brightness_pct\": 5 }","dataType":"json","mergecontext":"brightness: 5","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":800,"y":580,"wires":[[]]},{"id":"ea1d650.60c5698","type":"api-call-service","z":"62f9c9b4.0ff128","name":"","server":"468bbf33.22b11","version":1,"service_domain":"light","service":"turn_on","entityId":"","data":"{ \"entity_id\": \"group.master_bathroom\", \"brightness_pct\": 100 }","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":700,"y":500,"wires":[[]]},{"id":"fd8d1024.e9879","type":"api-current-state","z":"62f9c9b4.0ff128","name":"light levels","server":"468bbf33.22b11","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.vision_security_zp3111_multisensor_4in1_luminance","state_type":"num","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":410,"y":620,"wires":[["2693b06e.f5006"]]},{"id":"468bbf33.22b11","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true}]
{{states.sensor.vision_security_zp3111_multisensor_4in1_luminance.state}}
outputs:
50.34