How to save multiple objects to Influx?

I am trying to send multiple items of sensor data, from multiple rooms, to InfluxDB. Trying to do this in a tidy, logical way, I attempted to create a "bucket" of rooms, and within each room, a "bucket" of sensor's data.
ie

The debug shows the result

[
    {
        "id": "a241d72b79d8b1b7",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "3d23ccf9e7a89445",
        "type": "poll-state",
        "z": "a241d72b79d8b1b7",
        "name": "sensor.wiser_lts_temperature_lounge",
        "server": "3cade157397fc070",
        "version": 2,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "updateinterval": "60",
        "updateIntervalType": "num",
        "updateIntervalUnits": "seconds",
        "outputinitially": true,
        "outputonchanged": false,
        "entity_id": "sensor.wiser_lts_temperature_lounge",
        "state_type": "num",
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "x": 270,
        "y": 180,
        "wires": [
            [
                "d44ca4c463fcb953"
            ]
        ]
    },
    {
        "id": "50298066e0c76c73",
        "type": "poll-state",
        "z": "a241d72b79d8b1b7",
        "name": "sensor.wiser_lts_heating_demand_lounge",
        "server": "3cade157397fc070",
        "version": 2,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "updateinterval": "60",
        "updateIntervalType": "num",
        "updateIntervalUnits": "seconds",
        "outputinitially": true,
        "outputonchanged": false,
        "entity_id": "sensor.wiser_lts_heating_demand_lounge",
        "state_type": "num",
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "x": 280,
        "y": 220,
        "wires": [
            [
                "073920eea5a7aa87"
            ]
        ]
    },
    {
        "id": "ab0e97db45fb632c",
        "type": "poll-state",
        "z": "a241d72b79d8b1b7",
        "name": "sensor.wiser_lts_target_temperature_lounge",
        "server": "3cade157397fc070",
        "version": 2,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "updateinterval": "60",
        "updateIntervalType": "num",
        "updateIntervalUnits": "seconds",
        "outputinitially": true,
        "outputonchanged": false,
        "entity_id": "sensor.wiser_lts_target_temperature_lounge",
        "state_type": "num",
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "x": 290,
        "y": 260,
        "wires": [
            [
                "90f45e0b4b22311f"
            ]
        ]
    },
    {
        "id": "32cc53d6853a8b93",
        "type": "poll-state",
        "z": "a241d72b79d8b1b7",
        "name": "sensor.wiser_lts_humidity_lounge",
        "server": "3cade157397fc070",
        "version": 2,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "updateinterval": "60",
        "updateIntervalType": "num",
        "updateIntervalUnits": "seconds",
        "outputinitially": true,
        "outputonchanged": false,
        "entity_id": "sensor.wiser_lts_humidity_lounge",
        "state_type": "num",
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "x": 250,
        "y": 300,
        "wires": [
            [
                "78136dc09bdd906b"
            ]
        ]
    },
    {
        "id": "e0a942bd7c5674d4",
        "type": "join",
        "z": "a241d72b79d8b1b7",
        "name": "",
        "mode": "custom",
        "build": "object",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": false,
        "timeout": "",
        "count": "4",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 750,
        "y": 240,
        "wires": [
            [
                "70718fa6484cd6db"
            ]
        ]
    },
    {
        "id": "91f9c89b347a44a1",
        "type": "debug",
        "z": "a241d72b79d8b1b7",
        "name": "debug 14",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1140,
        "y": 240,
        "wires": []
    },
    {
        "id": "70718fa6484cd6db",
        "type": "function",
        "z": "a241d72b79d8b1b7",
        "name": "Add Topic Room",
        "func": "//msg.payload = Number(msg.payload);\nmsg.topic = \"Lounge\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 920,
        "y": 240,
        "wires": [
            [
                "91f9c89b347a44a1",
                "5be14f9fd7f02627"
            ]
        ]
    },
    {
        "id": "dbdc5c953f6df284",
        "type": "poll-state",
        "z": "a241d72b79d8b1b7",
        "name": "sensor.wiser_lts_temperature_kitchen",
        "server": "3cade157397fc070",
        "version": 2,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "updateinterval": "60",
        "updateIntervalType": "num",
        "updateIntervalUnits": "seconds",
        "outputinitially": true,
        "outputonchanged": false,
        "entity_id": "sensor.wiser_lts_temperature_kitchen",
        "state_type": "num",
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "x": 270,
        "y": 380,
        "wires": [
            [
                "c0b0a5047e59e3b8"
            ]
        ]
    },
    {
        "id": "80cc80b8050b68a1",
        "type": "poll-state",
        "z": "a241d72b79d8b1b7",
        "name": "sensor.wiser_lts_heating_demand_kitchen",
        "server": "3cade157397fc070",
        "version": 2,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "updateinterval": "60",
        "updateIntervalType": "num",
        "updateIntervalUnits": "seconds",
        "outputinitially": true,
        "outputonchanged": false,
        "entity_id": "sensor.wiser_lts_heating_demand_kitchen",
        "state_type": "num",
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "x": 280,
        "y": 420,
        "wires": [
            [
                "3cc93ae90c0546f7"
            ]
        ]
    },
    {
        "id": "2540feb3a4300e9f",
        "type": "poll-state",
        "z": "a241d72b79d8b1b7",
        "name": "sensor.wiser_lts_target_temperature_kitchen",
        "server": "3cade157397fc070",
        "version": 2,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "updateinterval": "60",
        "updateIntervalType": "num",
        "updateIntervalUnits": "seconds",
        "outputinitially": true,
        "outputonchanged": false,
        "entity_id": "sensor.wiser_lts_target_temperature_kitchen",
        "state_type": "num",
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "x": 290,
        "y": 460,
        "wires": [
            [
                "11fd30de50f02e56"
            ]
        ]
    },
    {
        "id": "a993a62a3973e455",
        "type": "join",
        "z": "a241d72b79d8b1b7",
        "name": "",
        "mode": "custom",
        "build": "object",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": false,
        "timeout": "",
        "count": "3",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 750,
        "y": 420,
        "wires": [
            [
                "bbd24069c74caaed"
            ]
        ]
    },
    {
        "id": "fa88c017403615b0",
        "type": "debug",
        "z": "a241d72b79d8b1b7",
        "name": "debug 15",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1140,
        "y": 420,
        "wires": []
    },
    {
        "id": "bbd24069c74caaed",
        "type": "function",
        "z": "a241d72b79d8b1b7",
        "name": "Add Topic Room",
        "func": "//msg.payload = Number(msg.payload);\nmsg.topic = \"kitchen\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 920,
        "y": 420,
        "wires": [
            [
                "fa88c017403615b0",
                "5be14f9fd7f02627"
            ]
        ]
    },
    {
        "id": "5be14f9fd7f02627",
        "type": "join",
        "z": "a241d72b79d8b1b7",
        "name": "",
        "mode": "custom",
        "build": "object",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": false,
        "timeout": "",
        "count": "2",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 1110,
        "y": 340,
        "wires": [
            [
                "d811d377a8fe043d"
            ]
        ]
    },
    {
        "id": "1c4fd26064bb7111",
        "type": "debug",
        "z": "a241d72b79d8b1b7",
        "name": "debug 16",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1500,
        "y": 320,
        "wires": []
    },
    {
        "id": "f5300633df3022af",
        "type": "influxdb out",
        "z": "a241d72b79d8b1b7",
        "influxdb": "54904c9be351d74d",
        "name": "Heating",
        "measurement": "HeatingTest",
        "precision": "",
        "retentionPolicy": "",
        "database": "home_assistant",
        "precisionV18FluxV20": "ms",
        "retentionPolicyV18Flux": "",
        "org": "organisation",
        "bucket": "bucket",
        "x": 1500,
        "y": 360,
        "wires": []
    },
    {
        "id": "d811d377a8fe043d",
        "type": "function",
        "z": "a241d72b79d8b1b7",
        "name": "Add Topic Heating",
        "func": "//msg.payload = Number(msg.payload);\nmsg.topic = \"Heating\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1290,
        "y": 340,
        "wires": [
            [
                "1c4fd26064bb7111",
                "f5300633df3022af"
            ]
        ]
    },
    {
        "id": "d44ca4c463fcb953",
        "type": "function",
        "z": "a241d72b79d8b1b7",
        "name": "Change Topic",
        "func": "//msg.payload = Number(msg.payload);\nmsg.topic = \"Temperature\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 560,
        "y": 180,
        "wires": [
            [
                "e0a942bd7c5674d4"
            ]
        ]
    },
    {
        "id": "c0b0a5047e59e3b8",
        "type": "function",
        "z": "a241d72b79d8b1b7",
        "name": "Change Topic",
        "func": "//msg.payload = Number(msg.payload);\nmsg.topic = \"Temperature\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 560,
        "y": 380,
        "wires": [
            [
                "a993a62a3973e455"
            ]
        ]
    },
    {
        "id": "073920eea5a7aa87",
        "type": "function",
        "z": "a241d72b79d8b1b7",
        "name": "Change Topic",
        "func": "//msg.payload = Number(msg.payload);\nmsg.topic = \"Demand\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 560,
        "y": 220,
        "wires": [
            [
                "e0a942bd7c5674d4"
            ]
        ]
    },
    {
        "id": "78136dc09bdd906b",
        "type": "function",
        "z": "a241d72b79d8b1b7",
        "name": "Change Topic",
        "func": "//msg.payload = Number(msg.payload);\nmsg.topic = \"Humidity\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 560,
        "y": 300,
        "wires": [
            [
                "e0a942bd7c5674d4"
            ]
        ]
    },
    {
        "id": "90f45e0b4b22311f",
        "type": "function",
        "z": "a241d72b79d8b1b7",
        "name": "Change Topic",
        "func": "//msg.payload = Number(msg.payload);\nmsg.topic = \"Target\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 560,
        "y": 260,
        "wires": [
            [
                "e0a942bd7c5674d4"
            ]
        ]
    },
    {
        "id": "3cc93ae90c0546f7",
        "type": "function",
        "z": "a241d72b79d8b1b7",
        "name": "Change Topic",
        "func": "//msg.payload = Number(msg.payload);\nmsg.topic = \"Demand\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 560,
        "y": 420,
        "wires": [
            [
                "a993a62a3973e455"
            ]
        ]
    },
    {
        "id": "11fd30de50f02e56",
        "type": "function",
        "z": "a241d72b79d8b1b7",
        "name": "Change Topic",
        "func": "//msg.payload = Number(msg.payload);\nmsg.topic = \"Target\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 560,
        "y": 460,
        "wires": [
            [
                "a993a62a3973e455"
            ]
        ]
    },
    {
        "id": "3cade157397fc070",
        "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": ": ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "default",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": false
    },
    {
        "id": "54904c9be351d74d",
        "type": "influxdb",
        "hostname": "127.0.0.1",
        "port": "8086",
        "protocol": "http",
        "database": "testdatabase",
        "name": "Test Temperature",
        "usetls": false,
        "tls": "",
        "influxdbVersion": "1.8-flux",
        "url": "http://localhost:8086",
        "rejectUnauthorized": true
    }
]

Why will this not work?

But thinking about it, assuming that "multi level" works, what are the pro's and con's of that approach vs just putting all of the sensor data in one big "bucket"?

ie
Lounge-Temp
Lounge_Humidity
Kitchen_Temp
Kitchen_Humidity
etc

If you post your flow, it would help people see what you are trying to do by running the same code.

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

Original post edited mudwalker.

Thanks for realising it was my first post!

If you check the help text for the influx node you will see that it does not support structured data like that. In fact Influxdb does not support data like that.

Generally where you have similar data for multiple locations then you should put the location as a tag in the record, and send all the data to the same measurement. Then you can query for the data, using a WHERE clause to select the room of interest (or whatever the equivalent is in Influx2, I have not used that recently). So there is no need to join the data from the rooms.

In fact, if the values for a room do not come in from the sensors at the same time then I would not bother joining those either. Send, for example, the temperatures to a measurement called temperature, containing the value and the room (as a tag), send the Demand to a demand measurement, and so on. That will vastly simplify your flow.

Thanks Colin, I thought I'd seen that structure in a Node Red example.........must have been mistaken.

I shall revert back to the KISS principle until I know better!

Thanks again.

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