I was able to read the prev state and do a function to read that path and pass it as payload value, but I’m still not sure how to connect the PIR with the prev_value reading. Here’s what I have so far
[{"id":"01a491104e1c7e13","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"e33e4890c15dd198","type":"server-state-changed","z":"01a491104e1c7e13","name":"Ambient light < 8?","server":"17f27332.cbbb3d","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.oficina_luz_ambiente","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"8","halt_if_type":"num","halt_if_compare":"lt","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":350,"y":240,"wires":[[],["7c1f637df74663de"]]},{"id":"7c1f637df74663de","type":"function","z":"01a491104e1c7e13","name":"get prev value","func":"msg.payload = msg.data.old_state.state\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":580,"y":240,"wires":[["4c15bea481ef953d"]]},{"id":"53456e4708a80bfa","type":"debug","z":"01a491104e1c7e13","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1010,"y":300,"wires":[]},{"id":"4c15bea481ef953d","type":"api-current-state","z":"01a491104e1c7e13","name":"Ambient light < 8","server":"17f27332.cbbb3d","version":3,"outputs":2,"halt_if":"8","halt_if_type":"num","halt_if_compare":"lt","entity_id":"sensor.oficina_luz_ambiente","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":790,"y":240,"wires":[["53456e4708a80bfa"],[]]},{"id":"876b95df52a962a7","type":"server-state-changed","z":"01a491104e1c7e13","name":"PIR","server":"17f27332.cbbb3d","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.oficina_movimiento","entityidfiltertype":"exact","outputinitially":true,"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":310,"y":180,"wires":[[],[]]},{"id":"17f27332.cbbb3d","type":"server","name":"Home Assistant","version":4,"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"}]