• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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 609 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 Oct 16, 2020, 7:53 AM

    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.

    S 1 Reply Last reply Oct 18, 2020, 6:05 AM Reply Quote 0
    • S Offline
      Serge @fribse
      last edited by Oct 18, 2020, 6:05 AM

      @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
      • S Offline
        Serge
        last edited by Oct 18, 2020, 1:35 PM

        @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 Oct 18, 2020, 2:16 PM

          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
          • 1 / 1
          1 / 1
          • First post
            4/4
            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