Motion sensor automation with PC as condition

Hello friends,

I am a fairly new user of HA and Node-Red. I have set up this motion based flow to turn on my lights when there is motion, then turn them off ONLY if my computer is turned off.

I was wondering if anyone has a better way in which I could do this? My flow seems quite cluttered. I tried experimenting with the trigger-state node but could not get this to work in the same way (i.e. if the PC was turned off first, then the motion sensor stopped detecting motion, the light would remain on.)

Any advice would be greatly appreciated.

image

[{"id":"60e26264.66f44c","type":"server-state-changed","z":"472c4da9.cd6cd4","name":"Motion detected","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.motion","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","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":[],"x":192,"y":544,"wires":[["b5f43e82.0a426"],[]]},{"id":"b5f43e82.0a426","type":"api-call-service","z":"472c4da9.cd6cd4","name":"light and strip","server":"","version":3,"debugenabled":false,"service_domain":"homeassistant","service":"turn_on","entityId":"switch.strip, light.light","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":390,"y":544,"wires":[[]]},{"id":"c81f3773.d64da8","type":"server-state-changed","z":"472c4da9.cd6cd4","name":"PC off","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.pc","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","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":"{\"service\": \"turn_off\"}","valueType":"jsonata"}],"x":162,"y":592,"wires":[["b5f43e82.0a426"],[]]}]
1 Like

Depending on how your motion sensor reports, the delay node may/may not be needed. If the motion sensor reports off, the second that motion stops or a few seconds there after, It may shut the light before the pc is turned on.

The delay would be the amount of time you might sit still before the power state of the pc is reported back to HA.

