Plugin: Lox2MQTT

Einklappen
X
 
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge
  • nufke
    Smart Home'r
    • 10.11.2018
    • 60

    #1

    Plugin: Lox2MQTT

    Hi Folks,

    This plugin connects to the Loxone Miniserver websocket and the LoxBerry MQTT Gateway and publishes Miniserver control state changes over MQTT. In addition, control commands can be send over MQTT to control the Miniserver directly. More info at the Lox2MQTT wiki page

    NOTE: Still in BETA stage, so issues might occur. Please report your issues via GitHub
  • Meininger
    Smart Home'r
    • 30.11.2015
    • 60

    #2
    Hi nufke!

    Find the plugin very interesting and have also installed it on my Loxberry for some time to see how it works. Unfortunately I have not seen any data from your plugin in the MQTT part of the Loxberry so far. I have 2 miniserver, I named them under Miniserver Topic Name and entered them in the MQTT Gateway Subscriptions. But now it is so that neither in the MQTT Finder nor at incomming anything from your plugin is to be seen. If the checkbox publish control states is set, changes or operations from the miniserver should be sent to the MQTT gateway, or do I understand this wrong?
    I also set the log level to debug and looked what happens, there I see only one entry: "WebSocketAPI 192.168.179.xxx - close" ervery 2 seconds.
    Maybe it helps you.

    Greetings Sascha

    Kommentar

    • nufke
      Smart Home'r
      • 10.11.2018
      • 60

      #3
      Looks like the plugin does not find your miniserver(s)... The log should show something like this:
      Code:
      2023-05-02T21:19:03: INFO: Start logger
      2023-05-02T21:19:03: INFO: Lox2MQTT started
      2023-05-02T21:19:03: INFO: Lox2MQTT - register Miniserver 1
      2023-05-02T21:19:04: INFO: MQTT Client - connect
      2023-05-02T21:19:04: INFO: WebSocketAPI 192.168.1.xxx- connect
      2023-05-02T21:19:04: INFO: WebSocketAPI 192.168.1.xxx - authorized
      2023-05-02T21:23:18: INFO: Lox2MQTT try to stop
      2023-05-02T21:23:18: INFO: Lox2MQTT exit - SIGINT
      2023-05-02T21:23:18: INFO: Close Logger
      2023-05-02T21:23:18: INFO: MQTT Client - close
      2023-05-02T21:23:18: Websocket Connection closed: 1000 Normal connection closure
      Some things to check:
      The plugin creates a default configuration under config/plugins/lox2mqtt/default.json and should contain something like this:

      Code:
      {
        "miniserver": {
          "1": {
            "mqtt_topic_ms": "loxone",
            "publish_structure": true,
            "publish_states": true,
            "subscribe": true,
            "mqtt_topic_app": "loxberry/app",
            "icon_path": "/assets/icons/svg"
          }
        }
      }
      The number of miniservers listed should match with the ones listed in the loxberry general config.

      If this default config is missing or empty, something went wrong with the creation of the default configuration. If you have accesss to your loxberry via ssh, login, and goto the bin/plugins/lox2mqtt directory and rerun the configuration:
      Code:
      node create_config.js
      Then check if your default config has been created.

      What does the Lox2MQTT page show as PID at the bottom of the screen? Is it green and connected, or red, meaning disconnected?

      Kommentar

      • Meininger
        Smart Home'r
        • 30.11.2015
        • 60

        #4
        ​Hi Nufke,

        I have looked at it, the config file looks ok, both miniserver are entered correctly.
        Code:
        {
            "miniserver": {
                "1": {
                    "mqtt_topic_ms": "lox2mqttms1",
                    "publish_structure": false,
                    "publish_states": true,
                    "subscribe": true,
                    "mqtt_topic_app": "loxberry/app",
                    "icon_path": "/assets/icons/svg"
                },
                "2": {
                    "mqtt_topic_ms": "lox2mqttms2",
                    "publish_structure": false,
                    "publish_states": true,
                    "subscribe": true,
                    "mqtt_topic_app": "loxberry/app",
                    "icon_path": "/assets/icons/svg"
                }
            }
        }​
        At the bottom of the page is displayed in green that your plugin is running with the corresponding PID.
        What comes to my mind, my miniserver is not reachable under the standard port 80, but another port was used, but this is entered correctly on the configuration page in the Loxberry and on the page the connection is tested successfully.
        Klicke auf die Grafik für eine vergrößerte Ansicht

