Gauge label doesn't work with {{msg.topic}}

#1

Setting Label with {{msg.topic}}


The topic is setted by change node

This is the flow

[
    {
        "id": "ed4796d7.57501",
        "type": "ui_gauge",
        "z": "1e58ad1d.519583",
        "name": "",
        "group": "77924864.53a6a8",
        "order": 0,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "{{msg.topic}}",
        "label": "°C ####",
        "format": "{{value}}",
        "min": "-10",
        "max": "60",
        "colors": [
            "#80ffff",
            "#ffff00",
            "#ca3838"
        ],
        "seg1": "12",
        "seg2": "30",
        "x": 630,
        "y": 200,
        "wires": []
    },
    {
        "id": "15e9bf7b.946241",
        "type": "json",
        "z": "1e58ad1d.519583",
        "name": "",
        "pretty": false,
        "x": 290,
        "y": 220,
        "wires": [
            [
                "cacd4506.dcd238"
            ]
        ]
    },
    {
        "id": "dba09ab9.842b48",
        "type": "mqtt in",
        "z": "1e58ad1d.519583",
        "name": "",
        "topic": "out/dht22",
        "qos": "0",
        "broker": "eed163.62e4bea",
        "x": 120,
        "y": 220,
        "wires": [
            [
                "15e9bf7b.946241"
            ]
        ]
    },
    {
        "id": "cacd4506.dcd238",
        "type": "change",
        "z": "1e58ad1d.519583",
        "name": "Temp",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.Temp",
                "tot": "msg"
            },
            {
                "t": "move",
                "p": "topic",
                "pt": "msg",
                "to": "payload.pos",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 450,
        "y": 220,
        "wires": [
            [
                "12227ba3.8a5ff4",
                "ed4796d7.57501"
            ]
        ]
    },
    {
        "id": "12227ba3.8a5ff4",
        "type": "display",
        "z": "1e58ad1d.519583",
        "active": true,
        "x": 640,
        "y": 240,
        "wires": []
    },
    {
        "id": "15597b43.0da9a5",
        "type": "go",
        "z": "1e58ad1d.519583",
        "name": "Test msg",
        "x": 120,
        "y": 320,
        "wires": [
            [
                "9874aad3.f06688"
            ]
        ]
    },
    {
        "id": "9874aad3.f06688",
        "type": "set",
        "z": "1e58ad1d.519583",
        "property": "payload",
        "value": "{\"Sn\":\"3389852238\",\"name\":\"TempHum\",\"pos\":\"Room 1\",\"Temp\":25,\"Hum\":\"105.90\"}",
        "name": "",
        "x": 420,
        "y": 420,
        "wires": [
            [
                "15e9bf7b.946241"
            ]
        ]
    },
    {
        "id": "77924864.53a6a8",
        "type": "ui_group",
        "z": "",
        "name": "Temperature",
        "tab": "3dccec0c.f37104",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": true
    },
    {
        "id": "eed163.62e4bea",
        "type": "mqtt-broker",
        "z": "",
        "broker": "localhost",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": ""
    },
    {
        "id": "3dccec0c.f37104",
        "type": "ui_tab",
        "z": "",
        "name": "DHT22",
        "icon": "dashboard",
        "order": 7
    }
]

(edited to add backticks by dceejay)

0 Likes

#2

You need to surround your flow with three backticks (before and after your flow) to remove the smart quotes or others will not be able to import it.

Also, can you shorten it to just an inject node and the gauge note to show the problem?

0 Likes

#3

If you do like @zenofmud said, in regards to the backticks surrounding the code, then it will be easier for people in the forum to help you.

I managed anyway to partially import your flow. You are using some nodes that are unknown for me but I suspect the issue is on your change node. Apparently it is configured like below:

If this is the case then you are moving, in the second rule, msg.topic to msg.payload.pos. Most likely you want to do the opposite. Swap that config for testing.

Additionally, this should be the first rule in the change node, not the second one. The reason is that you are modifying msg.payload (destroying the original one) , in the other rule, and the order matters. Summarizing, if the config is like below it should work.

m-0002

0 Likes