[{"id":"60e26264.66f44c","type":"server-state-changed","z":"d6a46901.ebee1","name":"Motion detected","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.motion","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","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":[],"x":1280,"y":320,"wires":[["b998bbf7.be7988","387179d.d043986"],["1571f48e.7ba40b"]]},{"id":"b5f43e82.0a426","type":"api-call-service","z":"d6a46901.ebee1","name":"strip","server":"","version":3,"debugenabled":false,"service_domain":"homeassistant","service":"turn_on","entityId":"switch.strip","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1830,"y":320,"wires":[[]]},{"id":"b998bbf7.be7988","type":"api-current-state","z":"d6a46901.ebee1","name":"","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.light","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":1610,"y":320,"wires":[[],["b5f43e82.0a426"]]},{"id":"387179d.d043986","type":"api-current-state","z":"d6a46901.ebee1","name":"","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.strip","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":1610,"y":380,"wires":[[],["bd622e81.09c1d"]]},{"id":"bd622e81.09c1d","type":"api-call-service","z":"d6a46901.ebee1","name":"light","server":"","version":3,"debugenabled":false,"service_domain":"homeassistant","service":"turn_on","entityId":" light.light","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1830,"y":380,"wires":[[]]},{"id":"42d4f9cc.f259f8","type":"api-current-state","z":"d6a46901.ebee1","name":"pc on?","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"switch.pc","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":1610,"y":460,"wires":[[],["fc91d3b2.131e2"]]},{"id":"fc91d3b2.131e2","type":"api-call-service","z":"d6a46901.ebee1","name":"ligth strip off","server":"","version":3,"debugenabled":false,"service_domain":"homeassistant","service":"turn_off","entityId":"switch.strip, light.light","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1810,"y":460,"wires":[[]]},{"id":"1571f48e.7ba40b","type":"delay","z":"d6a46901.ebee1","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1440,"y":460,"wires":[["42d4f9cc.f259f8"]]}]

1 Like

Thank you Kermit and Mikefila

What I’d also like to be able to do is have the PC turning off act as a trigger for the lights to turn off but only if there is no motion.

For example, if I walk out of the room (motion off) and the computer is taking a few minutes to shut down (e.g. Windows updates installing), once it shuts down I’d like this to check again if there is motion, and if none, turn off the lights - hence why I used the wait-until node above.

I’ve tried something like this with a trigger state, but can’t get it to work - if the PC is shut down while motion is still active, the lights will stay on (correctly), but once motion is no longer detected I would expect the trigger state to trigger again (it doesn’t). Unless I am misunderstanding how the trigger state node is supposed to work?

When the pc is on, off commands to the light will be held. When the pc goes off it will release the off hold and send the last message that it has stored.

[{"id":"60e26264.66f44c","type":"server-state-changed","z":"d6a46901.ebee1","name":"Motion detected","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.motion","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","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":[],"x":1260,"y":340,"wires":[["b998bbf7.be7988","387179d.d043986"],["659de05c.04ea6"]]},{"id":"b5f43e82.0a426","type":"api-call-service","z":"d6a46901.ebee1","name":"strip","server":"","version":3,"debugenabled":false,"service_domain":"homeassistant","service":"turn_on","entityId":"switch.strip","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1830,"y":340,"wires":[[]]},{"id":"b998bbf7.be7988","type":"api-current-state","z":"d6a46901.ebee1","name":"","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.light","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":1610,"y":340,"wires":[[],["b5f43e82.0a426"]]},{"id":"387179d.d043986","type":"api-current-state","z":"d6a46901.ebee1","name":"","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.strip","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":1610,"y":400,"wires":[[],["bd622e81.09c1d"]]},{"id":"bd622e81.09c1d","type":"api-call-service","z":"d6a46901.ebee1","name":"light","server":"","version":3,"debugenabled":false,"service_domain":"homeassistant","service":"turn_on","entityId":" light.light","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1830,"y":400,"wires":[[]]},{"id":"fc91d3b2.131e2","type":"api-call-service","z":"d6a46901.ebee1","name":"ligth strip off","server":"","version":3,"debugenabled":false,"service_domain":"homeassistant","service":"turn_off","entityId":"switch.strip, light.light","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1810,"y":480,"wires":[[]]},{"id":"1c62628b.333aad","type":"server-state-changed","z":"d6a46901.ebee1","name":"pc on/off","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","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":1200,"y":440,"wires":[["3a230195.853f06"],["7e8e196b.ef53b8"]]},{"id":"659de05c.04ea6","type":"traffic","z":"d6a46901.ebee1","name":"hold/release","property_allow":"payload","filter_allow":"release","ignore_case_allow":false,"negate_allow":false,"send_allow":false,"property_stop":"payload","filter_stop":"hold","ignore_case_stop":false,"negate_stop":false,"send_stop":false,"default_start":true,"differ":true,"x":1630,"y":480,"wires":[["fc91d3b2.131e2"]]},{"id":"3a230195.853f06","type":"change","z":"d6a46901.ebee1","name":"hold on","rules":[{"t":"set","p":"payload","pt":"msg","to":"hold","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1380,"y":440,"wires":[["659de05c.04ea6"]]},{"id":"7e8e196b.ef53b8","type":"change","z":"d6a46901.ebee1","name":"release off","rules":[{"t":"set","p":"payload","pt":"msg","to":"release","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1410,"y":500,"wires":[["659de05c.04ea6"]]}]

On second thought you’ll also need a timer for continued motion after the pc. each motion event will delay the off command by 15 seconds.

[{"id":"60e26264.66f44c","type":"server-state-changed","z":"d6a46901.ebee1","name":"Motion detected","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.motion","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","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":[],"x":1240,"y":340,"wires":[["b998bbf7.be7988","387179d.d043986","7c068811.477028"],["659de05c.04ea6"]]},{"id":"b5f43e82.0a426","type":"api-call-service","z":"d6a46901.ebee1","name":"strip","server":"","version":3,"debugenabled":false,"service_domain":"homeassistant","service":"turn_on","entityId":"switch.strip","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1830,"y":340,"wires":[[]]},{"id":"b998bbf7.be7988","type":"api-current-state","z":"d6a46901.ebee1","name":"","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.light","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":1610,"y":340,"wires":[[],["b5f43e82.0a426"]]},{"id":"387179d.d043986","type":"api-current-state","z":"d6a46901.ebee1","name":"","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.strip","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":1610,"y":400,"wires":[[],["bd622e81.09c1d"]]},{"id":"bd622e81.09c1d","type":"api-call-service","z":"d6a46901.ebee1","name":"light","server":"","version":3,"debugenabled":false,"service_domain":"homeassistant","service":"turn_on","entityId":" light.light","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1830,"y":400,"wires":[[]]},{"id":"fc91d3b2.131e2","type":"api-call-service","z":"d6a46901.ebee1","name":"ligth strip off","server":"","version":3,"debugenabled":false,"service_domain":"homeassistant","service":"turn_off","entityId":"switch.strip, light.light","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1870,"y":540,"wires":[[]]},{"id":"1c62628b.333aad","type":"server-state-changed","z":"d6a46901.ebee1","name":"pc on/off","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","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":1080,"y":460,"wires":[["3a230195.853f06"],["7e8e196b.ef53b8"]]},{"id":"659de05c.04ea6","type":"traffic","z":"d6a46901.ebee1","name":"hold/release","property_allow":"payload","filter_allow":"release","ignore_case_allow":false,"negate_allow":false,"send_allow":false,"property_stop":"payload","filter_stop":"hold","ignore_case_stop":false,"negate_stop":false,"send_stop":false,"default_start":true,"differ":true,"x":1510,"y":540,"wires":[["4cd06a36.13ca84"]]},{"id":"3a230195.853f06","type":"change","z":"d6a46901.ebee1","name":"hold on","rules":[{"t":"set","p":"payload","pt":"msg","to":"hold","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":460,"wires":[["659de05c.04ea6"]]},{"id":"7e8e196b.ef53b8","type":"change","z":"d6a46901.ebee1","name":"release off","rules":[{"t":"set","p":"payload","pt":"msg","to":"release","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1290,"y":540,"wires":[["659de05c.04ea6"]]},{"id":"4cd06a36.13ca84","type":"trigger","z":"d6a46901.ebee1","name":"","op1":"1","op2":"off","op1type":"str","op2type":"str","duration":"15","extend":false,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":1690,"y":540,"wires":[[],["fc91d3b2.131e2"]]},{"id":"7c068811.477028","type":"change","z":"d6a46901.ebee1","name":"","rules":[{"t":"set","p":"delay","pt":"msg","to":"15","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1520,"y":460,"wires":[["4cd06a36.13ca84"]]}]

1 Like

This seems to be working exactly as I need. Thank you kindly for your help.

There is a mistake in the set message delay node. I entered the time in seconds it should be milliseconds. So change 15 to 15000 in that node.

1 Like

I’ve had to modify your flow slightly as my motion sensor doesn’t seem to report a motion event repeatedly if motion is continuously detected. So what ends up happening is, if the pc is turned on and motion goes off for a second this will allow a payload through; if motion is then detected again but then the pc turns off, the lights will turn off. So I think I need that last motion check before the payload is delivered.

I know this has been a while but I am attempting to determine if motion was detected in the last 3 minutes. Curious if you can share your flow?

Hello, I’m afraid I’ve changed my flow quite a bit since my last post. I’m not sure my current flow would help you with what you are trying to do, but I can post the code if you want. This is what it looks like now:

Yes I would love to see the flow and see how I can learn from it.

I forgot to post this. Hope it is still useful:

[{"id":"512339a0be6cb40e","type":"api-call-service","z":"370d7c7ee10cad45","name":"Turn off lights","server":"6e6a7fd05cb77906","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.govee_lyra1","light.govee_lyra2","light.office_leds","light.wiz_office"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":600,"y":400,"wires":[[]]},{"id":"7597723d7c9ec1e6","type":"time-range-switch","z":"370d7c7ee10cad45","name":"12am - 5am","lat":"","lon":"","startTime":"00:00","endTime":"05:00","startOffset":0,"endOffset":0,"x":370,"y":120,"wires":[["ee744936495064e0"],["99c130ee5aa22796","ee744936495064e0"]]},{"id":"089cc6efa50c2172","type":"trigger-state","z":"370d7c7ee10cad45","name":"Light turn on rules","server":"6e6a7fd05cb77906","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":["input_boolean.toggle_auto_office","input_boolean.nighttime","binary_sensor.shmos_office_motion"],"entityidfiltertype":"list","debugenabled":false,"constraints":[{"targetType":"entity_id","targetValue":"input_boolean.toggle_auto_office","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"},{"targetType":"entity_id","targetValue":"input_boolean.nighttime","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"},{"targetType":"entity_id","targetValue":"binary_sensor.shmos_office_motion","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"inputs":0,"outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","enableInput":false,"x":150,"y":120,"wires":[["7597723d7c9ec1e6"],[]]},{"id":"64b58b27ae45c116","type":"trigger-state","z":"370d7c7ee10cad45","name":"Light turn off rules","server":"6e6a7fd05cb77906","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":["input_boolean.toggle_auto_office","binary_sensor.shmos_office_motion","binary_sensor.ping_glados"],"entityidfiltertype":"list","debugenabled":false,"constraints":[{"targetType":"entity_id","targetValue":"input_boolean.toggle_auto_office","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"},{"targetType":"entity_id","targetValue":"binary_sensor.shmos_office_motion","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is_not","comparatorValueDatatype":"str","comparatorValue":"on"},{"targetType":"entity_id","targetValue":"binary_sensor.ping_glados","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"}],"inputs":0,"outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","enableInput":false,"x":150,"y":340,"wires":[["190640ab1d462e38"],[]]},{"id":"1dce3a9fd3972279","type":"trigger","z":"370d7c7ee10cad45","name":"","op1":"dim","op2":"off","op1type":"str","op2type":"str","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"on","bytopic":"all","topic":"topic","outputs":2,"x":370,"y":340,"wires":[["b4d01633f861f7eb","3548441cbefd7bb3"],["512339a0be6cb40e","3548441cbefd7bb3"]]},{"id":"d3de4e512dc7aafa","type":"api-call-service","z":"370d7c7ee10cad45","name":"Turn on light","server":"6e6a7fd05cb77906","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.wiz_office"],"data":"{\"brightness\":msg.data.attributes.brightness/2}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":790,"y":340,"wires":[[]]},{"id":"b4d01633f861f7eb","type":"api-current-state","z":"370d7c7ee10cad45","name":"Light on?","server":"6e6a7fd05cb77906","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.wiz_office","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"lightBrightness","propertyType":"flow","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":580,"y":340,"wires":[["d3de4e512dc7aafa"],[]]},{"id":"71f3600f5ce71a7a","type":"change","z":"370d7c7ee10cad45","name":"get brightness","rules":[{"t":"set","p":"data","pt":"msg","to":"lightBrightness","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":180,"wires":[["33dc1ea9a065eab6"]]},{"id":"99c130ee5aa22796","type":"function","z":"370d7c7ee10cad45","name":"if dimmed/off","func":"if (flow.get(\"lightStatus\") === \"dim\" ||\n    flow.get(\"lightStatus\") === \"off\") {\n    return [msg,null];\n}\nelse {\n    return [null, msg];\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":200,"wires":[["3548441cbefd7bb3","71f3600f5ce71a7a","1dce3a9fd3972279"],[]]},{"id":"3548441cbefd7bb3","type":"change","z":"370d7c7ee10cad45","name":"","rules":[{"t":"set","p":"lightStatus","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":280,"wires":[[]]},{"id":"190640ab1d462e38","type":"change","z":"370d7c7ee10cad45","name":"\"off\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":250,"y":400,"wires":[["1dce3a9fd3972279"]]},{"id":"33dc1ea9a065eab6","type":"api-call-service","z":"370d7c7ee10cad45","name":"Turn on lights","server":"6e6a7fd05cb77906","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.office_leds","light.wiz_office"],"data":"{\"brightness\":msg.data.attributes.brightness}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":920,"y":180,"wires":[[]]},{"id":"ee744936495064e0","type":"api-call-service","z":"370d7c7ee10cad45","name":"Turn on LEDs","server":"6e6a7fd05cb77906","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.govee_lyra1","light.govee_lyra2","light.office_leds"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":600,"y":120,"wires":[[]]},{"id":"6e6a7fd05cb77906","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]
2 Likes