@yuval221183
Most simple flow is like this. (motion detection, Lux level > light on | No motion xx seconds > light off)
[{"id":"04946fc1375fe7dd","type":"server-state-changed","z":"60aa8ea9c7477ca7","name":"Wasruimte Motion","server":"85cb4144.a30f7","version":4,"exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"Wasruimte Automation"},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.motion_sensor_wasruimte_any","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":"600","forType":"num","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"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":1340,"wires":[["06f55963b0d16f91"],["6fff4ad296f6110d"]]},{"id":"6fff4ad296f6110d","type":"api-current-state","z":"60aa8ea9c7477ca7","name":"Wasruimte Lux < 25","server":"85cb4144.a30f7","version":3,"outputs":2,"halt_if":"25","halt_if_type":"num","halt_if_compare":"gt","entity_id":"sensor.motion_sensor_wasruimte_illuminance","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","x":360,"y":1340,"wires":[["7dc1edf70ad900ad"],[]]},{"id":"06f55963b0d16f91","type":"api-call-service","z":"60aa8ea9c7477ca7","name":"Turn off lights","server":"85cb4144.a30f7","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.light_wasruimte"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":340,"y":1280,"wires":[[]]},{"id":"7dc1edf70ad900ad","type":"api-call-service","z":"60aa8ea9c7477ca7","name":"Light On 20%","server":"85cb4144.a30f7","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.light_wasruimte"],"data":"{\"brightness_pct\":20}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":580,"y":1340,"wires":[[]]},{"id":"85cb4144.a30f7","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}]
This is a more complex methode but maybe usefull for your FP2 ( can’t wait to get one of those )
It uses a state machine and state node. So you can trigger a switch states or other stuff (like people etc.)
Depending on what state the state node is in and witch states it gets you can make a action that only counts then.
[{"id":"1ce2aeee07be4cf0","type":"comment","z":"60aa8ea9c7477ca7","name":"Smart Lights Wasruimte","info":"","x":120,"y":840,"wires":[]},{"id":"c8a5b8133f4017ed","type":"trigger-state","z":"60aa8ea9c7477ca7","name":"Light Wasruimte","server":"85cb4144.a30f7","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"light.light_wasruimte","entityidfiltertype":"substring","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"inputs":1,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":true,"x":100,"y":1120,"wires":[["fbdd542cdfcc1b44"],[]]},{"id":"69ccd9cb80e3deb9","type":"api-call-service","z":"60aa8ea9c7477ca7","name":"Light On 3%","server":"85cb4144.a30f7","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.light_wasruimte"],"data":"{\"brightness_pct\":3}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1050,"y":920,"wires":[["76f5eb3278f967cc"]]},{"id":"f69fb8fe41397248","type":"api-call-service","z":"60aa8ea9c7477ca7","name":"Turn off lights","server":"85cb4144.a30f7","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.light_wasruimte"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":920,"y":1160,"wires":[["79137bf3677e811c"]]},{"id":"fbdd542cdfcc1b44","type":"change","z":"60aa8ea9c7477ca7","name":"switch","rules":[{"t":"set","p":"payload","pt":"msg","to":"switch","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":1120,"wires":[[]]},{"id":"3e281722d02fd779","type":"change","z":"60aa8ea9c7477ca7","name":"motion","rules":[{"t":"set","p":"payload","pt":"msg","to":"motion","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":960,"wires":[["724e70e51e69be13"]]},{"id":"150a5d2bbaa364cb","type":"api-current-state","z":"60aa8ea9c7477ca7","name":"Light state","server":"85cb4144.a30f7","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.light_wasruimte","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"for":0,"forType":"num","forUnits":"minutes","x":1270,"y":1160,"wires":[["136e2acdf143537a"],[]]},{"id":"75dbf017c224fd09","type":"change","z":"60aa8ea9c7477ca7","name":"motion-on","rules":[{"t":"set","p":"payload","pt":"msg","to":"motion-on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1260,"y":1060,"wires":[["136e2acdf143537a"]]},{"id":"5120e12d2ecb8e69","type":"link in","z":"60aa8ea9c7477ca7","name":"kitchen state machine","links":["136e2acdf143537a"],"x":345,"y":1180,"wires":[["724e70e51e69be13"]]},{"id":"136e2acdf143537a","type":"link out","z":"60aa8ea9c7477ca7","name":"kitchen state machine","links":["5120e12d2ecb8e69"],"x":1435,"y":1100,"wires":[]},{"id":"c2e188b929199459","type":"api-current-state","z":"60aa8ea9c7477ca7","name":"Wasruimte Lux < 25","server":"85cb4144.a30f7","version":3,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is","entity_id":"sensor.motion_sensor_wasruimte_illuminance","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","x":340,"y":960,"wires":[["efc9859b5785abb5","675140b4f4503a2f"]]},{"id":"7129191bb6e50592","type":"api-current-state","z":"60aa8ea9c7477ca7","name":"Morning","server":"85cb4144.a30f7","version":3,"outputs":2,"halt_if":"Morning","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.time_of_day","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":900,"y":920,"wires":[["69ccd9cb80e3deb9"],[]]},{"id":"cbaf3a40e2608c9e","type":"api-current-state","z":"60aa8ea9c7477ca7","name":"Day","server":"85cb4144.a30f7","version":3,"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":[{"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":890,"y":980,"wires":[["1d6c124b40366f08"],[]]},{"id":"fd30a0249ec4d8bb","type":"api-current-state","z":"60aa8ea9c7477ca7","name":"Evening","server":"85cb4144.a30f7","version":3,"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":[{"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":900,"y":1040,"wires":[["93ccc35a3fa8b8cf"],[]]},{"id":"bfcff2a5a05ac021","type":"api-current-state","z":"60aa8ea9c7477ca7","name":"Night","server":"85cb4144.a30f7","version":3,"outputs":2,"halt_if":"Night","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.time_of_day","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":890,"y":1100,"wires":[["46dbaa80f37abb3f"],[]]},{"id":"1d6c124b40366f08","type":"api-call-service","z":"60aa8ea9c7477ca7","name":"Light On 20%","server":"85cb4144.a30f7","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.light_wasruimte"],"data":"{\"brightness_pct\":20}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1060,"y":980,"wires":[["76f5eb3278f967cc"]]},{"id":"93ccc35a3fa8b8cf","type":"api-call-service","z":"60aa8ea9c7477ca7","name":"Light On 8%","server":"85cb4144.a30f7","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.light_wasruimte"],"data":"{\"brightness_pct\":4}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1050,"y":1040,"wires":[["76f5eb3278f967cc"]]},{"id":"46dbaa80f37abb3f","type":"api-call-service","z":"60aa8ea9c7477ca7","name":"Light On 1%","server":"85cb4144.a30f7","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.light_wasruimte"],"data":"{\"brightness_pct\":1}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1050,"y":1100,"wires":[["76f5eb3278f967cc"]]},{"id":"9473ef84907f8dad","type":"rbe","z":"60aa8ea9c7477ca7","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":650,"y":920,"wires":[["f69fb8fe41397248"]]},{"id":"efc9859b5785abb5","type":"switch","z":"60aa8ea9c7477ca7","name":"> 26","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"26","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":530,"y":920,"wires":[["9473ef84907f8dad"]]},{"id":"675140b4f4503a2f","type":"switch","z":"60aa8ea9c7477ca7","name":"< 25","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"25","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":530,"y":960,"wires":[["3e281722d02fd779"]]},{"id":"2360aa53c5bc0050","type":"stoptimer","z":"60aa8ea9c7477ca7","duration":"5","units":"Second","payloadtype":"num","payloadval":"0","name":"pause detection","x":920,"y":1220,"wires":[["150a5d2bbaa364cb"],[]]},{"id":"79137bf3677e811c","type":"stoptimer","z":"60aa8ea9c7477ca7","duration":"10","units":"Second","payloadtype":"num","payloadval":"0","name":"pause","x":1090,"y":1160,"wires":[["150a5d2bbaa364cb"],[]]},{"id":"76f5eb3278f967cc","type":"stoptimer","z":"60aa8ea9c7477ca7","duration":"15","units":"Second","payloadtype":"num","payloadval":"0","name":"pause","x":1250,"y":1000,"wires":[["75dbf017c224fd09"],[]]},{"id":"e4dc9e91341d1501","type":"switch","z":"60aa8ea9c7477ca7","name":"State Action","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"motion-detected","vt":"str"},{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"switch","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":650,"y":1120,"wires":[["7129191bb6e50592","cbaf3a40e2608c9e","fd30a0249ec4d8bb","bfcff2a5a05ac021"],["f69fb8fe41397248"],["2360aa53c5bc0050"]]},{"id":"724e70e51e69be13","type":"state-machine","z":"60aa8ea9c7477ca7","name":"","triggerProperty":"payload","triggerPropertyType":"msg","stateProperty":"payload","statePropertyType":"msg","initialDelay":"0","persistOnReload":false,"outputStateChangeOnly":true,"throwException":false,"states":["off","on","motion-detected","motion-on","switch"],"transitions":[{"name":"motion","from":"off","to":"motion-detected"},{"name":"motion","from":"on","to":"motion-detected"},{"name":"motion-on","from":"switch","to":"motion-detected"},{"name":"motion","from":"switch","to":"motion-detected"},{"name":"off","from":"motion-on","to":"off"},{"name":"off","from":"motion-detected","to":"off"},{"name":"switch","from":"motion-detected","to":"switch"},{"name":"switch","from":"on","to":"switch"},{"name":"switch","from":"switch","to":"switch"},{"name":"switch","from":"off","to":"switch"}],"x":460,"y":1120,"wires":[["e4dc9e91341d1501"]]},{"id":"8eef76d0f029d538","type":"server-state-changed","z":"60aa8ea9c7477ca7","name":"Wasruimte Motion","server":"85cb4144.a30f7","version":4,"exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"Wasruimte Automation"},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.motion_sensor_wasruimte_any","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":"600","forType":"num","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"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":960,"wires":[["724e70e51e69be13"],["c2e188b929199459"]]},{"id":"9e3a50cae752cf85","type":"server-state-changed","z":"60aa8ea9c7477ca7","name":"Wasruimte Lux","server":"85cb4144.a30f7","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.motion_sensor_wasruimte_illuminance","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"num","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":320,"y":900,"wires":[["efc9859b5785abb5"]]},{"id":"85cb4144.a30f7","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}]