Tom-Hirschberger / MMM-Temperature

An MagicMirror² module which displays the current temperature and humidity measured by external scripts
MIT License
3 stars 2 forks source link

Values stay´s empty (na) displayed on MM after updating MMM-MQTTbridge #10

Closed SaschaSp closed 2 years ago

SaschaSp commented 2 years ago

Values stay´s empty (na) displayed on MM after updating MMM-MQTTbridge

mqttDictionary.js

var mqttHook = [ { mqttTopic: "Cotech", mqttPayload: [ { payloadValue: "", mqttNotiCmd: ["COTECH"], mqttPayload: "" }, ], }, ]; var mqttNotiCommands = [ { commandId: "COTECH", notiID: "TEMPERATURE_VALUES_Cotech", }, ]; module.exports = { mqttHook, mqttNotiCommands};

notiDictionary.js

var notiHook = [ { notiId: "USER_PRESENCE", notiPayload: [ { payloadValue: true, notiMqttCmd: ["SCREENON"] }, { payloadValue: false, notiMqttCmd: ["SCREENOFF"] }, ], }, { notiId: "INDOOR_TEMPERATURE", notiPayload: [ { payloadValue: '', notiMqttCmd: ["Command 2"] }, ], }, ]; var notiMqttCommands = [ { commandId: "SCREENON", mqttTopic: "magicmirror/state", mqttMsgPayload: '{"state":"ON"}' }, { commandId: "SCREENOFF", mqttTopic: "magicmirror/state", mqttMsgPayload: '{"state":"OFF"}' }, { commandId: "Command 1", mqttTopic: "magicmirror/state", mqttMsgPayload: '{"state":"OFF"}' }, { commandId: "Command 2", mqttTopic: "magicmirror/state", mqttMsgPayload: '' }, ];

module.exports = { notiHook, notiMqttCommands };

Part from config.js

    {
        module: "MMM-Temperature",
        position: "top_right",
        config: {
            sensors: [
                {
                    name: "Aktuelle Aussenwerte",
                    notificationId: "Cotech",
                    showWind: true,
                            },
            ]
        },
    },
    {
        module: 'MMM-MQTTbridge',
        disable: false,
        config: {
            mqttServer: "mqtt://:@192.168.1.83:1883",
            mqttConfig:
            {
                listenMqtt: true,
                interval: 300000,
            },
            notiConfig:
            {
                listenNoti: true,
                ignoreNotiId: ["CLOCK_MINUTE", "NEWS_FEED"],
                ignoreNotiSender: ["system", "NEWS_FEED"],
            },
            // set "NOTIFICATIONS -> MQTT" dictionary at /dict/notiDictionary.js
            // set "MQTT -> NOTIFICATIONS" dictionary at /dict/mqttDictionary.js
        },
    },

JS-Objekt

{humidity: 93, rain_mm: 98.700, wind_dir_deg: 262, wind_avg_m_s: 1.300, wind_max_m_s: 2.000, temperature_C: 7.555555555555556}

pm2 log

0|mm | MMM-Temperature: Updating sensor values 0|mm | [26.11.2022 13:03.07.649] [LOG] Sending temp update: [{"error":false}] 0|mm | [26.11.2022 13:03.07.654] [LOG] Removing values of sensor with name: Aktuelle Aussenwerte 0|mm | [26.11.2022 13:03.12.267] [LOG] 0|mm | [MQTT bridge] MQTT message received. Topic: Cotech, message: {"humidity":93,"rain_mm":98.7,"wind_dir_deg":306,"wind_avg_m_s":1.2,"wind_max_m_s":2,"temperature_C":7.555555555555556} 0|mm | [26.11.2022 13:03.12.291] [LOG] [MQTT bridge] MQTT message received. Topic: Cotech, message: {"humidity":93,"rain_mm":98.7,"wind_dir_deg":306,"wind_avg_m_s":1.2,"wind_max_m_s":2,"temperature_C":7.555555555555556} 0|mm | [26.11.2022 13:03.27.985] [LOG]

Tom-Hirschberger commented 2 years ago

Hi,

as assumed already the mqttDictionary.js does not suit your case cause it contains the old definition that was used to let the payload be passed as notification payload (payloadValue=''). I updated MMM-Temperature to version 0.0.7 which supports JSON in version 5 now. I am not sure if it is needed for your case but i suggest to update the module.

With the following mqttDitionary.js everything should work again:

var mqttHook = [
  {
    mqttTopic: "Cotech",
    mqttPayload: [
      {
        mqttNotiCmd: ["COTECH"],
      },
    ],
  },
];

var mqttNotiCommands = [
  {
    commandId: "COTECH",
    notiID: "TEMPERATURE_VALUES_Cotech",
  },
];
module.exports = { mqttHook, mqttNotiCommands};
SaschaSp commented 2 years ago

Yes, youre right. Updated MMM_Temperature and remove payloadValue & mqttPayload from mqttDictionary.js

It`s working great again, thank you.