Dashboard Toolbar will only update on HOME tab

I posted essentially the same question earlier with no response so I think I did a poor job with the question. I have a flow in the [HOME]Toolbar group that fetches solar activity and then I post it to the toolbar. If I refresh the Home tab the data posts properly:

When I change tabs the data is there for all tabs until I refresh the browser.

To get the data back I have to navigate back to the Home tab and the data is then present and when I navigate back to any other tab the data is there until the next refresh.

I have been trying to research this and have read about using the ui_control node to force an update but I have not been successful. Trying to debug this issue I am inspecting the browser out put and notice that when there is no data the variable in the browser is set to 0:

image

I am starting to think that a refresh is either deleting the data or for some reason it's not being picked up.

Below is the json for one function and the client / server templates.

Regards,
Mick

[
    {
        "id": "200328b17c35c26b",
        "type": "inject",
        "z": "601d137130d1ff68",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "600",
        "crontab": "",
        "once": true,
        "onceDelay": "5",
        "topic": "",
        "payloadType": "date",
        "x": 310,
        "y": 120,
        "wires": [
            [
                "02db021a09883ba3"
            ]
        ]
    },
    {
        "id": "02db021a09883ba3",
        "type": "http request",
        "z": "601d137130d1ff68",
        "name": "getSolar",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "https://www.hamqsl.com/solarxml.php",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "x": 140,
        "y": 180,
        "wires": [
            [
                "ee176491f7e60d4c"
            ]
        ]
    },
    {
        "id": "c68d1bbb02134814",
        "type": "function",
        "z": "601d137130d1ff68",
        "name": "",
        "func": "var kdx = msg.payload.solar.solardata[0].kindex[0];\nmsg.topic = \"kdx\";\nmsg.payload = kdx;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 440,
        "y": 180,
        "wires": [
            [
                "4946e617dfe4a6e9"
            ]
        ]
    },
    {
        "id": "ee176491f7e60d4c",
        "type": "xml",
        "z": "601d137130d1ff68",
        "name": "",
        "property": "payload",
        "attr": "",
        "chr": "",
        "x": 290,
        "y": 180,
        "wires": [
            [
                "c68d1bbb02134814",
                "ff8cb7addfe65ac9",
                "367061f2c2932a9f",
                "49d8a26f832c8b7d"
            ]
        ]
    },
    {
        "id": "4946e617dfe4a6e9",
        "type": "ui_template",
        "z": "601d137130d1ff68",
        "group": "12aa555ebffdaafd",
        "name": "update K",
        "order": 3,
        "width": 0,
        "height": 0,
        "format": "\n<script>\n    (function(scope) {\n        //hide this card. NOTE: 4b689f7473831a84 is the Node id as \n        //seen in the INFO panel on the sidebar when you select this node\n         $('[node-id=\"4946e617dfe4a6e9\"]').hide();\n        scope.$watch('msg', function(msg) {\n            if (msg && msg.topic == \"kdx\") {\n                $(\"#header-kdx\").text(msg.payload);\n            }\n        });\n    })(scope);\n</script>\n",
        "storeOutMessages": true,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "x": 600,
        "y": 180,
        "wires": [
            []
        ]
    },
    {
        "id": "7b70f8246c1cd8c0",
        "type": "ui_ui_control",
        "z": "601d137130d1ff68",
        "name": "",
        "events": "all",
        "x": 120,
        "y": 120,
        "wires": [
            [
                "02db021a09883ba3"
            ]
        ]
    },
    {
        "id": "dfb55d9d.ee5d2",
        "type": "ui_template",
        "z": "601d137130d1ff68",
        "group": "699db2e1.f6553c",
        "name": "Logo / Solar / Clock",
        "order": 1,
        "width": 0,
        "height": 0,
        "format": "<script id=\"toolbar\" type=\"text/javascript\">\n    var clockInterval;\n    $(function () {\n        if (clockInterval) return;\n\n        // add solar\n        var div1 = $('<div/>');\n        var p1 = $('<p>SFi</p>');\n        var p2 = $('<p/ id=\"header-sfi\">');\n        var p3 = $('<p>A</p>');\n        var p4 = $('<p/ id=\"header-Aindex\">');\n        var p5 = $('<p>K</p>');\n        var p6 = $('<p/ id=\"header-kdx\">');\n     \n        div1.append(p1);\n        div1.append(p2);\n        div1.append(p3);\n        div1.append(p4);\n        div1.append(p5);\n        div1.append(p6);\n        \n        div1[0].style.width = 'auto';\n        div1[0].style.margin = 'auto';\n        div1[0].style.display = 'flex';\n\n        p1[0].style.margin = 'auto';\n        p2[0].style.margin = '5px'; \n        p3[0].style.margin = 'auto';\n        p4[0].style.margin = '5px';\n        p5[0].style.margin = 'auto';\n        p6[0].style.margin = '5px';\n\n        //add fof2\n        var div2 = $('<div/>');\n        var f1 = $('<p>foF2</p>');\n        var f2 = $('<p/ id=\"header-fof2\">');\n        \n        div2.append(f1);\n        div2.append(f2);\n        \n        div2[0].style.width = 'auto';\n        div2[0].style.margin = 'auto';\n        div2[0].style.display = 'flex';\n        \n        f1[0].style.margin = '6px';\n        f2[0].style.margin = 'auto';\n     \n        // add clock\n        var div3 = $('<div/>');\n        var p = $('<p/>');\n\n        div3.append(p);\n        div3[0].style.margin = '5px 5px 5px auto';\n        div3[0].style.display = 'flex';\n\n\n        function displayTime() {\n            var d = Date();\n            var options = { timeZone: 'UTC', timeZoneName: 'short',  hourCycle: 'h23', hour: `2-digit`, minute: `2-digit`};\n            p.text(new Date().toLocaleString('en-US', options));\n        }\n        \n        clockInterval = setInterval(displayTime, 1000);\n\n        //add to toolbar when it's available\n        var addToToolbarTimer;\n        \n        function addToToolbar() {\n            var toolbar = $('.md-toolbar-tools');\n            \n            if(!toolbar.length) return;\n            \n            toolbar.append(div1);\n            toolbar.append(div2);\n            toolbar.append(div3);\n\n            clearInterval(addToToolbarTimer);\n        }\n        addToToolbarTimer = setInterval(addToToolbar, 200);\n    });\n</script>",
        "storeOutMessages": true,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "global",
        "x": 150,
        "y": 60,
        "wires": [
            []
        ]
    },
    {
        "id": "12aa555ebffdaafd",
        "type": "ui_group",
        "name": "Toolbar",
        "tab": "0a84fc0885f875a9",
        "order": 1,
        "disp": false,
        "width": "18",
        "collapse": false
    },
    {
        "id": "699db2e1.f6553c",
        "type": "ui_group",
        "name": "www",
        "tab": "f4b91d3a.a7533",
        "order": 2,
        "disp": false,
        "width": "24",
        "collapse": false
    },
    {
        "id": "0a84fc0885f875a9",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    },
    {
        "id": "f4b91d3a.a7533",
        "type": "ui_tab",
        "name": "Home",
        "icon": "home",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]type or paste code here

Tricky, sorry.

The only thing of which I can think which could be causing this is CACHE.....

Try a force refresh of the page and see what happens.

That's the best I can do at this stage.

I have tried that to no avail. I going through the ui_control nodes again. I see there is some info about how to update tabs.

Regards

I stumbled upon the solution. To get every tab to update on refresh I had to duplicate the client nodes in a flow for each tab. I then used link in/out to connect them to the function nodes. Lastly I had to include a ui_control node for change to inject a flow based on change.

Here is the main flow with link out nodes

and here is the flow for one of the tabs with link in.

image

Regards,

Mick

1 Like

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