Store and extract payload and ON value

[
    {
        "id": "70e51d08eb1bde9c",
        "type": "change",
        "z": "7b83b20cb732bf2a",
        "name": "set memory",
        "rules": [
            {
                "t": "set",
                "p": "#:(file)::modes",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 730,
        "y": 320,
        "wires": [
            [
                "caa5f4b99f7da5b6"
            ]
        ]
    },
    {
        "id": "986f8041a31d81fc",
        "type": "change",
        "z": "7b83b20cb732bf2a",
        "name": "Get memory",
        "rules": [
            {
                "t": "set",
                "p": "#:(file)::modes",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 550,
        "y": 560,
        "wires": [
            [
                "53eb89dedc94539c"
            ]
        ]
    },
    {
        "id": "fc634b1dea3eb4dc",
        "type": "trigger",
        "z": "7b83b20cb732bf2a",
        "name": "",
        "op1": "",
        "op2": "",
        "op1type": "pay",
        "op2type": "pay",
        "duration": "10",
        "extend": false,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 370,
        "y": 620,
        "wires": [
            [
                "986f8041a31d81fc"
            ]
        ]
    },
    {
        "id": "b9f48f5eddd75d47",
        "type": "inject",
        "z": "7b83b20cb732bf2a",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "payload",
        "payloadType": "msg",
        "x": 150,
        "y": 620,
        "wires": [
            [
                "fc634b1dea3eb4dc"
            ]
        ]
    },
    {
        "id": "9db7201c3ddbf7d8",
        "type": "server-state-changed",
        "z": "7b83b20cb732bf2a",
        "name": "Ferie",
        "server": "12135e641a9670e0",
        "version": 4,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "input_boolean.vacation_mode",
        "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": 230,
        "y": 460,
        "wires": [
            [
                "a6cf3de1910234de"
            ]
        ]
    },
    {
        "id": "c8c1a272d6f63707",
        "type": "server-state-changed",
        "z": "7b83b20cb732bf2a",
        "name": "Borte",
        "server": "12135e641a9670e0",
        "version": 4,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "input_boolean.away_mode",
        "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": 230,
        "y": 240,
        "wires": [
            [
                "a6cf3de1910234de"
            ]
        ]
    },
    {
        "id": "f9566101d6146066",
        "type": "server-state-changed",
        "z": "7b83b20cb732bf2a",
        "name": "Natt",
        "server": "12135e641a9670e0",
        "version": 4,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "input_boolean.night_mode",
        "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": 220,
        "y": 300,
        "wires": [
            [
                "a6cf3de1910234de"
            ]
        ]
    },
    {
        "id": "2b6a38ba0191afab",
        "type": "server-state-changed",
        "z": "7b83b20cb732bf2a",
        "name": "Hjemme",
        "server": "12135e641a9670e0",
        "version": 4,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "input_boolean.home_mode",
        "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": 230,
        "y": 360,
        "wires": [
            [
                "a6cf3de1910234de"
            ]
        ]
    },
    {
        "id": "a6cf3de1910234de",
        "type": "switch",
        "z": "7b83b20cb732bf2a",
        "name": "State Check",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "on",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 410,
        "y": 300,
        "wires": [
            [
                "1183ca5e08707323"
            ]
        ]
    },
    {
        "id": "1183ca5e08707323",
        "type": "change",
        "z": "7b83b20cb732bf2a",
        "name": "Extract Entity and Value",
        "rules": [
            {
                "t": "set",
                "p": "entity",
                "pt": "msg",
                "to": "entityid",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "value",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 400,
        "wires": [
            [
                "70e51d08eb1bde9c"
            ]
        ]
    },
    {
        "id": "98e3445687de0b5f",
        "type": "switch",
        "z": "7b83b20cb732bf2a",
        "name": "Check Entity",
        "property": "entity",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "input_boolean.away_mode",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "input_boolean.night_mode",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "input_boolean.home_mode",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "input_boolean.vacation_mode",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 4,
        "x": 810,
        "y": 640,
        "wires": [
            [
                "481a057009317e50",
                "2bc5aaafd00484a9"
            ],
            [
                "7a65a472e7383f1c",
                "9c6e25d2459a7360"
            ],
            [
                "a51f3f1380d4560f",
                "de95f458c34df77c"
            ],
            [
                "6937a4c2d666c11a",
                "bae87d872ef89b9e"
            ]
        ]
    },
    {
        "id": "481a057009317e50",
        "type": "api-call-service",
        "z": "7b83b20cb732bf2a",
        "name": "Activate Away Mode",
        "server": "12135e641a9670e0",
        "version": 5,
        "debugenabled": false,
        "service": "turn_on",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "input_boolean.away_mode"
        ],
        "data": "",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "output_location": "",
        "output_location_type": "none",
        "service_domain": "script",
        "mergecontext": "",
        "x": 1120,
        "y": 540,
        "wires": [
            []
        ]
    },
    {
        "id": "7a65a472e7383f1c",
        "type": "api-call-service",
        "z": "7b83b20cb732bf2a",
        "name": "Activate Night Mode",
        "server": "12135e641a9670e0",
        "version": 5,
        "debugenabled": false,
        "service": "turn_on",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "input_boolean.night_mode"
        ],
        "data": "",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "output_location": "",
        "output_location_type": "none",
        "service_domain": "script",
        "mergecontext": "",
        "x": 1120,
        "y": 580,
        "wires": [
            []
        ]
    },
    {
        "id": "a51f3f1380d4560f",
        "type": "api-call-service",
        "z": "7b83b20cb732bf2a",
        "name": "Activate Home Mode",
        "server": "12135e641a9670e0",
        "version": 5,
        "debugenabled": false,
        "service": "turn_on",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "input_boolean.home_mode"
        ],
        "data": "",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "output_location": "",
        "output_location_type": "none",
        "service_domain": "script",
        "mergecontext": "",
        "x": 1120,
        "y": 620,
        "wires": [
            []
        ]
    },
    {
        "id": "6937a4c2d666c11a",
        "type": "api-call-service",
        "z": "7b83b20cb732bf2a",
        "name": "Activate vacation mode",
        "server": "12135e641a9670e0",
        "version": 5,
        "debugenabled": false,
        "service": "turn_on",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "input_boolean.vacation_mode"
        ],
        "data": "",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "output_location": "",
        "output_location_type": "none",
        "service_domain": "script",
        "mergecontext": "",
        "x": 1130,
        "y": 660,
        "wires": [
            []
        ]
    },
    {
        "id": "2bc5aaafd00484a9",
        "type": "debug",
        "z": "7b83b20cb732bf2a",
        "name": "Borte",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1070,
        "y": 700,
        "wires": []
    },
    {
        "id": "9c6e25d2459a7360",
        "type": "debug",
        "z": "7b83b20cb732bf2a",
        "name": "Natt",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1070,
        "y": 740,
        "wires": []
    },
    {
        "id": "de95f458c34df77c",
        "type": "debug",
        "z": "7b83b20cb732bf2a",
        "name": "Hjemme",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1080,
        "y": 780,
        "wires": []
    },
    {
        "id": "bae87d872ef89b9e",
        "type": "debug",
        "z": "7b83b20cb732bf2a",
        "name": "Ferie",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1070,
        "y": 820,
        "wires": []
    },
    {
        "id": "53eb89dedc94539c",
        "type": "debug",
        "z": "7b83b20cb732bf2a",
        "name": "debug 5",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 780,
        "y": 520,
        "wires": []
    },
    {
        "id": "caa5f4b99f7da5b6",
        "type": "debug",
        "z": "7b83b20cb732bf2a",
        "name": "debug 6",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 940,
        "y": 300,
        "wires": []
    },
    {
        "id": "12135e641a9670e0",
        "type": "server",
        "name": "Home Assistant",
        "version": 5,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": "at: ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "h23",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": true
    }
]

So I am working on this flow to set a mode in home assistant when Home assistant and node red starts up. Since it must only happen at startup if power has been gone I need to store the value and collect it when node red starts up. Here is what I am currently at.

Realised I got my get memory node wrong, but still need it to pass through the topic as well.

[
    {
        "id": "4b50e7b09b5168a0",
        "type": "change",
        "z": "7b83b20cb732bf2a",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "#:(file)::modes",
                "tot": "flow"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 560,
        "y": 580,
        "wires": [
            [
                "53eb89dedc94539c"
            ]
        ]
    }
]

Is the pointer in this thread to different context storage options relevant here?

Maybe, but anyway I found a solution that works fine for me.

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