Call service when flow is disabled in HA?

Hi!

I’ve made a simple NR flow which polls the temperature in a room and turns a heating switch on/off depending on the result. However, I want to turn this flow on and off via a HA button. Works like a charm. But if I turn the flow off when the heating is on when I turn it off it stays on. It would be nice to make NR turn the switch off after receiving the “disable” command?

BR,
Niklas

image

[{"id":"1d377d89ba30eb23","type":"poll-state","z":"ffbd7f06.4a014","name":"","server":"","version":1,"exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"poll room temp"},{"property":"icon","value":""}],"updateinterval":"60","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":false,"entity_id":"sensor.temperature","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":262,"y":2672,"wires":[["94b05789236ea8f4"]]},{"id":"94b05789236ea8f4","type":"api-call-service","z":"ffbd7f06.4a014","name":"Turn on heater","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.heater","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":528,"y":2672,"wires":[[]]},{"id":"c7e89b019abcdbcb","type":"server-state-changed","z":"ffbd7f06.4a014","name":"Watch of poll node to be disabled","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.poll_room_temp","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":274,"y":2720,"wires":[["94b05789236ea8f4"],[]]}]