How to send JSON via UDP/MQTT with Virtual Output?

Einklappen
X
 
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge
  • johnsmith_
    Dumb Home'r
    • 24.03.2022
    • 27

    #1

    How to send JSON via UDP/MQTT with Virtual Output?

    Hello,

    It's probably something easy to solve, but it's driving me crazy for days now. I have Zigbee2Mqtt installed on a RPi, a Loxone Miniserver, and a couple of zigbee lights. Everything works fine throught zigbee2mqtt, I can toggle my lights, set rgbw colors, brightness, etc. All good. Problem comes when I try to do all this via Loxone virtual output. I've tried with Loxberry's quick publisher and mqtt explorer as well to send JSON messages to the mqtt gateway and it works flawlessly. Added a simple example to toggle the light on/off.

    However, when I try to do the same via Loxone it just doesn't work. My theory is that it's because Loxone escapes the " character with \, but I might be wrong. That's all the difference I could find, but I have no clue how to turn off the auto-escape feature. Any idea how can I do this ?

    Cheers !
    Zuletzt geändert von johnsmith_; 26.08.2023, 18:08.
  • buki
    Smart Home'r
    • 17.05.2017
    • 80

    #2
    Have you tried to set as digital output and unit as <v>

    Kommentar

    • johnsmith_
      Dumb Home'r
      • 24.03.2022
      • 27

      #3
      Zitat von buki
      Have you tried to set as digital output and unit as <v>
      Yes, it doesn't work. Sending a simple
      Code:
      zigbee2mqtt/device/set/state ON
      message it does turn the light on, however, when sending it as
      Code:
      zigbee2mqtt/device/set { "state": "ON" }
      it does nothing. For some reason it seems like the
      Code:
      "
      characters in the JSON are escaped. I could use the first version for turning the light on/off and setting the brightness, however, it seems really awful to set the RGB colors with 3 commands (setting red, green and blue separately). It just doesn't feel right, that's why I would like to send a simple command with
      Code:
      zigbee2mqtt/device/set { "color": { "r": 100, "g": 150, "b": 200 } }
      for example.

      Kommentar

      • buki
        Smart Home'r
        • 17.05.2017
        • 80

        #4
        Not sure why, but the (red marked) off-parts are missing in your screen. Below my configuration. This works for me, at least.
        I tried to create some combinations with <v> and state/text like your example, this wasn't working for me neither. I couldn't see anything in the UDP monitor when I use <v>.
        Klicke auf die Grafik für eine vergrößerte Ansicht

Name: Untitled.png
Ansichten: 1352
Größe: 58,7 KB
ID: 401799
        my loxone version is 14.2.6.16

        good luck.​

        Kommentar

        • johnsmith_
          Dumb Home'r
          • 24.03.2022
          • 27

          #5
          Zitat von buki
          Not sure why, but the (red marked) off-parts are missing in your screen. Below my configuration. This works for me, at least.
          I tried to create some combinations with <v> and state/text like your example, this wasn't working for me neither. I couldn't see anything in the UDP monitor when I use <v>.
          Klicke auf die Grafik für eine vergrößerte Ansicht

Name: Untitled.png
Ansichten: 1352
Größe: 58,7 KB
ID: 401799
          my loxone version is 14.2.6.16

          good luck.​
          The red marked part is only there if you use digital output. I'm pretty sure I shouldn't use that if I want to send a JSON text with color settings, but anyways. I tried your settings but that doesn't seem to work for me at all. It simply does nothing. I would also need the <v> since I can't just hard code the colors there.

          Kommentar

          • johnsmith_
            Dumb Home'r
            • 24.03.2022
            • 27

            #6
            Been debugging a bit. So if I directly set the JSON in the command (sort of like "hard coding" it there), then it's going to be escaped. Also, when using the "Test Command" menu (which I've been doing to actually test it...) does the same, the message body gets escaped. However, when I'm for example adding a push button -> status block -> Virtual Output, where the status block sets the same exact output
            Code:
            { "color": { "r": 100, "g": 150, "b": 200 } }
            , it actually does NOT get escaped. I'm pretty sure this is a Loxone bug actually, which have been introduced between your version and mine (I'm on latest). Where should this be reported?

            Kommentar


            • buki
              buki kommentierte
              Kommentar bearbeiten
              This is why I added my config version to my response. I also had in mind that this could be a bug.
              You need to create s support request to the loxone support.

            • johnsmith_
              johnsmith_ kommentierte
              Kommentar bearbeiten
              Cheers, will do so!
          • jensmh
            Smart Home'r
            • 25.08.2015
            • 98

            #7
            I just configured my first Miniserver -> MQTT connection. To avoid the problem with the escaping, I used the "text-generator" block. Works like a charm.

            Simply put the desired text in the first parameter, don't use anything else.

            Kommentar

            • henk.oosterlinck
              Dumb Home'r
              • 17.06.2016
              • 18

              #8
              Hello,

              I seem to have the same issue.
              Is it possible to post a few screenshots of both solutions with the text block (ok for 1 command) and status block (ok for on/off).
              Do I get this right?

              Angehängte Dateien

              Kommentar

              Lädt...