Boiler on/off detection from Total power consumption

Hi,
I would like to create a routine in node red to understand when the boiler is on or off (to calculate relative consumption).
Having at home energy meter a consumption detector and knowing that my boiler when turned on consumes between 58W (fluctuates between 50W and 65W), my idea is to:
Take every 10 seconds the total consumption value of the detector, check if in those 10 seconds there was an increase in consumption between 50 and 65W. If yes, sensor.boiler = on otherwise sensor.boiler = off.

How can I do this? Thank you very much

If it’s only 65 W on your total consumption then I believe you will get a lot of false positives.
65 watts is not an uncommon wattage.

I know but i think is a good exercise for everyone want to do something like this and a personal try (I am already thinking of purchasing a shelly P1 to do this accurately)

So how often does the values update on the sensor? is it every 10 seconds or more often?

Sensor updates every 1 second

I have set the timeout to 60 seconds in the join node. Change it to what you want, but I needed 60 seconds for my sensor I was testing on.

[{"id":"29542a024e51a8be","type":"ha-entity","z":"ebaa69a9.649708","name":"boiler","server":"4bbca37b.1700ec","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"on","stateType":"str","attributes":[{"property":"last_change","value":"change","valueType":"msg"}],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":790,"y":620,"wires":[[]]},{"id":"cbebf94ec244078d","type":"switch","z":"ebaa69a9.649708","name":"","property":"change","propertyType":"msg","rules":[{"t":"btwn","v":"50","vt":"num","v2":"65","v2t":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":660,"wires":[["29542a024e51a8be"],["871807f62d27196e"]]},{"id":"1ed2147a69e067a6","type":"function","z":"ebaa69a9.649708","name":"","func":"msg.change = parseFloat(msg.payload[msg.payload.length-1]) - parseFloat(msg.payload[0]);      \n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":660,"wires":[["cbebf94ec244078d"]]},{"id":"871807f62d27196e","type":"ha-entity","z":"ebaa69a9.649708","name":"boiler","server":"4bbca37b.1700ec","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"off","stateType":"str","attributes":[{"property":"last_change","value":"change","valueType":"msg"}],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":800,"y":680,"wires":[[]]},{"id":"851dea0375c5eaa0","type":"join","z":"ebaa69a9.649708","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"60","count":"10","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":350,"y":660,"wires":[["1ed2147a69e067a6"]]},{"id":"a87da41d12e6cbd1","type":"server-state-changed","z":"ebaa69a9.649708","name":"","server":"4bbca37b.1700ec","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.power","entityidfiltertype":"exact","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":140,"y":660,"wires":[["851dea0375c5eaa0"]]},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
1 Like

Really thank you!