Unexpected Switch behavior (datatype?)

I am a novice with Node Red. I have a Midea HVAC that cannot keep its tempterature within a decent range.

Since I have been troubleshooting this Flow for sometime, I have taken parts of the msg payload and inputs and pushed them into the msg as easy to reference variables (smin,smax,temp,low,high,hvac_mode,etc...). I have created multiple debug points. My hypothesis is that this is a datatype issue, because when I look at the SWITCH output, I cannot figure out how it would trigger an OTHERWISE condition. I am hoping someone has a minute to import the flow and the debug and see if you can tell why Option 8 is being triggered.

The A/C is on and will not shut off. Notice in the following message how the temp is 79 and smax is 81? The expected behavior is that option 6 would be triggered. But instead it is Option 8?

Thank you!! (sorry, I only did one backtick with the original post)


SW2 Option 8 message reads:

{"topic":"climate.shed_hvac","payload":1645893259453,"data":{"event_type":"state_changed","entity_id":"climate.shed_hvac","event":{"entity_id":"climate.shed_hvac","old_state":{"entity_id":"climate.shed_hvac","state":"cool","attributes":{"hvac_modes":["off","cool","heat","fan_only"],"min_temp":66,"max_temp":79.5,"target_temp_step":0.5,"fan_modes":["auto","low","medium","high"],"preset_modes":["none","sleep"],"swing_modes":["off","both","vertical","horizontal"],"current_temperature":79.5,"temperature":78,"fan_mode":"auto","preset_mode":"none","swing_mode":"off","friendly_name":"Shed_HVAC","supported_features":57},"last_changed":"2022-02-26T16:29:16.730931+00:00","last_updated":"2022-02-26T16:29:16.730931+00:00","context":{"id":"098718e821637e0ec0274543691fe18c","parent_id":null,"user_id":"efedb14572b6469994746ef29757784c"},"original_state":"cool"},"new_state":{"entity_id":"climate.shed_hvac","state":"cool","attributes":{"hvac_modes":["off","cool","heat","fan_only"],"min_temp":66,"max_temp":79.5,"target_temp_step":0.5,"fan_modes":["auto","low","medium","high"],"preset_modes":["none","sleep"],"swing_modes":["off","both","vertical","horizontal"],"current_temperature":79,"temperature":78,"fan_mode":"auto","preset_mode":"none","swing_mode":"off","friendly_name":"Shed_HVAC","supported_features":57},"last_changed":"2022-02-26T16:29:16.730931+00:00","last_updated":"2022-02-26T16:34:18.828589+00:00","context":{"id":"c0f70eea9204db893881dc8bc2036515","parent_id":null,"user_id":null},"original_state":"cool","timeSinceChangedMs":302124}},"origin":"LOCAL","time_fired":"2022-02-26T16:34:18.828589+00:00","context":{"id":"c0f70eea9204db893881dc8bc2036515","parent_id":null,"user_id":null}},"_msgid":"ae94115cc04ab995","hvac_mode":"cool","temp":79,"mydate":"Sat Feb 26 2022","myymd":"2022-02-26","myyear":"2022","mymonth":"Feb","mymonthn":"02","mydom":"26","mydoy":"57","myday":"Sat","myhourpm":"11","myhour":"11","mytime":"11:34","mytimes":"11:34:18","myminute":"34","myminutes":"34:18","mysecond":"18","mymillis":"857","myepoch":"1645893258857","myrawdate":"2022-02-26T16:34:18.857Z","mypm":"AM","starttime":"07:45:00","stoptime":"16:45:00","high":76,"low":69,"smin":58,"smax":81,"ea_4b":"between startime and stoptime","ea_3b":"auto mode off"}

Flow:

