Record real world activity for playback as Virtual Occupancy

Hi

I’ve found a way to record actual device usage (for any given time period) and store it as a sequence for playback as Virtual Occupancy.

Is anyone interested?


Thanks for the interest. @KidSquid @opus @glhopital


I’m using a Sequence recorder in NodeRed, monitoring all the events I want to capture from openHAB2, for 4000 events or 18 hours (whichever occurs first)

The capture is saved to a text file for archiving and so that I can edit it and paste the file into an Inject or Change Node. (the later being if I want an openHAB2 Item to load a sequence)
As well as being injected into the player node.
(remove the Wire between the recorder and the player, if you don’t want to inject the newly recorded sequence straight away and keep the two processes isolated)

The Player node can be started at a similar time on another day to imitate occupancy.

There’s no reason why multiple days could not be captured and each sequence be injected into the player node at will.
(with the same sequence name or different, just remember to adjust the Play, Stop & Remove nodes accordingly)

(Or capture one day and edit the resulting file’s delay times)

So far…

I have captured

  • OnOff
  • HSL
  • Numbers (Percentages, Target Temperatures, Scene Choices, Volumes etc)
  • Strings (Heating Modes, URLs etc)

According to the sequencer how to, there is no limit as to what each Step (Sequencer Topic) state can be, so URLs, Radio station, Sound Files paths etc etc could be played back through the course of the sequence.

There is a very cunning way to get the sequence to loop, or retriggered.
I am going to be using this to create animated scenes. - (I’ll post another How-To for that)


Here are the details…

I’m using NodeRed, with this sequencer node set. -

node-red-contrib-sequencer


You will see from the following that I needed to create an openHAB IN node for each Item I wanted to capture the value from, with it’s “Item name” moved to the NodeRed Topic and the State remaining in the main Payload.

Once a record session is completed, the sequence is automatically loaded into the player node.

The output of the Player node is then filtered so that the Payload of each “Topic” (Item name) is send out to a corresponding openHAB OUT node.

The hardest part of this is painstakingly creating the IN Nodes, Topic Filter & OUT nodes correctly.

My example sequencer looks like this -

Here is the formatted Flow if you want to simply paste it in and play around with it.

Record_House_Events.nodered_flow.txt (28.2 KB)

