ottopaulsen / MMM-MQTT

MQTT Client module for MagicMirror2
MIT License
57 stars 29 forks source link

mqtt values #54

Closed Riaanh2 closed 2 years ago

Riaanh2 commented 2 years ago

Good day Otto, and thanks for sharing your projects.

I have an issue that I can get and edit the mqtt portion on MM, but for some reason I cannot get it to return values. With the exact same server/port detail and subscription to topic, I can return the values in items like mqttDash and mqtt explorer.

Any ideas of some switch that need to be defined somewhere?

I paste below some detail.

{ module: 'MMM-MQTT', header: 'MMM-MQTT', position: 'bottom_left', config: { mqttBroker: [ { url: "192.168.88.212", port: 1884, auth: { user: "@F21C6284", password: "@F21C6284", }, subscriptions: [ { topic: "@F21C6284/Inverter/TotalGridWatts", // Topic to look for label: "GridWatts", // Label, which is displayed in front of the value showLabelAsIcon: true, // Specify whether the label shall be replaced> icon: "thermometer", // Font awesome icon, which shall be displayed (> suffix: "°C", // Suffix, which is displayed behind the value decimals: 1, // Round value to this number of decimals position: 2, // Position of the value inside the table (counting top > colors: [ {upTo: 0, label: "#0a3fb0", value: "#0000FF", suffix: "#FFFFF"}, {upTo: 25, value: "#00FF00"}, {upTo: 35, value: "#FF0000"}, ], factor: 4, // Factor with which the value should be factorized by offset: 5, // Offset of the value },

From mqtt server @ 192.168.88.212 on port 1884:

image

Thanks in advance Riaan

ottopaulsen commented 2 years ago

Hi.

There can be many reasons for this. The first that strikes me is that you seem to have the username as part of the topic. Are you sure that is correct? Also, you have a lot of config in use here. I suggest you try something simpler first. Are you able to send to the queue? If so, try to send something very simple, and make a simple configuration to show that value. This way you can make sure that you have connection to the queue. Another thing to try is to look at the log from MM. The module should put some information there, and there may be error messages. You can also add more info by turning on debug.

Are you running this on an RPi? Is so, you could use the mqtt-tools on the command line to try stuff.

Riaanh2 commented 2 years ago

Good day OttoPaulsen.

Firstly let me start by thanking you for the response, really appreciated. I initially worked my way back from the post above, but ended up going all the way back to root basics. With mqtt installed on the local Pi running MM, the basic Pub and Sub to and from 'localhost' is operational. as soon as one replace localhost with the unit's local IP, you start getting failures as stated above. So even local there are issues with using IP rather than localhost. The solution was to edit the mosquitto.conf file with the following: bind_address x.x.x.x (the Pi local IP) After this I could Pub and Sub with local IP. Added user and pass, still worked, and then tried sub to the server side, also successful. So in a nutshell it was only mqtt that bind to "localhost" ONLY for security purposes that caused the issues.

Thanks again for great work done by you.

Riaan

ottopaulsen commented 2 years ago

Great it worked out. Closing this issue, then.