[{"id":"e12ab7593cacd058","type":"trigger-state","z":"781c8f79747d6b74","name":"shed temp","server":"2238bceb.b75bb4","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"climate.shed_hvac","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"inputs":1,"outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","enableInput":true,"x":360,"y":100,"wires":[["572e5b46df8e3323"],[]]},{"id":"ca7d8b3d98c5eb8f","type":"api-current-state","z":"781c8f79747d6b74","name":"Auto Mode?","server":"2238bceb.b75bb4","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.shed_hvac_auto","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":130,"y":360,"wires":[["de119b89f1c3ace0"],["8631f88915dfacd8"]]},{"id":"572e5b46df8e3323","type":"change","z":"781c8f79747d6b74","name":"store flow variables","rules":[{"t":"set","p":"hvac_mode","pt":"msg","to":"payload","tot":"msg","dc":true},{"t":"set","p":"temp","pt":"msg","to":"data.event.new_state.attributes.current_temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":100,"wires":[["c50f03b7fe0d1745"]]},{"id":"f84d18da93771cda","type":"switch","z":"781c8f79747d6b74","name":"hvac_on?","property":"hvac_mode","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"neq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":460,"y":340,"wires":[["d21594e4343c8fb6"],[]]},{"id":"af14374f2c636214","type":"api-call-service","z":"781c8f79747d6b74","name":"Turn on ","server":"2238bceb.b75bb4","version":5,"debugenabled":false,"domain":"climate","service":"turn_on","areaId":[],"deviceId":[],"entityId":["climate.shed_hvac"],"data":"{}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":740,"y":260,"wires":[[]]},{"id":"50c89f07c0e91f05","type":"comment","z":"781c8f79747d6b74","name":"","info":"debug can output the value of a flow by using:\n$flowContext('variable')\n\nfunction can reference it using\nflow.get('variable')\n\n$number($entities(\"climate.shed_hvac\").attributes.current_temperature) \n\n{\"test3\":$number(low)-20}.\n\nstates('sensor.temperature')","x":100,"y":520,"wires":[]},{"id":"16cf8d8790a80abf","type":"switch","z":"781c8f79747d6b74","name":"TOO COLD or TOO HOT","property":"temp","propertyType":"msg","rules":[{"t":"empty"},{"t":"null"},{"t":"lt","v":"{\"test3\":smin-20}","vt":"jsonata"},{"t":"gt","v":"{\"test2\":smax+20}","vt":"jsonata"},{"t":"lte","v":"smin","vt":"msg"},{"t":"gte","v":"smax","vt":"msg"},{"t":"btwn","v":"{\"test1\":smin+1}","vt":"jsonata","v2":"{\"test4\":smax-1}","v2t":"jsonata"},{"t":"else"}],"checkall":"false","repair":false,"outputs":8,"x":510,"y":1100,"wires":[["85c57238890d70cd"],["90002450373dc701"],["026cabc5a9808c27"],["c84c3d4da3f2a0d8"],["a9eb268755a182f9","22e2d20dfae6b93d"],["b8af3dce09423f17","22e2d20dfae6b93d"],["5e85b36a46e577ec"],["5bb421bfcc5e2ac8"]]},{"id":"c98acc00efa47b21","type":"api-call-service","z":"781c8f79747d6b74","name":"Turn on Heat","server":"2238bceb.b75bb4","version":3,"debugenabled":true,"service":"set_hvac_mode","entityId":"climate.shed_hvac","data":"{\"hvac_mode\": \"heat\"}","dataType":"json","mustacheAltTags":false,"outputProperties":[],"queue":"none","service_domain":"climate","mergecontext":"","x":1470,"y":1020,"wires":[["43c65a30185dc0bf"]]},{"id":"a9eb268755a182f9","type":"switch","z":"781c8f79747d6b74","name":"Heat on?","property":"hvac_mode","propertyType":"msg","rules":[{"t":"eq","v":"heat","vt":"str"},{"t":"neq","v":"heat","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":840,"y":1060,"wires":[["aed0cd8b29229e7d","60ed267ee64d7b98"],["52cd1b817a26d90c"]]},{"id":"b8af3dce09423f17","type":"switch","z":"781c8f79747d6b74","name":"A/C on?","property":"hvac_mode","propertyType":"msg","rules":[{"t":"eq","v":"cool","vt":"str"},{"t":"neq","v":"cool","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":800,"y":1260,"wires":[["aed0cd8b29229e7d","ca735276ab904a2e"],["1743f0fc95eddb70"]]},{"id":"5d04dde1bb0a4b05","type":"api-call-service","z":"781c8f79747d6b74","name":"Turn on A/C","server":"2238bceb.b75bb4","version":5,"debugenabled":true,"domain":"climate","service":"set_hvac_mode","areaId":[],"deviceId":[],"entityId":["climate.shed_hvac"],"data":"{\"hvac_mode\": \"cool\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1530,"y":1200,"wires":[["534f8c985a2d3714"]]},{"id":"156d770c34d2202f","type":"api-call-service","z":"781c8f79747d6b74","name":"Turn off","server":"2238bceb.b75bb4","version":5,"debugenabled":true,"domain":"climate","service":"turn_off","areaId":[],"deviceId":[],"entityId":["climate.shed_hvac"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1280,"y":860,"wires":[[]]},{"id":"aed0cd8b29229e7d","type":"debug","z":"781c8f79747d6b74","name":"no change","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1270,"y":1320,"wires":[]},{"id":"ca735276ab904a2e","type":"api-call-service","z":"781c8f79747d6b74","name":"Set Temp","server":"2238bceb.b75bb4","version":5,"debugenabled":false,"domain":"climate","service":"set_temperature","areaId":[],"deviceId":[],"entityId":["climate.shed_hvac"],"data":"{\"temperature\": smax }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1940,"y":1240,"wires":[["15bebe9b3bce6245"]]},{"id":"60ed267ee64d7b98","type":"api-call-service","z":"781c8f79747d6b74","name":"Set Temp","server":"2238bceb.b75bb4","version":5,"debugenabled":false,"domain":"climate","service":"set_temperature","areaId":[],"deviceId":[],"entityId":["climate.shed_hvac"],"data":"{\"temperature\": smin }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1940,"y":1060,"wires":[["6ddf6fd985b4d50f"]]},{"id":"192c5669f4cba399","type":"api-current-state","z":"781c8f79747d6b74","name":"get_starttime","server":"2238bceb.b75bb4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_datetime.shed_hvac_auto_starttime","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"starttime","propertyType":"msg","value":"","valueType":"entityState"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":950,"y":100,"wires":[["430fa49ff3c5e484"]]},{"id":"430fa49ff3c5e484","type":"api-current-state","z":"781c8f79747d6b74","name":"get_stoptime","server":"2238bceb.b75bb4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_datetime.shed_hvac_auto_stoptime","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"stoptime","propertyType":"msg","value":"","valueType":"entityState"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1150,"y":100,"wires":[["7e6f43b0a649d546"]]},{"id":"2aa67c2ceae44365","type":"switch","z":"781c8f79747d6b74","name":"between start and stop?","property":"mytimes","propertyType":"msg","rules":[{"t":"btwn","v":"starttime","vt":"msg","v2":"stoptime","v2t":"msg"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":170,"y":200,"wires":[["9aa6bcbe89999a2c"],["72f5f3e3ed801c62"]]},{"id":"c50f03b7fe0d1745","type":"simpletime","z":"781c8f79747d6b74","name":"","mydate":true,"myymd":true,"myyear":true,"mymonth":true,"mymonthn":true,"mydom":true,"mydoy":true,"myday":true,"myhourpm":true,"myhour":true,"mytime":true,"mytimes":true,"myminute":true,"myminutes":true,"mysecond":true,"mymillis":true,"myepoch":true,"myrawdate":true,"mypm":true,"x":790,"y":100,"wires":[["192c5669f4cba399"]]},{"id":"52cd1b817a26d90c","type":"switch","z":"781c8f79747d6b74","name":"hvac_on?","property":"hvac_mode","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"neq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":980,"y":1020,"wires":[["183598d5da9548f4"],["c98acc00efa47b21"]]},{"id":"52fc90c41dbf6a20","type":"api-call-service","z":"781c8f79747d6b74","name":"Turn on ","server":"2238bceb.b75bb4","version":3,"debugenabled":false,"service":"turn_on","entityId":"climate.shed_hvac","data":"{}","dataType":"json","mustacheAltTags":false,"outputProperties":[],"queue":"none","service_domain":"climate","mergecontext":"","x":1140,"y":960,"wires":[["bfb4ece2ddb82aca"]]},{"id":"1743f0fc95eddb70","type":"switch","z":"781c8f79747d6b74","name":"hvac_on?","property":"hvac_mode","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"neq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":880,"y":1200,"wires":[["46e3c25bb8e5fbd9"],["5d04dde1bb0a4b05"]]},{"id":"9f847076955b1c84","type":"api-call-service","z":"781c8f79747d6b74","name":"Turn on ","server":"2238bceb.b75bb4","version":3,"debugenabled":false,"service":"turn_on","entityId":"climate.shed_hvac","data":"{}","dataType":"json","mustacheAltTags":false,"outputProperties":[],"queue":"none","service_domain":"climate","mergecontext":"","x":1180,"y":1140,"wires":[["38dcd61ac39b73a9"]]},{"id":"3d84cd54156f5d7c","type":"debug","z":"781c8f79747d6b74","name":"No Action Taken","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":980,"y":780,"wires":[]},{"id":"22e2d20dfae6b93d","type":"debug","z":"781c8f79747d6b74","name":"Action Taken","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":1440,"wires":[]},{"id":"e9a1dd078cad062c","type":"switch","z":"781c8f79747d6b74","name":"hvac_on?","property":"hvac_mode","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"neq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":900,"y":860,"wires":[["3d84cd54156f5d7c"],["f0ef952394c28e80"]]},{"id":"b1e85c79bca05f1d","type":"server-state-changed","z":"781c8f79747d6b74","name":"Change Detected","server":"2238bceb.b75bb4","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.shed_hvac_auto","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":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"enable","valueType":"str"}],"x":200,"y":20,"wires":[["e12ab7593cacd058"]]},{"id":"bf548b285004fcea","type":"server-state-changed","z":"781c8f79747d6b74","name":"Change Detected","server":"2238bceb.b75bb4","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.shed_hvac_auto_high","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":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"enable","valueType":"str"}],"x":1500,"y":20,"wires":[["e12ab7593cacd058"]]},{"id":"e8cb464ecaac042b","type":"server-state-changed","z":"781c8f79747d6b74","name":"Change Detected","server":"2238bceb.b75bb4","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.shed_hvac_auto_low","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":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"enable","valueType":"str"}],"x":400,"y":20,"wires":[["e12ab7593cacd058"]]},{"id":"76f819dd64a2ee44","type":"server-state-changed","z":"781c8f79747d6b74","name":"Change Detected","server":"2238bceb.b75bb4","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_datetime.shed_hvac_auto_starttime","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":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"enable","valueType":"str"}],"x":640,"y":20,"wires":[["e12ab7593cacd058"]]},{"id":"120223465e8599ae","type":"server-state-changed","z":"781c8f79747d6b74","name":"Change Detected","server":"2238bceb.b75bb4","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_datetime.shed_hvac_auto_stoptime","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":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"enable","valueType":"str"}],"x":860,"y":20,"wires":[["e12ab7593cacd058"]]},{"id":"7fbbff7cd46031f1","type":"server-state-changed","z":"781c8f79747d6b74","name":"Change Detected","server":"2238bceb.b75bb4","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.shed_hvac_max","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":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"enable","valueType":"str"}],"x":1080,"y":20,"wires":[["e12ab7593cacd058"]]},{"id":"f1a5eb4dc1096687","type":"server-state-changed","z":"781c8f79747d6b74","name":"Change Detected","server":"2238bceb.b75bb4","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.shed_hvac_min","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":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"enable","valueType":"str"}],"x":1300,"y":20,"wires":[["e12ab7593cacd058"]]},{"id":"5e85b36a46e577ec","type":"api-current-state","z":"781c8f79747d6b74","name":"Auto Mode?","server":"2238bceb.b75bb4","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.shed_hvac_auto","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":730,"y":860,"wires":[["3d84cd54156f5d7c"],["e9a1dd078cad062c"]]},{"id":"d21594e4343c8fb6","type":"delay","z":"781c8f79747d6b74","name":"Wait 5 sec","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":630,"y":340,"wires":[["af14374f2c636214"]]},{"id":"f0ef952394c28e80","type":"delay","z":"781c8f79747d6b74","name":"Wait 5 sec","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1090,"y":860,"wires":[["156d770c34d2202f"]]},{"id":"183598d5da9548f4","type":"delay","z":"781c8f79747d6b74","name":"Wait 5 sec","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":990,"y":960,"wires":[["52fc90c41dbf6a20"]]},{"id":"bfb4ece2ddb82aca","type":"delay","z":"781c8f79747d6b74","name":"Wait 5 sec","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1290,"y":960,"wires":[["c98acc00efa47b21"]]},{"id":"46e3c25bb8e5fbd9","type":"delay","z":"781c8f79747d6b74","name":"Wait 5 sec","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1030,"y":1140,"wires":[["9f847076955b1c84"]]},{"id":"38dcd61ac39b73a9","type":"delay","z":"781c8f79747d6b74","name":"Wait 5 sec","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1350,"y":1140,"wires":[["5d04dde1bb0a4b05"]]},{"id":"43c65a30185dc0bf","type":"delay","z":"781c8f79747d6b74","name":"Wait 5 sec","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1650,"y":1020,"wires":[["60ed267ee64d7b98"]]},{"id":"534f8c985a2d3714","type":"delay","z":"781c8f79747d6b74","name":"Wait 5 sec","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1750,"y":1200,"wires":[["ca735276ab904a2e"]]},{"id":"de119b89f1c3ace0","type":"change","z":"781c8f79747d6b74","name":"msg","rules":[{"t":"set","p":"ea_3a","pt":"msg","to":"auto mode on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":340,"wires":[["f84d18da93771cda"]]},{"id":"8631f88915dfacd8","type":"change","z":"781c8f79747d6b74","name":"msg","rules":[{"t":"set","p":"ea_3b","pt":"msg","to":"auto mode off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":420,"wires":[["16cf8d8790a80abf"]]},{"id":"8eedaa163785da1f","type":"trigger","z":"781c8f79747d6b74","name":"","op1":"","op2":"0","op1type":"date","op2type":"str","duration":"0","extend":false,"overrideDelay":false,"units":"ms","reset":"reset","bytopic":"all","topic":"topic","outputs":1,"x":620,"y":160,"wires":[["2aa67c2ceae44365","afd3c88a71153fb2"]]},{"id":"afd3c88a71153fb2","type":"delay","z":"781c8f79747d6b74","name":"","pauseType":"delay","timeout":"90","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":900,"y":160,"wires":[["a948cb17d05bad7d"]]},{"id":"a948cb17d05bad7d","type":"function","z":"781c8f79747d6b74","name":"payload=reset","func":"msg.payload=\"reset\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1080,"y":160,"wires":[["8eedaa163785da1f"]]},{"id":"d85c118ef3de6d63","type":"inject","z":"781c8f79747d6b74","name":"manual reset","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"reset","payloadType":"str","x":130,"y":120,"wires":[["8eedaa163785da1f"]]},{"id":"7e6f43b0a649d546","type":"api-current-state","z":"781c8f79747d6b74","name":"get_high","server":"2238bceb.b75bb4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_number.shed_hvac_auto_high","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"high","propertyType":"msg","value":"","valueType":"entityState"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1340,"y":100,"wires":[["c857af72ec105403"]]},{"id":"c857af72ec105403","type":"api-current-state","z":"781c8f79747d6b74","name":"get_low","server":"2238bceb.b75bb4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_number.shed_hvac_auto_low","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"low","propertyType":"msg","value":"","valueType":"entityState"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1480,"y":100,"wires":[["067bc47ba38eb246"]]},{"id":"7f1ba85184eeb0f8","type":"debug","z":"781c8f79747d6b74","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2190,"y":800,"wires":[]},{"id":"6ddf6fd985b4d50f","type":"change","z":"781c8f79747d6b74","name":"set temp msg","rules":[{"t":"set","p":"ea_2d","pt":"msg","to":"{\"set temp\":smin}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":2020,"y":980,"wires":[["7f1ba85184eeb0f8"]]},{"id":"15bebe9b3bce6245","type":"change","z":"781c8f79747d6b74","name":"set temp msg","rules":[{"t":"set","p":"ea_2e","pt":"msg","to":"{\"set temp\":smax}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":2080,"y":1160,"wires":[["7f1ba85184eeb0f8"]]},{"id":"72f5f3e3ed801c62","type":"change","z":"781c8f79747d6b74","name":"msg","rules":[{"t":"set","p":"ea_4b","pt":"msg","to":"not between startime and stoptime","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":820,"wires":[["16cf8d8790a80abf","f8bc8f2b993b5c72"]]},{"id":"9aa6bcbe89999a2c","type":"change","z":"781c8f79747d6b74","name":"msg","rules":[{"t":"set","p":"ea_4b","pt":"msg","to":"between startime and stoptime","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":190,"y":260,"wires":[["ca7d8b3d98c5eb8f","e15d8d091d84c3c2"]]},{"id":"067bc47ba38eb246","type":"api-current-state","z":"781c8f79747d6b74","name":"get_min","server":"2238bceb.b75bb4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_number.shed_hvac_min","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"smin","propertyType":"msg","value":"","valueType":"entityState"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1660,"y":100,"wires":[["60a93b254bca6229"]]},{"id":"60a93b254bca6229","type":"api-current-state","z":"781c8f79747d6b74","name":"get_max","server":"2238bceb.b75bb4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_number.shed_hvac_max","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"smax","propertyType":"msg","value":"","valueType":"entityState"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1860,"y":100,"wires":[["8eedaa163785da1f"]]},{"id":"e15d8d091d84c3c2","type":"debug","z":"781c8f79747d6b74","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":430,"y":260,"wires":[]},{"id":"f8bc8f2b993b5c72","type":"debug","z":"781c8f79747d6b74","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":470,"y":820,"wires":[]},{"id":"85c57238890d70cd","type":"debug","z":"781c8f79747d6b74","name":"SW2 Option 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":400,"y":1220,"wires":[]},{"id":"90002450373dc701","type":"debug","z":"781c8f79747d6b74","name":"SW2 Option 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":400,"y":1260,"wires":[]},{"id":"026cabc5a9808c27","type":"debug","z":"781c8f79747d6b74","name":"SW2 Option 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":400,"y":1300,"wires":[]},{"id":"c84c3d4da3f2a0d8","type":"debug","z":"781c8f79747d6b74","name":"SW2 Option 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":400,"y":1340,"wires":[]},{"id":"5bb421bfcc5e2ac8","type":"debug","z":"781c8f79747d6b74","name":"SW2 Option 8","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":400,"y":1380,"wires":[]},{"id":"2238bceb.b75bb4","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

When posting flows, code etc, in order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

``` 
   code goes here 
```

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json

However, if you think a Switch node is not performing as you want, all you need to do is show us what the input to the switch looks like (in a debug node) and show us how you have configured the Switch. Posting a massive flow with mutliple non-core nodes that most do not have installed is just going to put people off.

A common reason that a Switch node does not do as expected is that the value being tested is a string containing a number, not a number. If it is that then you will see it in the debug output.

Changes made. I agree; my hypothesis is that it is a datatype issue. But they all look like numbers to me.

The type is easy to see in the debug node.

If you are seeing a red number: it is text.
If you are seeing a blue number: it is a number.

in your switch you are testing msg.temp to see if it is less than {"test3":smin-20}.

Where is test3 coming from? It doesn't seem to be in the msg anywhere.

What are you trying to do with that test?

Option 6 is triggered if msg.temp >= msg.smax. 79 is not >= 81.

Good question. I was just using this as an alternative method for defining a test value.

I tried the using the following with the same net effect (otherwise behavior instead of condition 6):

Did you see the post I entered at the same time as you were typing?

In the example it should actually go to output 7, but it appears there is a bug in the 'between' option in the switch node if you have arithmetic there, msg.smin+1 for example.
This flow does not work as it should.

image

[{"id":"37b1f326501a7230","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"temp","v":"80","vt":"num"},{"p":"smin","v":"59","vt":"num"},{"p":"smax","v":"82","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":1120,"wires":[["8c649e2be2f68087"]]},{"id":"8c649e2be2f68087","type":"switch","z":"bdd7be38.d3b55","name":"","property":"temp","propertyType":"msg","rules":[{"t":"btwn","v":"smin+1","vt":"msg","v2":"smax-1","v2t":"msg"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":310,"y":1120,"wires":[["a75b5623a481496e"],["d2f29b68a90e5638"]]},{"id":"a75b5623a481496e","type":"debug","z":"bdd7be38.d3b55","name":"ONE","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":510,"y":1100,"wires":[]},{"id":"d2f29b68a90e5638","type":"debug","z":"bdd7be38.d3b55","name":"TWO","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":510,"y":1160,"wires":[]}]

Oh my word. Yes! It still should not be going to Otherwise.

YES!

So what would a solution be? A function?

Thanks Colin. I am not sure of the right way to do this. But as you mentioned, arithmetic did not work. So, I just created a function that does the math. It works

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