Dashboard issue with use on two devices

Hi! I use the dashboard on two devices (tablet and smartphone) and I have a tab with the interface optimized for the tablet and one for the smartphone. When I press a button the MQTT function is executed but the state of the button is not detected by the same button on the other device (on the other tab). If i refresh the page the problem will be fixed. I tried to remove msg.socketid but didn't fix the issue or maybe I'm using it the wrong way. What can I do? Here is an example:

[{"id":"f5b26d5742f51b9b","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"ccfdef495756c1f3","type":"ui_button","z":"f5b26d5742f51b9b","name":"Luce Cucina","group":"29a8a46b636a8cf2","order":2,"width":3,"height":3,"passthru":false,"label":"{{label}}","tooltip":"","color":"{{color}}","bgcolor":"DimGray","className":"","icon":"{{icon}}","payload":"","payloadType":"str","topic":"","topicType":"str","x":510,"y":100,"wires":[["047666d4a4cc40b9"]]},{"id":"f38dc5dd3426a0d6","type":"mqtt in","z":"f5b26d5742f51b9b","name":"Stato Luce Cucina","topic":"shellies/shellyswitch25-xxxx/relay/1","qos":"2","datatype":"auto","broker":"","nl":false,"rap":false,"inputs":0,"x":130,"y":100,"wires":[["f68b8db2bfa39590","ad7dd8f072f60164"]]},{"id":"f68b8db2bfa39590","type":"function","z":"f5b26d5742f51b9b","name":"Desktop","func":"var icon = \"iconify-mdi:microwave 48px\";\nvar object = \"Cucina\";\nconst object1 = global.get(\"temperatura_cucina\");\nconst object2 = Number(object1).toFixed(1);\nvar text = \"<br/><font size=4 color=white>\" + object + \"</font>\";\nvar temp = \"<br/><font size=3 color=white>\" + object2 + \"°</font>\";\nvar label = text + temp;\nvar iconcolor;\n\nif (msg.payload == \"on\") {\n    iconcolor = \"DarkOrange\";\n} else {\n    iconcolor = \"White\";\n}\n\nmsg = { color:iconcolor, label:label, icon: icon};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":100,"wires":[["ccfdef495756c1f3"]]},{"id":"2bad338bd5d37ce4","type":"mqtt in","z":"f5b26d5742f51b9b","name":"Temperatura Cucina","topic":"rtl_433/inFactory-TH-129/temperature_C","qos":"2","datatype":"auto","broker":"","nl":false,"rap":false,"inputs":0,"x":130,"y":160,"wires":[["4e644b53ec748d3e"]]},{"id":"83014c9c324b7131","type":"change","z":"f5b26d5742f51b9b","name":"Stato Temperatura Cucina","rules":[{"t":"set","p":"temperatura_cucina","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":160,"wires":[[]]},{"id":"4e644b53ec748d3e","type":"delay","z":"f5b26d5742f51b9b","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":340,"y":160,"wires":[["83014c9c324b7131"]]},{"id":"047666d4a4cc40b9","type":"function","z":"f5b26d5742f51b9b","name":"Object State","func":"var object3 = global.get(\"luce_cucina\");\nvar topic = \"shellies/shellyswitch25-xxxx/relay/1/command\";\n\nif (object3 === \"on\") {\n    msg.payload = \"off\";\n    \n} else if (object3 === \"off\") {\n    msg.payload = \"on\";\n}\n\nmsg = { topic:topic, payload:msg.payload};\ndelete msg.socketid;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":730,"y":100,"wires":[["2c42edb95cdccabd"]]},{"id":"f8c2610ec59a2184","type":"ui_button","z":"f5b26d5742f51b9b","name":"Luce Cucina","group":"22c314d3ebb7fcfe","order":2,"width":3,"height":2,"passthru":false,"label":"{{label}}","tooltip":"","color":"{{color}}","bgcolor":"DimGray","className":"","icon":"{{icon}}","payload":"","payloadType":"str","topic":"","topicType":"str","x":510,"y":60,"wires":[["047666d4a4cc40b9"]]},{"id":"ad7dd8f072f60164","type":"function","z":"f5b26d5742f51b9b","name":"Mobile","func":"var icon = \"iconify-mdi:microwave 48px\";\nvar object = \"Cucina\";\nconst object1 = global.get(\"temperatura_cucina\");\nconst object2 = Number(object1).toFixed(1);\nvar text = \"<font size=3 color=white>\" + object + \"</font>\";\nvar temp = \"<br/><font size=2 color=white>\" + object2 + \"°</font>\";\nvar label = text + temp;\nvar iconcolor;\n\nif (msg.payload == \"on\") {\n    iconcolor = \"DarkOrange\";\n} else {\n    iconcolor = \"White\";\n}\n\nmsg = { color:iconcolor, label:label, icon: icon};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":60,"wires":[["f8c2610ec59a2184"]]},{"id":"2c42edb95cdccabd","type":"mqtt out","z":"f5b26d5742f51b9b","name":"","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"","x":890,"y":100,"wires":[]},{"id":"29a8a46b636a8cf2","type":"ui_group","name":"Group 1","tab":"e1578eda944fe27f","order":1,"disp":true,"width":6},{"id":"22c314d3ebb7fcfe","type":"ui_group","name":"Group 1","tab":"42dba2f1e52d6160","order":1,"disp":true,"width":6},{"id":"e1578eda944fe27f","type":"ui_tab","name":"Desktop1","icon":"dashboard","order":10,"disabled":false,"hidden":false},{"id":"42dba2f1e52d6160","type":"ui_tab","name":"Mobile1","icon":"dashboard","order":11,"disabled":false,"hidden":false}]

For a quick fix, if you want a dirty solution, i would refresh the page after a button click maybe after a 2 second wait. Use the trigger node to refresh your dashboard groups

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