MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

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

    Scheduled Pinned Locked Moved Troubleshooting
    4 Posts 2 Posters 958 Views 2 Watching
    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 Offline
      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.

      SergeS 1 Reply Last reply Reply Quote 0
      • SergeS Offline
        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
        • SergeS Offline
          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 Offline
            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!. :flexed_biceps: :heart_suit:

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post
            Enjoying MagicMirror? Please consider a donation!
            MagicMirror created by Michael Teeuw.
            Forum managed by Sam, technical setup by Karsten.
            This forum is using NodeBB as its core | Contributors
            Contact | Privacy Policy