Node Red Flow Review - Multiple Conditions for Space Heater

Hi everyone - I am embarking on a automation flow that has multiple conditions for turning a bedroom space heater on and off.

I have three conditions I want met for it to be turned on - for it to be less than 70F, during a set time period (sunset to 6AM), and for our family group presence to be “home”.

With these three conditionals, I’m not sure if I’m using the switch nodes right. Specifically inputting multiple payloads.

Would someone be willing to review, and critique my flow if needed?

[
    {
        "id": "36958ee10b93002c",
        "type": "tab",
        "label": "Master Bedroom",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "8a874552aec2b1a3",
        "type": "switch",
        "z": "36958ee10b93002c",
        "name": "Maintain 70 Degrees",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "lt",
                "v": "70",
                "vt": "str"
            },
            {
                "t": "gte",
                "v": "70",
                "vt": "str"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "x": 1053.9999389648438,
        "y": 178,
        "wires": [
            [
                "1a2d0e5afde80230"
            ],
            [
                "6eed48b0f8cc3ef4"
            ]
        ]
    },
    {
        "id": "1a2d0e5afde80230",
        "type": "api-current-state",
        "z": "36958ee10b93002c",
        "name": "Heater Off?",
        "server": "e204944a.31bc78",
        "version": 2,
        "outputs": 2,
        "halt_if": "off",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "switch.master_bedroom_heater_switch",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 1452.0000610351562,
        "y": 120,
        "wires": [
            [
                "fac765c58b4bf93f"
            ],
            []
        ]
    },
    {
        "id": "fac765c58b4bf93f",
        "type": "api-call-service",
        "z": "36958ee10b93002c",
        "name": "Turn Heater On",
        "server": "e204944a.31bc78",
        "version": 3,
        "debugenabled": false,
        "service_domain": "switch",
        "service": "turn_on",
        "entityId": "switch.master_bedroom_heater_switch",
        "data": "",
        "dataType": "jsonata",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 2026,
        "y": 66,
        "wires": [
            []
        ]
    },
    {
        "id": "6eed48b0f8cc3ef4",
        "type": "api-current-state",
        "z": "36958ee10b93002c",
        "name": "Heater On?",
        "server": "e204944a.31bc78",
        "version": 2,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "switch.master_bedroom_heater_switch",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 1450.0000610351562,
        "y": 223,
        "wires": [
            [
                "dbabfb2a0e7dc1fe"
            ],
            []
        ]
    },
    {
        "id": "dbabfb2a0e7dc1fe",
        "type": "api-call-service",
        "z": "36958ee10b93002c",
        "name": "Turn Heater Off",
        "server": "e204944a.31bc78",
        "version": 3,
        "debugenabled": false,
        "service_domain": "switch",
        "service": "turn_off",
        "entityId": "switch.master_bedroom_heater_switch",
        "data": "",
        "dataType": "jsonata",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 2089,
        "y": 541,
        "wires": [
            []
        ]
    },
    {
        "id": "190b40862ad581f0",
        "type": "poll-state",
        "z": "36958ee10b93002c",
        "name": "Master Bedroom Multisensor Temp",
        "server": "e204944a.31bc78",
        "version": 2,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "updateinterval": "60",
        "updateIntervalType": "num",
        "updateIntervalUnits": "seconds",
        "outputinitially": true,
        "outputonchanged": true,
        "entity_id": "sensor.master_bedroom_multisensor_air_temperature",
        "state_type": "str",
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "x": 187,
        "y": 169.00001525878906,
        "wires": [
            [
                "4ce36b773862f69f"
            ]
        ]
    },
    {
        "id": "4ce36b773862f69f",
        "type": "time-range-switch",
        "z": "36958ee10b93002c",
        "name": "Sunset On - Off at 6AM",
        "lat": "41.70728",
        "lon": "-93.62909",
        "startTime": "sunset",
        "endTime": "06:00",
        "startOffset": 0,
        "endOffset": 0,
        "x": 534.0000610351562,
        "y": 172.2000274658203,
        "wires": [
            [
                "2661e01f1bbdf1cf"
            ],
            [
                "dbabfb2a0e7dc1fe"
            ]
        ]
    },
    {
        "id": "9c36cd927e18572c",
        "type": "server-state-changed",
        "z": "36958ee10b93002c",
        "name": "Family Presence",
        "server": "e204944a.31bc78",
        "version": 3,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "group.presence_home",
        "entityidfiltertype": "exact",
        "outputinitially": true,
        "state_type": "str",
        "haltifstate": "home",
        "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": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 525.7999877929688,
        "y": 56.80000305175781,
        "wires": [
            [
                "2661e01f1bbdf1cf"
            ],
            []
        ]
    },
    {
        "id": "2661e01f1bbdf1cf",
        "type": "switch",
        "z": "36958ee10b93002c",
        "name": "Family Is Home",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "home",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "away",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 825,
        "y": 109.20002746582031,
        "wires": [
            [
                "8a874552aec2b1a3"
            ],
            []
        ]
    },
    {
        "id": "e204944a.31bc78",
        "type": "server",
        "name": "Home Assistant",
        "version": 2,
        "addon": false,
        "rejectUnauthorizedCerts": false,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": 30
    }
]