Name: Screenshot 2023-05-11 223807.png
Ansichten: 880
Größe: 342,8 KB
ID: 390917
        What do you need to connect to the miniserver?

        Greetings Sascha

        Angehängte Dateien
        Zuletzt geändert von Meininger; 11.05.2023, 22:42.

        Kommentar

        • nufke
          Smart Home'r
          • 10.11.2018
          • 60

          #5
          Implemented support of Miniserver ports other than 80 in version 0.2.3. Please check

          Kommentar

          • Meininger
            Smart Home'r
            • 30.11.2015
            • 60

            #6

            I have installed the new version and restarted, unfortunately still the same behavior in the log file, no connection to the miniserver is established.

            Kommentar

            • nufke
              Smart Home'r
              • 10.11.2018
              • 60

              #7
              Ok let's explore further... Can you check the following with 0.2.3:
              • Do you see the other log entries like log started, register, etc?
              • the plugin should not restart after exiting, so the PID should become red/unknown and no reoccuring entries in the log file.
              • Is the correct port number listed in the log? Since you use HTTPS, it should state 443 (from your general config)
              I expect the issue relates to the connection to Miniserver HTTPS port, so I will study this further. Unfortuantely I have no V2 Miniserver so I cannot test HTTPS. If possible for you, you could test with HTTP port 80 (or 5000 in your case), so we can confirm it relates to the port setting.

              Kommentar

              • Meininger
                Smart Home'r
                • 30.11.2015
                • 60

                #8
                Good morning Nufke,

                yes in the log file are all the other entries as seen in your example above.​

                Code:
                2023-05-11T23:30:43: INFO: Start logger
                2023-05-11T23:30:43: INFO: Lox2MQTT started
                2023-05-11T23:30:43: INFO: Lox2MQTT - register Miniserver 1
                2023-05-11T23:30:43: INFO: Lox2MQTT - register Miniserver 2
                2023-05-11T23:30:43: INFO: MQTT Client - connect
                2023-05-11T23:30:43: INFO: MQTT Client - connect
                2023-05-11T23:30:43: INFO: WebSocketAPI 192.168.xxx.xxx:443 - close
                2023-05-11T23:30:45: INFO: WebSocketAPI 192.168.xxx.xxx:443 - close
                2023-05-11T23:30:47: INFO: WebSocketAPI 192.168.xxx.xxx:443 - close
                2023-05-11T23:30:49: INFO: WebSocketAPI 192.168.xxx.xxx:443 - close
                2023-05-11T23:30:51: INFO: WebSocketAPI 192.168.xxx.xxx:443 - close​
                as you can see the port for the HTTPS communication is also entered.

                Now I deactivated the HTTPS communication as suggested and connected both miniserver only with HTTP, unfortunately this changes nothing in your plugin, in the logfile you can see that it still tries to communicate on port 443. Also a restart of the Loxberry brought no change.
                After a restart the plugin does not start automatically, PID is red, you have to start the plugin manually.​

                Sascha

                Kommentar

                • nufke
                  Smart Home'r
                  • 10.11.2018
                  • 60

                  #9
                  Thanks for the feedback. The plugin does not monitor yet if there are changes made to the general miniserver settings. I will add this to my list. For now, just hit the save button in the plugin config page.

                  Kommentar

                  • Meininger
                    Smart Home'r
                    • 30.11.2015
                    • 60

                    #10
                    I did that several times, the changes to the Miniserver configuration were still not accepted, port 443 remains despite saving and restarting.
                    .

                    Kommentar

                    • nufke
                      Smart Home'r
                      • 10.11.2018
                      • 60

                      #11
                      Can you check the value of the miniserver field "Preferhttps" in your general.json file? In my case it states "null" since it is disabled, because I have a Gen1 Miniserver. I expect you have something like "false" (as string with quotes). Can you confirm?

                      I also noticed I used the old and wrong authentication method, which was still working for my Gen1 Miniserver but most likely not for Gen2. The plugin now it uses the recommended token-based approach. This might explain the issue with connecting to your Miniservers.

                      I uploaded v0.2.4. Since I did not implement detection of the general.json changes, after changing the Miniserver settings, restart the plugin by doing a save/apply in the plugin config window. Just try this one and report your findings

                      Kommentar

                      • Meininger
                        Smart Home'r
                        • 30.11.2015
                        • 60

                        #12
                        Hello Nufke,

                        sorry for my late reply....

                        First, with the new version of the plugin it also works for me, both miniserver are connected and deliver data. It does not matter whether HTTP or HTTPS is selected or not. Your plugin always connects via HTTP to the miniserver.
                        Here is the excerpt from the​ general.json:

                        Code:
                        "Port": "5000",
                        "Porthttps": "443",
                        "Preferhttps": "1",
                        "Securegateway": "",
                        "Transport": "https",
                        "Useclouddns": "0"​
                        I hope that this could all help a bit further.
                        Now I have to see how I reduce the thousands of values to the meaningful and can also use accordingly.

                        Greetings Sascha​

                        Kommentar

                        • nufke
                          Smart Home'r
                          • 10.11.2018
                          • 60

                          #13
                          Great to hear it is working now. In v0.2.4 I check if Preferhttps is "true", but based on your info I see it uses "1" instead. I will update this in the next release later today or tomorrow, then you could also check https.

                          Do you have a specific use case in mind to process/use this data? My use case is to pass all this data via MQTT to a new LoxBerry App for my tablets and mobiles. If you have specific ideas/requirements, just let me know and I can see if that fits into the Lox2MQTT concept.

                          Kommentar

                          • nufke
                            Smart Home'r
                            • 10.11.2018
                            • 60

                            #14
                            v0.3.0 available. Updates to system configuration or plugin configuration are now detected and will restart the plugin automatically. You can now also login to the Miniserver(s) using different credentials other than the admin which is specified in the general Miniserver settings. More changes listed in the CHANGELOG.

                            Kommentar

                            • Meininger
                              Smart Home'r
                              • 30.11.2015
                              • 60

                              #15
                              Hello,

                              could now also test the new version of the plugin.
                              Here it is now so that if HTTPS is activated in the settings, it is also tried to communicate on the appropriate port, which is not successful. In the log file only the message "close" can be found again.
                              For the plugin to work again, the HTTPS connection must be explicitly disabled in the Miniserver communication.

                              Greetings Sascha​

                              Kommentar

                              Lädt...