Navigation

    MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    MMM-MQTTbridge doesn't seem to report USER_PRESENCE correctly?

    Troubleshooting
    2
    4
    45
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      fribse last edited by

      I can see that MMM-Remote-Control set’s the USER_PRESENCE depending on the state of the monitor.
      I try to interpret that to update the status of the switch in HomeAssistant by having it set up in the notiDictionary

      The config looks like this:

      var notiHook = [
        {
          notiId: "USER_PRESENCE",
          notiPayload: [
            {
              payloadValue: true,
              notiMqttCmd: ["SCREENON"]
            },
            {
              payloadValue: false,
              notiMqttCmd: ["SCREENOFF"]
            },
          ],
        },
      ];
      var notiMqttCommands = [
        {
          commandId: "SCREENOFF",
          mqttTopic: "bathroom/mirror/monitor",
          mqttMsgPayload: "{'state':'OFF'}"
        },
        {
          commandId: "SCREENON",
          mqttTopic: "bathroom/mirror/monitor",
          mqttMsgPayload: "{'state':'ON'}"
        },
      ];
      
      module.exports = { notiHook, notiMqttCommands };
      
      

      The logs looks like this:

      0|mm     | [2020-10-16 09:44:34.089] [LOG]
      0|mm     | [MQTT bridge] NOTI->MQTT. Topic: bathroom/mirror/monitor, payload: false
      0|mm     | [2020-10-16 09:44:34.101] [LOG]
      0|mm     | Powering off HDMI
      0|mm     | [2020-10-16 09:44:34.102] [LOG]
      0|mm     | [2020-10-16 09:44:36.936] [LOG]
      0|mm     | [MQTT bridge] NOTI->MQTT. Topic: bathroom/mirror/monitor, payload: {"state":"ON"}
      0|mm     | [2020-10-16 09:44:37.793] [LOG]
      0|mm     | Powering on HDMI with preferred settings
      0|mm     | [2020-10-16 09:44:37.795] [LOG]
      

      So when it turns off, it doesn’t report state: off it just reports ‘false’ and it only reports state:on when it’s on.

      I do see the messages appear in the MQTT, but as they are incorrectly formatted, HA doesn’t update it properly.

      Serge 1 Reply Last reply Reply Quote 0
      • Serge
        Serge @fribse last edited by

        @fribse please send here as well console log. Also, could you please wait and check wat is happening when FALSE is sent by user_presence for the second time.
        E.g. it would help full to see behaviour : false, true, … false

        1 Reply Last reply Reply Quote 0
        • Serge
          Serge last edited by

          @fribse resolved on github, the reason is that for Boolean values the payloadValue should be set up as 1 or 0 for true/false.

          1 Reply Last reply Reply Quote 0
          • F
            fribse last edited by

            The config that works looks like this:

            var notiHook = [
              {
                notiId: "USER_PRESENCE",
                notiPayload: [
                  {
                    payloadValue: '1',
                    notiMqttCmd: ["SCREENON"]
                  },
                  {
                    payloadValue: '0',
                    notiMqttCmd: ["SCREENOFF"]
                  }
                ]
              }
            ];
            var notiMqttCommands = [
              {
                commandId: "SCREENOFF",
                mqttTopic: "state/bathroom/mirror/monitor",
                mqttMsgPayload: "OFF"
              },
              {
                commandId: "SCREENON",
                mqttTopic: "state/bathroom/mirror/monitor",
                mqttMsgPayload: "ON"
              }
            ];
            
            module.exports = { notiHook, notiMqttCommands };
            

            Thankyou again for your excellent help and sharp eyes Serge!. 💪 ♥

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Enjoying MagicMirror? Please consider a donation!
            MagicMirror created by Michael Teeuw.
            Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
            This forum is using NodeBB as its core | Contributors
            Contact | Privacy Policy