You could use something like this for the turn on. Then set a turn off trigger for when you leave and the end of the time on period.

[{"id":"c02dbf79606ce723","type":"server-state-changed","z":"f80b6c338afd5483","name":"","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.temp","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"70","halt_if_type":"num","halt_if_compare":"lte","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":"","valueType":"entityState"}],"x":140,"y":380,"wires":[["a4007ae96a33a07d"],[]]},{"id":"a4007ae96a33a07d","type":"time-range-switch","z":"f80b6c338afd5483","name":"","lat":"","lon":"","startTime":"07:28","endTime":"goldenHour","startOffset":0,"endOffset":0,"x":430,"y":380,"wires":[["3239c7c571c04119"],[]]},{"id":"3239c7c571c04119","type":"api-current-state","z":"f80b6c338afd5483","name":"who is home","server":"","version":2,"outputs":2,"halt_if":"home","halt_if_type":"str","halt_if_compare":"is","entity_id":"person.mike_fila","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":690,"y":380,"wires":[["75fa6d55458a8a8a"],[]]},{"id":"75fa6d55458a8a8a","type":"api-call-service","z":"f80b6c338afd5483","name":"call for heat","server":"","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":950,"y":380,"wires":[[]]}]

Thanks for the suggestion - Would I add the switch for meeting the 70F temp threshold between the 3rd and 4th nodes?

The state change is set to output only when the temp is <= 70.

Got it - thank you so much. I took the “outside” constraint on the time range as a service off call, and also took the false state on anyone home as an service off call.

[
    {
        "id": "36958ee10b93002c",
        "type": "tab",
        "label": "Master Bedroom",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "c02dbf79606ce723",
        "type": "server-state-changed",
        "z": "36958ee10b93002c",
        "name": "Master Bedroom Multisensor Temp",
        "server": "e204944a.31bc78",
        "version": 3,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "sensor.master_bedroom_multisensor_air_temperature",
        "entityidfiltertype": "exact",
        "outputinitially": true,
        "state_type": "str",
        "haltifstate": "70",
        "halt_if_type": "num",
        "halt_if_compare": "lte",
        "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": "",
                "valueType": "entityState"
            }
        ],
        "x": 213.79998779296875,
        "y": 705,
        "wires": [
            [
                "136aa06f08ee8eb7"
            ],
            []
        ]
    },
    {
        "id": "3239c7c571c04119",
        "type": "api-current-state",
        "z": "36958ee10b93002c",
        "name": "Anyone Home?",
        "server": "e204944a.31bc78",
        "version": 2,
        "outputs": 2,
        "halt_if": "home",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "group.presence_home",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 945.7999877929688,
        "y": 606,
        "wires": [
            [
                "75fa6d55458a8a8a"
            ],
            [
                "4c0b42f0bdebe1e9"
            ]
        ]
    },
    {
        "id": "75fa6d55458a8a8a",
        "type": "api-call-service",
        "z": "36958ee10b93002c",
        "name": "Turn Heater On",
        "server": "e204944a.31bc78",
        "version": 3,
        "debugenabled": false,
        "service_domain": "switch",
        "service": "turn_on",
        "entityId": "switch.master_bedroom_heater_switch",
        "data": "",
        "dataType": "jsonata",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1275.800048828125,
        "y": 575,
        "wires": [
            []
        ]
    },
    {
        "id": "136aa06f08ee8eb7",
        "type": "time-range-switch",
        "z": "36958ee10b93002c",
        "name": "Sunset On - Off at 6AM",
        "lat": "41.70728",
        "lon": "-93.62909",
        "startTime": "sunset",
        "endTime": "06:00",
        "startOffset": 0,
        "endOffset": 0,
        "x": 598.7999877929688,
        "y": 623.7999877929688,
        "wires": [
            [
                "3239c7c571c04119"
            ],
            [
                "4c0b42f0bdebe1e9"
            ]
        ]
    },
    {
        "id": "4c0b42f0bdebe1e9",
        "type": "api-call-service",
        "z": "36958ee10b93002c",
        "name": "Turn Heater Off",
        "server": "e204944a.31bc78",
        "version": 3,
        "debugenabled": false,
        "service_domain": "switch",
        "service": "turn_off",
        "entityId": "switch.master_bedroom_heater_switch",
        "data": "",
        "dataType": "jsonata",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1295.800048828125,
        "y": 735.7999877929688,
        "wires": [
            []
        ]
    },
    {
        "id": "e204944a.31bc78",
        "type": "server",
        "name": "Home Assistant",
        "version": 2,
        "addon": false,
        "rejectUnauthorizedCerts": false,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": 30
    }
]

Should work great - time will tell :slight_smile: