Compare value with a variable (entity)

Hi,
I am struggling with a - maybe - simple flow. Just want to compare 2 temperatures and in case the difference is bigger than a value do something. Below flow works s far, but the compare level is set to a fix value of 7 (in node "Diff >7°C"). I just want to take that comparision value out from an entity from HA. Means instead of "if Diff >= 7°C" it should be the logic "if Diff >= enitiy_value". Could anybody help me on this? Thank you.

my flow so far:

[{"id":"33c1d6fe.663a8a","type":"api-current-state","z":"2c418c52.f3d774","name":"Temperatur Innen","server":"a11aa034.815b8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.indoor_temperature","state_type":"num","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":390,"y":180,"wires":[["f7d945d0.ba4818"]]},{"id":"f7d945d0.ba4818","type":"change","z":"2c418c52.f3d774","name":"","rules":[{"t":"set","p":"var1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":180,"wires":[["37f6254e.fb19aa"]]},{"id":"c0133008.576ef","type":"api-current-state","z":"2c418c52.f3d774","name":"Temperatur aussen","server":"a11aa034.815b8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.outdoor_temperature","state_type":"num","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":390,"y":240,"wires":[["50fcdacf.1c6ca4"]]},{"id":"50fcdacf.1c6ca4","type":"change","z":"2c418c52.f3d774","name":"","rules":[{"t":"set","p":"var2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":240,"wires":[["37f6254e.fb19aa"]]},{"id":"37f6254e.fb19aa","type":"change","z":"2c418c52.f3d774","name":"sub","rules":[{"t":"set","p":"payload","pt":"msg","to":"$flowContext('var1')-$flowContext('var2')","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":200,"wires":[["bb1839b8.6ad328"]]},{"id":"bb1839b8.6ad328","type":"switch","z":"2c418c52.f3d774","name":"Diff > 7° ?","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"7","vt":"num"},{"t":"lt","v":"7","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":360,"y":358,"wires":[["ac1d090b.5b23b8","1e9f95a.e65386a"],["212300e7.5a60e","4748fca1.8f17b4"]]},{"id":"9286843d.3f3698","type":"server-state-changed","z":"2c418c52.f3d774","name":"F offen >5Min","server":"a11aa034.815b8","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.testswitch3","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"5","forType":"num","forUnits":"seconds","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":150,"y":220,"wires":[["33c1d6fe.663a8a","c0133008.576ef"],[]]},{"id":"ac1d090b.5b23b8","type":"function","z":"2c418c52.f3d774","name":"Meldung","func":"let d = new Date();\nvar entity_id = msg.topic;\nvar n = d.getTime();\nvar h =d.getHours();\nvar m =d.getMinutes();\n\nmsg.payload = \"Fenster schliessen! Zeit: \"+h+\":\"+m+ \" \"; \nmsg.payload = msg.payload + \"Sensor: \" \nmsg.payload = msg.payload + entity_id;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":352,"wires":[[]]},{"id":"de2059c1.9976c8","type":"comment","z":"2c418c52.f3d774","name":"Temperatur-Differenz berechnen","info":"wird aus der Payload der beiden Sensoren extrahiert","x":510,"y":140,"wires":[]},{"id":"8c3eb1fc.7b718","type":"comment","z":"2c418c52.f3d774","name":"Meldung Fenster schliessen","info":"","x":900,"y":315,"wires":[]},{"id":"212300e7.5a60e","type":"delay","z":"2c418c52.f3d774","name":"warte 10Min","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":370,"y":440,"wires":[["929abf65.0e12b"]]},{"id":"1e9f95a.e65386a","type":"debug","z":"2c418c52.f3d774","name":"Temp diff","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":600,"y":300,"wires":[]},{"id":"929abf65.0e12b","type":"api-current-state","z":"2c418c52.f3d774","name":"F noch offen?","server":"a11aa034.815b8","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.testswitch3","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":580,"y":440,"wires":[["ac1d090b.5b23b8"],[]]},{"id":"85b9782e.0f3598","type":"comment","z":"2c418c52.f3d774","name":"Meldung Fenster ist zu","info":"","x":820,"y":420,"wires":[]},{"id":"4748fca1.8f17b4","type":"debug","z":"2c418c52.f3d774","name":"Temp diff","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":560,"y":380,"wires":[]},{"id":"9cce44bc.e27468","type":"comment","z":"2c418c52.f3d774","name":"Wenn Diff zu gross --> Meldung","info":"wird aus der Payload der beiden Sensoren extrahiert","x":215,"y":318,"wires":[]},{"id":"f28b7252.28c3e","type":"comment","z":"2c418c52.f3d774","name":"Warte mind. 5 Minuten","info":"wird aus der Payload der beiden Sensoren extrahiert","x":185,"y":143,"wires":[]},{"id":"a11aa034.815b8","type":"server","name":"Home Assistant","addon":true}]

you could use a flow variable in the switch Screen Shot 2021-03-05 at 8.13.18 PM
You just need to set the flow vriable somewhere else.

Thank you very much for this explanation - was able to realise with the flow.content ! Great!!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.