[
    {
        "id": "f8c32e2f.83358",
        "type": "debug",
        "z": "c937c2f9.a66fc",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 990,
        "y": 680,
        "wires": []
    },
    {
        "id": "26975a3.ca968a6",
        "type": "recorder",
        "z": "c937c2f9.a66fc",
        "name": "Recorder node",
        "maxElements": "4000",
        "maxDuration": "1080",
        "startImmediately": false,
        "x": 800,
        "y": 640,
        "wires": [
            [
                "f8c32e2f.83358",
                "a8455fd3.b132c",
                "73afea67.eebac4"
            ]
        ]
    },
    {
        "id": "e47bc23d.bf4e",
        "type": "change",
        "z": "c937c2f9.a66fc",
        "name": "payload -> start",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "start",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 740,
        "y": 260,
        "wires": [
            [
                "26975a3.ca968a6"
            ]
        ]
    },
    {
        "id": "25273c9.7f1c4c4",
        "type": "change",
        "z": "c937c2f9.a66fc",
        "name": "payload -> stop",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "stop",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 740,
        "y": 360,
        "wires": [
            [
                "26975a3.ca968a6"
            ]
        ]
    },
    {
        "id": "41e4a750.58e6a8",
        "type": "inject",
        "z": "c937c2f9.a66fc",
        "name": "Stop Recording MyRecord1",
        "topic": "",
        "payload": "MyRecord1",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 500,
        "y": 360,
        "wires": [
            [
                "25273c9.7f1c4c4"
            ]
        ]
    },
    {
        "id": "76e9606b.4840e",
        "type": "inject",
        "z": "c937c2f9.a66fc",
        "name": "Start Recording MyRecord1",
        "topic": "",
        "payload": "MyRecord1",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 500,
        "y": 260,
        "wires": [
            [
                "e47bc23d.bf4e"
            ]
        ]
    },
    {
        "id": "6cc3d13c.2d976",
        "type": "openhab2-in",
        "z": "c937c2f9.a66fc",
        "name": "Dining Room Light",
        "controller": "deaa963.282a968",
        "itemname": "DiningRoom",
        "x": 110,
        "y": 560,
        "wires": [
            [
                "87687cf8.9fd63"
            ],
            []
        ]
    },
    {
        "id": "87687cf8.9fd63",
        "type": "change",
        "z": "c937c2f9.a66fc",
        "name": "Filter unwanted properties",
        "rules": [
            {
                "t": "delete",
                "p": "topic",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 490,
        "y": 620,
        "wires": [
            [
                "f86484f7.3d09e8"
            ]
        ]
    },
    {
        "id": "f86484f7.3d09e8",
        "type": "change",
        "z": "c937c2f9.a66fc",
        "name": "",
        "rules": [
            {
                "t": "move",
                "p": "item",
                "pt": "msg",
                "to": "topic",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 520,
        "y": 680,
        "wires": [
            [
                "26975a3.ca968a6"
            ]
        ]
    },
    {
        "id": "eab74a39.2a9548",
        "type": "openhab2-in",
        "z": "c937c2f9.a66fc",
        "name": "TV Room Light",
        "controller": "deaa963.282a968",
        "itemname": "TVRoomMainLight",
        "x": 100,
        "y": 500,
        "wires": [
            [
                "87687cf8.9fd63"
            ],
            []
        ]
    },
    {
        "id": "a8455fd3.b132c",
        "type": "player",
        "z": "c937c2f9.a66fc",
        "name": "Player node",
        "runOnLoad": false,
        "x": 1310,
        "y": 1540,
        "wires": [
            [
                "49e10b4b.20a654",
                "82e12cc7.073"
            ]
        ]
    },
    {
        "id": "49e10b4b.20a654",
        "type": "debug",
        "z": "c937c2f9.a66fc",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 1490,
        "y": 1540,
        "wires": []
    },
    {
        "id": "82e12cc7.073",
        "type": "switch",
        "z": "c937c2f9.a66fc",
        "name": "Divide up Topics",
        "property": "topic",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "DiningRoom",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "KitchenMainLX",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "TVRoomMainLight",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "HallwayLight",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "LoungeMainLight",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "KitchenMainLX",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "ConservatoryLX",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "DSToilet",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "ToiletUP",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "LandingLX",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "MasterBedroomLight",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "bathroomcolour",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "bath_WHT",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 13,
        "x": 1200,
        "y": 660,
        "wires": [
            [
                "54421636.46f6f8"
            ],
            [
                "ff182d87.f547f"
            ],
            [
                "b5d924a8.73a588"
            ],
            [
                "e1773030.75a3"
            ],
            [
                "b044f185.3ba4c"
            ],
            [
                "4e5249c6.cfb658"
            ],
            [
                "b4f5cbeb.f12878"
            ],
            [
                "cb4f5099.a289c"
            ],
            [
                "96ee0f10.8a961"
            ],
            [
                "5a6ab80e.04eb68"
            ],
            [
                "e366b6b.e515a48"
            ],
            [
                "f7bbcd8f.7dd74"
            ],
            [
                "6d6c9795.4a2438"
            ]
        ]
    },
    {
        "id": "6abbd877.646e18",
        "type": "change",
        "z": "c937c2f9.a66fc",
        "name": "payload -> remove",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "remove",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 930,
        "y": 1600,
        "wires": [
            [
                "a8455fd3.b132c"
            ]
        ]
    },
    {
        "id": "f2d25053.6daab",
        "type": "change",
        "z": "c937c2f9.a66fc",
        "name": "payload -> stop",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "stop",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 920,
        "y": 1560,
        "wires": [
            [
                "a8455fd3.b132c"
            ]
        ]
    },
    {
        "id": "84c6f21.4309a1",
        "type": "change",
        "z": "c937c2f9.a66fc",
        "name": "payload -> pause",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "pause",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 930,
        "y": 1520,
        "wires": [
            [
                "a8455fd3.b132c"
            ]
        ]
    },
    {
        "id": "128255d1.25ad7a",
        "type": "change",
        "z": "c937c2f9.a66fc",
        "name": "payload -> play",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "play",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 920,
        "y": 1480,
        "wires": [
            [
                "a8455fd3.b132c"
            ]
        ]
    },
    {
        "id": "86e4e538.cec068",
        "type": "change",
        "z": "c937c2f9.a66fc",
        "name": "payload -> sequence",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "sequence",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 940,
        "y": 1220,
        "wires": [
            [
                "a8455fd3.b132c"
            ]
        ]
    },
    {
        "id": "4d50ddb3.1efdb4",
        "type": "inject",
        "z": "c937c2f9.a66fc",
        "name": "Enumerate",
        "topic": "",
        "payload": "",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 680,
        "y": 1720,
        "wires": [
            [
                "28f0a3c7.610c5c"
            ]
        ]
    },
    {
        "id": "28f0a3c7.610c5c",
        "type": "change",
        "z": "c937c2f9.a66fc",
        "name": "payload -> enumerate",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "enumerate",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 940,
        "y": 1720,
        "wires": [
            [
                "a8455fd3.b132c"
            ]
        ]
    },
    {
        "id": "37c92aa5.9b02e6",
        "type": "inject",
        "z": "c937c2f9.a66fc",
        "name": "Play - A",
        "topic": "",
        "payload": "MyRecord1",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 670,
        "y": 1480,
        "wires": [
            [
                "128255d1.25ad7a"
            ]
        ]
    },
    {
        "id": "e67207f2.b08ff8",
        "type": "inject",
        "z": "c937c2f9.a66fc",
        "name": "Pause - A",
        "topic": "",
        "payload": "MyRecord1",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 680,
        "y": 1520,
        "wires": [
            [
                "84c6f21.4309a1"
            ]
        ]
    },
    {
        "id": "bd350ed9.5f61c",
        "type": "inject",
        "z": "c937c2f9.a66fc",
        "name": "Stop - A",
        "topic": "",
        "payload": "MyRecord1",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 680,
        "y": 1560,
        "wires": [
            [
                "f2d25053.6daab"
            ]
        ]
    },
    {
        "id": "3aa126c4.91639a",
        "type": "inject",
        "z": "c937c2f9.a66fc",
        "name": "Remove - A",
        "topic": "",
        "payload": "MyRecord1",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 690,
        "y": 1600,
        "wires": [
            [
                "6abbd877.646e18"
            ]
        ]
    },
    {
        "id": "54421636.46f6f8",
        "type": "openhab2-out",
        "z": "c937c2f9.a66fc",
        "name": "Dining Room",
        "controller": "deaa963.282a968",
        "itemname": "DiningRoom",
        "topic": "ItemCommand",
        "payload": "",
        "x": 1570,
        "y": 360,
        "wires": [
            []
        ]
    },
    {
        "id": "ff182d87.f547f",
        "type": "openhab2-out",
        "z": "c937c2f9.a66fc",
        "name": "Kitchen Main Light",
        "controller": "deaa963.282a968",
        "itemname": "KitchenMainLX",
        "topic": "ItemCommand",
        "payload": "",
        "x": 1590,
        "y": 420,
        "wires": [
            []
        ]
    },
    {
        "id": "b5d924a8.73a588",
        "type": "openhab2-out",
        "z": "c937c2f9.a66fc",
        "name": "TVRoomMainLight",
        "controller": "deaa963.282a968",
        "itemname": "TVRoomMainLight",
        "topic": "ItemCommand",
        "payload": "",
        "x": 1590,
        "y": 480,
        "wires": [
            []
        ]
    },
    {
        "id": "d9bc945d.3a5ce8",
        "type": "file",
        "z": "c937c2f9.a66fc",
        "name": "",
        "filename": "/etc/openhab2/recorded_sequences.nodered",
        "appendNewline": true,
        "createDir": true,
        "overwriteFile": "false",
        "encoding": "none",
        "x": 490,
        "y": 1020,
        "wires": [
            [
                "7e1adfb2.2cbd8"
            ]
        ]
    },
    {
        "id": "3b00dad9.7b2d36",
        "type": "inject",
        "z": "c937c2f9.a66fc",
        "name": "",
        "topic": "Test",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 480,
        "y": 960,
        "wires": [
            [
                "d9bc945d.3a5ce8"
            ]
        ]
    },
    {
        "id": "7e1adfb2.2cbd8",
        "type": "debug",
        "z": "c937c2f9.a66fc",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "x": 450,
        "y": 1080,
        "wires": []
    },
    {
        "id": "73afea67.eebac4",
        "type": "change",
        "z": "c937c2f9.a66fc",
        "name": "sequence -> Payload",
        "rules": [
            {
                "t": "move",
                "p": "sequence",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 480,
        "y": 920,
        "wires": [
            [
                "d9bc945d.3a5ce8"
            ]
        ]
    },
    {
        "id": "aac54e88.dd824",
        "type": "openhab2-in",
        "z": "c937c2f9.a66fc",
        "name": "Hallway Light",
        "controller": "deaa963.282a968",
        "itemname": "HallwayLight",
        "x": 92,
        "y": 400,
        "wires": [
            [
                "87687cf8.9fd63"
            ],
            []
        ]
    },
    {
        "id": "7f3ce66c.032a58",
        "type": "openhab2-in",
        "z": "c937c2f9.a66fc",
        "name": "Front Room Light",
        "controller": "deaa963.282a968",
        "itemname": "LoungeMainLight",
        "x": 100,
        "y": 449,
        "wires": [
            [
                "87687cf8.9fd63"
            ],
            []
        ]
    },
    {
        "id": "af427210.05056",
        "type": "openhab2-in",
        "z": "c937c2f9.a66fc",
        "name": "Kitchen Light",
        "controller": "deaa963.282a968",
        "itemname": "KitchenMainLX",
        "x": 90,
        "y": 620,
        "wires": [
            [
                "87687cf8.9fd63"
            ],
            []
        ]
    },
    {
        "id": "582aaa49.ddbb94",
        "type": "openhab2-in",
        "z": "c937c2f9.a66fc",
        "name": "Conservatory Light",
        "controller": "deaa963.282a968",
        "itemname": "ConservatoryLX",
        "x": 110,
        "y": 680,
        "wires": [
            [
                "87687cf8.9fd63"
            ],
            []
        ]
    },
    {
        "id": "5aee8cce.2fdb64",
        "type": "openhab2-in",
        "z": "c937c2f9.a66fc",
        "name": "Downstairs Toilet Light",
        "controller": "deaa963.282a968",
        "itemname": "DSToilet",
        "x": 120,
        "y": 740,
        "wires": [
            [
                "87687cf8.9fd63"
            ],
            []
        ]
    },
    {
        "id": "dff66dd4.0b5b6",
        "type": "openhab2-in",
        "z": "c937c2f9.a66fc",
        "name": "Upstairs Toilet  Light",
        "controller": "deaa963.282a968",
        "itemname": "ToiletUP",
        "x": 110,
        "y": 820,
        "wires": [
            [
                "87687cf8.9fd63"
            ],
            []
        ]
    },
    {
        "id": "45ea10eb.d38ff",
        "type": "openhab2-in",
        "z": "c937c2f9.a66fc",
        "name": "Master Bedroom Light",
        "controller": "deaa963.282a968",
        "itemname": "MasterBedroomLight",
        "x": 120,
        "y": 940,
        "wires": [
            [
                "87687cf8.9fd63"
            ],
            []
        ]
    },
    {
        "id": "c12d87df.b33ce8",
        "type": "openhab2-in",
        "z": "c937c2f9.a66fc",
        "name": "Landing Light",
        "controller": "deaa963.282a968",
        "itemname": "LandingLX",
        "x": 90,
        "y": 880,
        "wires": [
            [
                "87687cf8.9fd63"
            ],
            []
        ]
    },
    {
        "id": "8b8b9b72.93f798",
        "type": "openhab2-in",
        "z": "c937c2f9.a66fc",
        "name": "Bathroom RGB",
        "controller": "deaa963.282a968",
        "itemname": "bathroomcolour",
        "x": 100,
        "y": 1000,
        "wires": [
            [
                "87687cf8.9fd63"
            ],
            []
        ]
    },
    {
        "id": "1f323839.c64248",
        "type": "openhab2-in",
        "z": "c937c2f9.a66fc",
        "name": "Bathroom Wht Light",
        "controller": "deaa963.282a968",
        "itemname": "Bath_WHT",
        "x": 110,
        "y": 1060,
        "wires": [
            [
                "87687cf8.9fd63"
            ],
            []
        ]
    },
    {
        "id": "e1773030.75a3",
        "type": "openhab2-out",
        "z": "c937c2f9.a66fc",
        "name": "Hallway Light",
        "controller": "deaa963.282a968",
        "itemname": "HallwayLight",
        "topic": "ItemCommand",
        "payload": "",
        "x": 1570,
        "y": 540,
        "wires": [
            []
        ]
    },
    {
        "id": "b044f185.3ba4c",
        "type": "openhab2-out",
        "z": "c937c2f9.a66fc",
        "name": "Front Room Main Light",
        "controller": "deaa963.282a968",
        "itemname": "LoungeMainLight",
        "topic": "ItemCommand",
        "payload": "",
        "x": 1600,
        "y": 580,
        "wires": [
            []
        ]
    },
    {
        "id": "4e5249c6.cfb658",
        "type": "openhab2-out",
        "z": "c937c2f9.a66fc",
        "name": "Kitchen Light",
        "controller": "deaa963.282a968",
        "itemname": "KitchenMainLX",
        "topic": "ItemCommand",
        "payload": "",
        "x": 1570,
        "y": 640,
        "wires": [
            []
        ]
    },
    {
        "id": "b4f5cbeb.f12878",
        "type": "openhab2-out",
        "z": "c937c2f9.a66fc",
        "name": "Conservatory Light",
        "controller": "deaa963.282a968",
        "itemname": "ConservatoryLX",
        "topic": "ItemCommand",
        "payload": "",
        "x": 1590,
        "y": 680,
        "wires": [
            []
        ]
    },
    {
        "id": "cb4f5099.a289c",
        "type": "openhab2-out",
        "z": "c937c2f9.a66fc",
        "name": "Downstairs Toilet Light",
        "controller": "deaa963.282a968",
        "itemname": "DSToilet",
        "topic": "ItemCommand",
        "payload": "",
        "x": 1600,
        "y": 740,
        "wires": [
            []
        ]
    },
    {
        "id": "96ee0f10.8a961",
        "type": "openhab2-out",
        "z": "c937c2f9.a66fc",
        "name": "Upstairs Toilet",
        "controller": "deaa963.282a968",
        "itemname": "ToiletUP",
        "topic": "ItemCommand",
        "payload": "",
        "x": 1580,
        "y": 800,
        "wires": [
            []
        ]
    },
    {
        "id": "5a6ab80e.04eb68",
        "type": "openhab2-out",
        "z": "c937c2f9.a66fc",
        "name": "Landing Light",
        "controller": "deaa963.282a968",
        "itemname": "LandingLX",
        "topic": "ItemCommand",
        "payload": "",
        "x": 1580,
        "y": 860,
        "wires": [
            []
        ]
    },
    {
        "id": "e366b6b.e515a48",
        "type": "openhab2-out",
        "z": "c937c2f9.a66fc",
        "name": "Master Bedroom Light",
        "controller": "deaa963.282a968",
        "itemname": "MasterBedroomLight",
        "topic": "ItemCommand",
        "payload": "",
        "x": 1600,
        "y": 920,
        "wires": [
            []
        ]
    },
    {
        "id": "f7bbcd8f.7dd74",
        "type": "openhab2-out",
        "z": "c937c2f9.a66fc",
        "name": "Bathroom RGB",
        "controller": "deaa963.282a968",
        "itemname": "bathroomcolour",
        "topic": "ItemCommand",
        "payload": "",
        "x": 1580,
        "y": 980,
        "wires": [
            []
        ]
    },
    {
        "id": "6d6c9795.4a2438",
        "type": "openhab2-out",
        "z": "c937c2f9.a66fc",
        "name": "Bathroom White",
        "controller": "deaa963.282a968",
        "itemname": "Bath_WHT",
        "topic": "ItemCommand",
        "payload": "",
        "x": 1580,
        "y": 1040,
        "wires": [
            []
        ]
    },
    {
        "id": "9b298287.ec4f6",
        "type": "comment",
        "z": "c937c2f9.a66fc",
        "name": "Record 4000 steps or 18 hours",
        "info": "Adjust the settings of the record node",
        "x": 850,
        "y": 600,
        "wires": []
    },
    {
        "id": "d4056dd9.1f90d",
        "type": "comment",
        "z": "c937c2f9.a66fc",
        "name": "Save the Sequence to a File",
        "info": "",
        "x": 500,
        "y": 860,
        "wires": []
    },
    {
        "id": "f9e3002.f878e",
        "type": "inject",
        "z": "c937c2f9.a66fc",
        "name": "Load Sequence A",
        "topic": "",
        "payload": "{Sequence String}",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 690,
        "y": 1220,
        "wires": [
            [
                "86e4e538.cec068"
            ]
        ]
    },
    {
        "id": "bbfecbd5.997748",
        "type": "inject",
        "z": "c937c2f9.a66fc",
        "name": "Load Sequence B",
        "topic": "",
        "payload": "{Sequence String}",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 690,
        "y": 1260,
        "wires": [
            [
                "86e4e538.cec068"
            ]
        ]
    },
    {
        "id": "eddf34df.347748",
        "type": "inject",
        "z": "c937c2f9.a66fc",
        "name": "Load Sequence C",
        "topic": "",
        "payload": "{Sequence String}",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 690,
        "y": 1300,
        "wires": [
            []
        ]
    },
    {
        "id": "dc5ee449.b7c598",
        "type": "change",
        "z": "c937c2f9.a66fc",
        "name": "Play A",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "MyRecord1",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 490,
        "y": 1480,
        "wires": [
            [
                "128255d1.25ad7a"
            ]
        ]
    },
    {
        "id": "6c998b27.51e494",
        "type": "openhab2-in",
        "z": "c937c2f9.a66fc",
        "name": "openHAB2 Play A Trigger",
        "controller": "",
        "itemname": "",
        "x": 230,
        "y": 1480,
        "wires": [
            [
                "dc5ee449.b7c598"
            ],
            []
        ]
    },
    {
        "id": "4bbfc6bd.47bb38",
        "type": "change",
        "z": "c937c2f9.a66fc",
        "name": "Stop A",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "MyRecord1",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 490,
        "y": 1560,
        "wires": [
            [
                "f2d25053.6daab"
            ]
        ]
    },
    {
        "id": "e7d86249.26b56",
        "type": "openhab2-in",
        "z": "c937c2f9.a66fc",
        "name": "openHAB2 Stop A Trigger",
        "controller": "",
        "itemname": "",
        "x": 230,
        "y": 1560,
        "wires": [
            [
                "4bbfc6bd.47bb38"
            ],
            []
        ]
    },
    {
        "id": "deaa963.282a968",
        "type": "openhab2-controller",
        "z": "",
        "name": "OpenHAB2 Home",
        "protocol": "http",
        "host": "127.0.0.1",
        "port": "8080",
        "path": "",
        "username": "",
        "password": ""
    }
]

Sounds very interesting…I’ve seen systems that offer a “vacation mode” which offers a very similar playback. Would you be able to include an option for randomizing or some kind of offset so that the same light doesn’t turn off or on at the same time the script is played back? If you were out of the house for a week or so, you would want some variety.

Squid

Are you talking about something like That?

Not caldav, I couldn’t work out how to get that working.

I’m working on the text to explain this right now…

1 Like

I’ll create another How-To thread tomorrow, but for now, here’s the basics of the looping sequencer I’ve built to start testing with.

The trick was to add a tiny delay in the last step to reset the player.
Thanks to TedStriker for that one :smile:

8 step looping sequencer.nodered_flow.txt (18.2 KB)

Which contains this Test Sequence - (Which must be inputted as one continuous line, without breaks.

{"name":"EightTopics","seq":[{"data":{"topic":"one","payload":50},"delay":0},{"data":{"topic":"two","payload":50},"delay":1000},{"data":{"topic":"three","payload":"ON"},"delay":1000},{"data":{"topic":"four","payload":0},"delay":1000},{"data":{"topic":"five","payload":50},"delay":1000},{"data":{"topic":"six","payload":50},"delay":1000},{"data":{"topic":"seven","payload":"ON"},"delay":1000},{"data":{"topic":"eight","payload":75},"delay":1000},{"data":{"topic":"play","payload":"EightTopics"},"delay":1000}]}

Here’s the complete flow to drop into NodeRed

[
    {
        "id": "5c8872e.2f6de8c",
        "type": "tab",
        "label": "Sequencer for Bathroom",
        "disabled": false,
        "info": ""
    },
    {
        "id": "761aaa4f.3d5ec4",
        "type": "debug",
        "z": "5c8872e.2f6de8c",
        "name": "",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "x": 2010,
        "y": 160,
        "wires": []
    },
    {
        "id": "773ab71e.11ad48",
        "type": "debug",
        "z": "5c8872e.2f6de8c",
        "name": "",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "x": 2010,
        "y": 220,
        "wires": []
    },
    {
        "id": "1e997440.543a4c",
        "type": "debug",
        "z": "5c8872e.2f6de8c",
        "name": "",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "x": 2010,
        "y": 280,
        "wires": []
    },
    {
        "id": "b473b9bb.ec28d8",
        "type": "debug",
        "z": "5c8872e.2f6de8c",
        "name": "",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "x": 2010,
        "y": 340,
        "wires": []
    },
    {
        "id": "180f3f66.b34031",
        "type": "debug",
        "z": "5c8872e.2f6de8c",
        "name": "",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "x": 2010,
        "y": 400,
        "wires": []
    },
    {
        "id": "120ae77d.da6449",
        "type": "debug",
        "z": "5c8872e.2f6de8c",
        "name": "",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "x": 2010,
        "y": 460,
        "wires": []
    },
    {
        "id": "ade9602.abb79a",
        "type": "debug",
        "z": "5c8872e.2f6de8c",
        "name": "",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "x": 2010,
        "y": 520,
        "wires": []
    },
    {
        "id": "a54d625.f7018a",
        "type": "debug",
        "z": "5c8872e.2f6de8c",
        "name": "",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "x": 2010,
        "y": 580,
        "wires": []
    },
    {
        "id": "2414224a.18b02e",
        "type": "debug",
        "z": "5c8872e.2f6de8c",
        "name": "",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "x": 2010,
        "y": 760,
        "wires": []
    },
    {
        "id": "8c26ff45.4011",
        "type": "switch",
        "z": "5c8872e.2f6de8c",
        "name": "Divide up Topics",
        "property": "topic",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "one",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "two",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "three",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "four",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "five",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "six",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "seven",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "eight",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "play",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 9,
        "x": 1380,
        "y": 300,
        "wires": [
            [
                "761aaa4f.3d5ec4"
            ],
            [
                "773ab71e.11ad48"
            ],
            [
                "1e997440.543a4c"
            ],
            [
                "b473b9bb.ec28d8"
            ],
            [
                "180f3f66.b34031"
            ],
            [
                "120ae77d.da6449"
            ],
            [
                "ade9602.abb79a"
            ],
            [
                "a54d625.f7018a"
            ],
            [
                "2414224a.18b02e",
                "f474884d.064f98"
            ]
        ]
    },
    {
        "id": "25c6251c.c3922a",
        "type": "inject",
        "z": "5c8872e.2f6de8c",
        "name": "Load Eight Topics and repeat",
        "topic": "",
        "payload": "{\"name\":\"EightTopics\",\"seq\":[{\"data\":{\"topic\":\"one\",\"payload\":50},\"delay\":0},{\"data\":{\"topic\":\"two\",\"payload\":50},\"delay\":1000},{\"data\":{\"topic\":\"three\",\"payload\":\"ON\"},\"delay\":1000},{\"data\":{\"topic\":\"four\",\"payload\":0},\"delay\":1000},{\"data\":{\"topic\":\"five\",\"payload\":50},\"delay\":1000},{\"data\":{\"topic\":\"six\",\"payload\":50},\"delay\":1000},{\"data\":{\"topic\":\"seven\",\"payload\":\"ON\"},\"delay\":1000},{\"data\":{\"topic\":\"eight\",\"payload\":75},\"delay\":1000},{\"data\":{\"topic\":\"play\",\"payload\":\"EightTopics\"},\"delay\":1000}]}",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 920,
        "y": 340,
        "wires": [
            [
                "2afe12e6.c3284e"
            ]
        ]
    },
    {
        "id": "7fc853ac.d1f1bc",
        "type": "inject",
        "z": "5c8872e.2f6de8c",
        "name": "Play",
        "topic": "",
        "payload": "EightTopics",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 870,
        "y": 420,
        "wires": [
            [
                "5a8b352.a5178cc"
            ]
        ]
    },
    {
        "id": "c8978b25.6b0988",
        "type": "inject",
        "z": "5c8872e.2f6de8c",
        "name": "Stop",
        "topic": "",
        "payload": "EightTopics",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 870,
        "y": 780,
        "wires": [
            [
                "6cd81c74.de4944",
                "e758178e.ed2c08"
            ]
        ]
    },
    {
        "id": "df8abad1.cae8c8",
        "type": "player",
        "z": "5c8872e.2f6de8c",
        "name": "Player node",
        "runOnLoad": true,
        "x": 1430,
        "y": 620,
        "wires": [
            [
                "87839721.b5d738",
                "8c26ff45.4011"
            ]
        ]
    },
    {
        "id": "87839721.b5d738",
        "type": "debug",
        "z": "5c8872e.2f6de8c",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 1570,
        "y": 660,
        "wires": []
    },
    {
        "id": "2afe12e6.c3284e",
        "type": "change",
        "z": "5c8872e.2f6de8c",
        "name": "payload -> sequence",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "sequence",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1160,
        "y": 520,
        "wires": [
            [
                "df8abad1.cae8c8"
            ]
        ]
    },
    {
        "id": "5a8b352.a5178cc",
        "type": "change",
        "z": "5c8872e.2f6de8c",
        "name": "payload -> play",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "play",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1140,
        "y": 560,
        "wires": [
            [
                "df8abad1.cae8c8"
            ]
        ]
    },
    {
        "id": "535514f8.b3f0ac",
        "type": "change",
        "z": "5c8872e.2f6de8c",
        "name": "payload -> pause",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "pause",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1150,
        "y": 600,
        "wires": [
            [
                "df8abad1.cae8c8"
            ]
        ]
    },
    {
        "id": "6cd81c74.de4944",
        "type": "change",
        "z": "5c8872e.2f6de8c",
        "name": "payload -> stop",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "stop",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1140,
        "y": 640,
        "wires": [
            [
                "df8abad1.cae8c8"
            ]
        ]
    },
    {
        "id": "46cbb2f3.467f8c",
        "type": "change",
        "z": "5c8872e.2f6de8c",
        "name": "payload -> remove",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "remove",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1150,
        "y": 680,
        "wires": [
            [
                "df8abad1.cae8c8"
            ]
        ]
    },
    {
        "id": "681867e8.883a08",
        "type": "openhab2-events",
        "z": "5c8872e.2f6de8c",
        "name": "openHAB events in House",
        "controller": "deaa963.282a968",
        "itemname": "",
        "x": 270,
        "y": 500,
        "wires": [
            [
                "ea0af200.86f1a"
            ]
        ]
    },
    {
        "id": "ea0af200.86f1a",
        "type": "function",
        "z": "5c8872e.2f6de8c",
        "name": "Show Flow temp sensor",
        "func": "var event = msg.payload.event;\nvar channel = msg.payload.channel;\nvar newMsg = { payload: msg.payload.event };\nvar button = \"velbus:vmb7in:c5053467:0B:input#CH1\"\n\nif  (channel === button )  {\n\tif (event === \"PRESSED\") {\n\t\treturn [newMsg, null, null];\n\t}\n\tif (event === \"LONG_PRESSED\") {\n\t\treturn [null, newMsg, null];\n\t}\n\tif (event === \"RELEASED\") {\n\t\treturn [null, null, newMsg];\n\t}\n}\nreturn null;\n",
        "outputs": 3,
        "noerr": 0,
        "x": 310,
        "y": 580,
        "wires": [
            [
                "ffbb28fb.543d28",
                "88de9207.30699"
            ],
            [
                "22e2b06f.83de3"
            ],
            [
                "db65300c.9e274",
                "250d796e.fea556"
            ]
        ],
        "inputLabels": [
            "Raw Events from openHAB2"
        ],
        "outputLabels": [
            "PRESSED",
            "LONG_PRESSED",
            "RELEASED"
        ]
    },
    {
        "id": "ffbb28fb.543d28",
        "type": "debug",
        "z": "5c8872e.2f6de8c",
        "name": "",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "x": 570,
        "y": 460,
        "wires": []
    },
    {
        "id": "22e2b06f.83de3",
        "type": "debug",
        "z": "5c8872e.2f6de8c",
        "name": "",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "x": 570,
        "y": 580,
        "wires": []
    },
    {
        "id": "db65300c.9e274",
        "type": "debug",
        "z": "5c8872e.2f6de8c",
        "name": "",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "x": 570,
        "y": 680,
        "wires": []
    },
    {
        "id": "88de9207.30699",
        "type": "change",
        "z": "5c8872e.2f6de8c",
        "name": "Pressed = Load Sequence",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"name\":\"EightTopics\",\"seq\":[{\"data\":{\"topic\":\"one\",\"payload\":50},\"delay\":0},{\"data\":{\"topic\":\"two\",\"payload\":50},\"delay\":1000},{\"data\":{\"topic\":\"three\",\"payload\":\"ON\"},\"delay\":1000},{\"data\":{\"topic\":\"four\",\"payload\":0},\"delay\":1000},{\"data\":{\"topic\":\"five\",\"payload\":50},\"delay\":1000},{\"data\":{\"topic\":\"six\",\"payload\":50},\"delay\":1000},{\"data\":{\"topic\":\"seven\",\"payload\":\"ON\"},\"delay\":1000},{\"data\":{\"topic\":\"eight\",\"payload\":75},\"delay\":1000},{\"data\":{\"topic\":\"play\",\"payload\":\"EightTopics\"},\"delay\":1000}]}",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 620,
        "y": 520,
        "wires": [
            [
                "2afe12e6.c3284e"
            ]
        ]
    },
    {
        "id": "250d796e.fea556",
        "type": "change",
        "z": "5c8872e.2f6de8c",
        "name": "Released to STOP",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "EightTopics",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 590,
        "y": 640,
        "wires": [
            [
                "6cd81c74.de4944",
                "e758178e.ed2c08"
            ]
        ]
    },
    {
        "id": "6e400a78.97f154",
        "type": "comment",
        "z": "5c8872e.2f6de8c",
        "name": "Restart Sequence",
        "info": "",
        "x": 2030,
        "y": 680,
        "wires": []
    },
    {
        "id": "a538089f.5ac6b8",
        "type": "comment",
        "z": "5c8872e.2f6de8c",
        "name": "Set devices during the sequence",
        "info": "",
        "x": 1990,
        "y": 120,
        "wires": []
    },
    {
        "id": "f474884d.064f98",
        "type": "delay",
        "z": "5c8872e.2f6de8c",
        "name": "",
        "pauseType": "delay",
        "timeout": "1",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 2020,
        "y": 800,
        "wires": [
            [
                "5a8b352.a5178cc"
            ]
        ]
    },
    {
        "id": "e758178e.ed2c08",
        "type": "change",
        "z": "5c8872e.2f6de8c",
        "name": "OFF Sequence",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"name\":\"OFF\",\"seq\":[{\"data\":{\"topic\":\"one\",\"payload\":0},\"delay\":0},{\"data\":{\"topic\":\"two\",\"payload\":0},\"delay\":1000},{\"data\":{\"topic\":\"three\",\"payload\":\"OFF\"},\"delay\":1000},{\"data\":{\"topic\":\"four\",\"payload\":0},\"delay\":1000},{\"data\":{\"topic\":\"five\",\"payload\":0},\"delay\":1000},{\"data\":{\"topic\":\"six\",\"payload\":0},\"delay\":1000},{\"data\":{\"topic\":\"seven\",\"payload\":\"OFF\"},\"delay\":1000},{\"data\":{\"topic\":\"eight\",\"payload\":0},\"delay\":1000}]}",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 840,
        "y": 600,
        "wires": [
            [
                "1bae37.c4b531c9"
            ]
        ]
    },
    {
        "id": "1bae37.c4b531c9",
        "type": "delay",
        "z": "5c8872e.2f6de8c",
        "name": "",
        "pauseType": "delay",
        "timeout": "50",
        "timeoutUnits": "milliseconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 870,
        "y": 540,
        "wires": [
            [
                "2afe12e6.c3284e"
            ]
        ]
    },
    {
        "id": "deaa963.282a968",
        "type": "openhab2-controller",
        "z": "",
        "name": "OpenHAB2 Home",
        "protocol": "http",
        "host": "127.0.0.1",
        "port": "8080",
        "path": "",
        "username": "",
        "password": ""
    }
]

I read a thread awhile back where the idea was to use light switching pattern gleaned from states pulled from the persistence service. In other words, while you are on vacation, the lights play back the prior week’s switching on and off. Author believed it to be more ‘convincing’ then random pattern.

yeah, thanks @syn Christoph got it, I was at a loss to find it, the 2nd one

1 Like

Can you link to that thread please, so others have a comparison?

Edit: Initial point is here, I think:

For those who want an OH native way that uses persistence to do this see Presence Simulation - #4 by rlkoshak. There are several tutorials that cover doing this with CalDav as well.

It’s pretty much a one liner Rule.

rule "Simulate lights"
when
    Time cron "0 0/5 * * * ?"
then
    if(PresenceSim.state == ON){
        gLights.members.forEach[light | light.sendCommand(light.historicState(now.minusHours(24*7)).state)]
    }
end

That will replay the light states to whatever they were at this same time one week ago.

That was mine. I don’t know that it’s more convincing but it is pretty easy to implement and doesn’t require anything special external beyond persistence which many of us have set up already.

I never turned this into a separate tutorial or DP.

Thanks for posting the later topic. I forgot that the approach was refined quite a bit in that thread. That is probably why I never turned it into a tutorial. By the time we get to Dim’s example it was more other people’s code than mine.

1 Like

I just love how these threads evolve :smile:

Here we have two great options for the same issue.

Look at now - 7 days, or replay a specific sequence.

1 Like