I didn’t put the code because I think the flow is simple enough to understand it from a screenshot. But anyway, here it is:
[{"id":"8e02bdc4.bd48d","type":"server-state-changed","z":"d326cf3e.06bee","name":"Cocina Light","server":"244e8d39.7b4e02","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.shelly_motion_luminosity","entityidfiltertype":"exact","outputinitially":true,"state_type":"num","haltifstate":"","halt_if_type":"num","halt_if_compare":"lt","outputs":1,"output_only_on_state_change":false,"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":1480,"wires":[["2e0dfa21.cf30d6"]]},{"id":"a3220237.f1f4e","type":"server-state-changed","z":"d326cf3e.06bee","name":"Cocina Motion","server":"244e8d39.7b4e02","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.shelly_motion_motion","entityidfiltertype":"exact","outputinitially":true,"state_type":"habool","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":140,"y":1420,"wires":[["2e0dfa21.cf30d6"]]},{"id":"2e0dfa21.cf30d6","type":"join","z":"d326cf3e.06bee","name":"Combined","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":370,"y":1460,"wires":[["b3d07634.390988"]]},{"id":"b3d07634.390988","type":"debug","z":"d326cf3e.06bee","name":"cocina_multi_sensor","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":620,"y":1460,"wires":[]},{"id":"244e8d39.7b4e02","type":"server","name":"Home Assistant","version":1,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
I mean that I get a value that is not the real current value from the sensor. I can’t tell if it is the value from a minute ago or 3 seconds ago. So, for example, imagine that I want to use this information to turn a light on only if the lux values are below a threshold (AKA is dark enough). It happens that, I enter the room and the lights does not turn on. Why? Because it is “reading” the values that the sensor was reporting when the lights were on.
I don’t know how this sensor (shelly motion sensor) reports to home assistant, but when it reports to mqtt it provides all the values it has on every motion event: lux and motion.
Thanks