Node Red Motion Lights - Answered

Hoping someone can point me in the right direction. I have an input boolean that i use to turn on/off motion automations. If it is on, and motion is detected, and another time of day boolean is set to day, the lights should turn on to 100%. If the time of day is not day, the lights shold turn on at 10%. Either way, after 5 minutes of no motion the lights should turn off. If someone turned off the motion automations boolean, and there is no motion for 30 minutes, the lights should be turned off if they are on, and the motion automation boolean should be set back to on, that way motion automation resume. Can someone suggest how I might accomplish this?

this should get you started

https://zachowj.github.io/node-red-contrib-home-assistant-websocket/cookbook/motion-triggered-light.html

This takes care of if.

[{"id":"70eea8ce83affd3e","type":"comment","z":"2f95c855cb2cd6a6","name":"Master Bed Room","info":"","x":150,"y":1560,"wires":[]},{"id":"986ccd2303bfbe63","type":"server-state-changed","z":"2f95c855cb2cd6a6","name":"Motion","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.master_bedroom_motion_ias_zone","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"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":130,"y":1700,"wires":[["39bf21add42a82fd"]]},{"id":"39bf21add42a82fd","type":"change","z":"2f95c855cb2cd6a6","name":"Get input_boolean state and set delays in ms","rules":[{"t":"set","p":"delay","pt":"msg","to":"$globalContext(\"homeassistant.homeAssistant.states['input_boolean.master_bedroom_automation'].state\")","tot":"jsonata"},{"t":"change","p":"delay","pt":"msg","from":"on","fromt":"str","to":"300000","tot":"num"},{"t":"change","p":"delay","pt":"msg","from":"off","fromt":"str","to":"1800000","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":215,"y":1700,"wires":[["5956189ce3cd99e7"]],"l":false},{"id":"a7940be7089141fa","type":"trigger","z":"2f95c855cb2cd6a6","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"250","extend":false,"overrideDelay":true,"units":"ms","reset":"on","bytopic":"all","topic":"topic","outputs":1,"x":535,"y":1760,"wires":[["4903c6e6dd1cbc8e"]],"l":false},{"id":"5956189ce3cd99e7","type":"switch","z":"2f95c855cb2cd6a6","name":"Automation on or off?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":360,"y":1700,"wires":[["a7940be7089141fa","2864ca1365a740d0","3cad76e79ebce598"],["a7940be7089141fa"]]},{"id":"4903c6e6dd1cbc8e","type":"api-call-service","z":"2f95c855cb2cd6a6","name":"Light off","server":"bb06732d.30845","version":3,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.master_bedroom_light","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":640,"y":1760,"wires":[["88aa0e11a98a8538"]]},{"id":"88aa0e11a98a8538","type":"api-current-state","z":"2f95c855cb2cd6a6","name":"Input off?","server":"9405c3fe.d0a6c","version":2,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.master_bedroom_automation","state_type":"str","blockInputOverrides":true,"outputProperties":[],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":880,"y":1760,"wires":[["752672f03e67a426"],[]]},{"id":"752672f03e67a426","type":"api-call-service","z":"2f95c855cb2cd6a6","name":"Input on","server":"9405c3fe.d0a6c","version":3,"debugenabled":false,"service_domain":"homeassistant","service":"turn_on","entityId":"input_boolean.master_bedroom_automation","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1030,"y":1760,"wires":[[]]},{"id":"2864ca1365a740d0","type":"api-current-state","z":"2f95c855cb2cd6a6","name":"Day?","server":"9405c3fe.d0a6c","version":2,"outputs":2,"halt_if":"Day","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.time_of_day","state_type":"str","blockInputOverrides":false,"outputProperties":[],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":570,"y":1620,"wires":[["53f6e6b45f8d9595"],[]]},{"id":"53f6e6b45f8d9595","type":"api-call-service","z":"2f95c855cb2cd6a6","name":"Light 100%","server":"bb06732d.30845","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.master_bedroom_light","data":"{\"brightness_pct\": \"100\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":770,"y":1600,"wires":[[]]},{"id":"fe264a3186a94cf0","type":"api-call-service","z":"2f95c855cb2cd6a6","name":"Light 20%","server":"bb06732d.30845","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.master_bedroom_light","data":"{\"brightness_pct\": \"20\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":770,"y":1680,"wires":[[]]},{"id":"3cad76e79ebce598","type":"api-current-state","z":"2f95c855cb2cd6a6","name":"Evening?","server":"9405c3fe.d0a6c","version":2,"outputs":2,"halt_if":"Evening","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.time_of_day","state_type":"str","blockInputOverrides":false,"outputProperties":[],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":580,"y":1680,"wires":[["fe264a3186a94cf0"],[]]},{"id":"9405c3fe.d0a6c","type":"server","name":"Home Assistant Real","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"bb06732d.30845","type":"server","name":"Home Assistant","version":1,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true}]```