Place Pi Temp on Dashboard Toolbar

I am trying to put the Pi Temp on the tool bar. I have used several templates that I pulled from the web to no avail. Currently I found one that looked promising but it does not render anything on the tool bar.

image

I am watching the output in debug and I see:
path = payload
value = 31.0

Inspecting the UI elements I see:
Uncaught ReferenceError: scope is not defined

My current flow is:

Cpu temp comes from: vcgencmd measure_temp
getPiTemp comes from :
str = msg.payload
msg.payload = str.substring(5,9);
return msg;

Can some one advise on how to do this?
thanks

I think I found this in another post

[
    {
        "id": "fad1640e.39cf78",
        "type": "inject",
        "z": "68bac6fc.a91c88",
        "name": "",
        "props": [
            {
                "p": "payload",
                "v": "true",
                "vt": "bool"
            },
            {
                "p": "topic",
                "v": "",
                "vt": "string"
            }
        ],
        "repeat": "60",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 70,
        "y": 600,
        "wires": [
            [
                "24b6f3b8.3b4a9c"
            ]
        ]
    },
    {
        "id": "24b6f3b8.3b4a9c",
        "type": "exec",
        "z": "68bac6fc.a91c88",
        "command": "vcgencmd",
        "addpay": false,
        "append": "measure_temp",
        "useSpawn": "false",
        "timer": "",
        "oldrc": false,
        "name": "",
        "x": 330,
        "y": 600,
        "wires": [
            [
                "89f596af.9ae6b8"
            ],
            [],
            []
        ]
    },
    {
        "id": "89f596af.9ae6b8",
        "type": "change",
        "z": "68bac6fc.a91c88",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "pitemp/Automation",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 350,
        "y": 660,
        "wires": [
            [
                "e18c947.a9dce68",
                "fd36720a.bbecd"
            ]
        ]
    },
    {
        "id": "e18c947.a9dce68",
        "type": "mqtt out",
        "z": "68bac6fc.a91c88",
        "name": "",
        "topic": "",
        "qos": "",
        "retain": "",
        "broker": "5d7e8c9.d0edf74",
        "x": 330,
        "y": 720,
        "wires": []
    },
    {
        "id": "f67256e3.482398",
        "type": "comment",
        "z": "68bac6fc.a91c88",
        "name": "CPU Temperature",
        "info": "",
        "x": 110,
        "y": 560,
        "wires": []
    },
    {
        "id": "fd36720a.bbecd",
        "type": "debug",
        "z": "68bac6fc.a91c88",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 540,
        "y": 660,
        "wires": []
    },
    {
        "id": "5d7e8c9.d0edf74",
        "type": "mqtt-broker",
        "z": "",
        "name": "",
        "broker": "192.168.1.21",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": false,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    }
]

Buckskin

All I see is a CPU temp sent to an MQTT server. Did you send the current flow?

Alan

I am just executing the vcgencmd measure_temp command to get the result

There should be a Debug node. Activate the output and check the debug message

OK, thanks. Hoping to get a template script to get the result into the tool bar.

Alan

I haven't done this myself, but this thread has some examples intended to do similar things. I would start by importing one of those and make sure it works as given, then amend it in small steps to get what you want. If it stops working then you know that the step you have just made is not correct. Set a logo in the title bar?

I have python scripts or NR flows (depending on the device) that capture the processor temperature, and forward this information via MQTT to a central NR instance. That same central NR instance, can by schedule or on-demand send MQTT message (i.e. command) to tell the remote device to send back its processor temperature (as I noted above). This gives me a really nice dashboard tab that has the temperature, serial #, device name, etc. for all my devices.

I suggest you create a flow that just captures the processor temperature via an Exec node. Then add to that flow, an MQTT publishing node that sends that information to somewhere (even it is that same device). Doing this means you need to setup a MQTT subscriber node.

Get Temp (Exec node) -> MQTT Publish (MQTT out node)
MQTT Subscribe (MQTT in node) -> Display Temp (whatever way you want to present the data)

To use MQTT, you will need to learn or have knowledge of how to setup an MQTT broker.

Thanks. So the MQTT broker essentially takes the msg.payload and makes it available to the system (i.e variable)?

Mick

I use "Mosquito" as my MQTT broker installed on one of my Raspberry Pis. Google mosquito MQTT and you will get the install command. Easy. No additional setup required.

On Node-Red, use the MQTT in or out nodes pointed to/from the IP:port of the MQTT broker. You can now share messages to all of your other Raspberry Pis on the same LAN. I use multiple Raspberry Pis to switch antennas, switch power, collect data (volts, amps, temperature), and others, then send back to the "Master Pi" for building the logic and dashboard.

A lot of IOT devices use MQTT, so you can interface with them also. I control the Digital Loggers, DLI Switch via MQTT.

I understand there are also WAN based MQTT brokers you can pay for un-line. These would open up the Broker/Client to work in or out of your LAN. Again, the Node-Red MQTT nodes could be pointed at these WAN based brokers.

Alan WA9WUD

To learn about MQTT work through this guide https://www.hivemq.com/mqtt-essentials/

Thanks all. I just started to look into it and my head exploded. It looks as hairy as Node-Red...Oh well never a dull moment...

Just ask... we will always nudge you in the right direction when you get bogged down. :slight_smile: If had not already been quite experienced with enterprise monitoring solutions, various scripting languages, and had experience with 'MQ' based design models, event driven application design, etc. I am SURE I would have had a headache of unbelievable dimensions when I started doing some serious stuff with NR.

MQTT is easy actually just keep the following basics in mind...

MQTT publisher (sender) -> Broker -> MQTT subscriber (receiver, listener)

So how do you know a publisher and subscriber will talk? By setting the topic they agree to use. So...

MQTT publisher sends 'This is my topic' and a message (data).
MQTT subscriber receives, listens for 'This is my topic' and I am waiting or just got a message

The above is a 1 to 1 send and receive, Of course you can do more, 1 to many, many to 1, etc. But just start with a 1 to 1 setup and learn from there. A tip, it is easier to create unique topics as needed, than to parse the message data from a shared topic (unless a shared topic is need) but lets ignore that for now.

Did you look at the hive tutorial linked? I thought it have a fairly gentle introduction. It is certainly one of the easier communications methods invented, and most of the time, in use, it is almost trivial, once you understand the basic publish subscribe model.

I have not yet, I just googled mqtt and went to the the websites I found there. I will get to it. I do appreciate it...

thanks