Domoticz now supports the MySensors MQTT Gateway



  • I just wanted to share my latest discovery. Domoticz now supports the MySensors MQTT Gateway.
    A push was made by Rogier Reedijk, xs4free in November. Thanks Rogier, really great stuff! This was the main reason why I personally didn´t use Domoticz before as a controller. For the moment it's only available as Beta version.
    Pls. have a look at the Domoticz Wiki page, showing how to setup the MySensors MQTT GW in the Domoticz environment.



  • Hi @jpaulin, can you explain how you got this working with MySensors?

    As far as I can tell, MySensors and Domoticz use very different MQTT message formats.

    Some examples:
    MySensors:

    mygateway1-out/2/1/1/0/49 55.722519;13.018121;13
    

    Domoticz:

    { "idx" : 222, "nvalue" : 0, "svalue" : "22.5" }
    

    Note: I can publish to the 'domoticz/in' topic from the command line OK:

    mosquitto_pub -h 192.168.0.63 -m '{ "idx" : 222, "nvalue" : 0, "svalue" : "22.5" }' -t 'domoticz/in'
    

    (this updates a dummy temperature node in Domoticz) , so I know that MQTT is working in Domoticz.



  • As a newbie that only so far built 2 sensors and a serial gateway.

    What is better with this kind of gateway?
    Should I build one instead of the serial one I use now?



  • @MikeF
    Domoticz can now interpret the MySensors MQTT format from a MySensors MQTT Client Gateway without JSON stuff, it's straight forward. To make it work just change the Topic Prefix in the MySensors Gateway and the rest is solved under the hood. Auto discovery etc works now as any other MySensors Gateway with Domoticz.

    Change in your MQTT GW setup:

    #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
    #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
    

    To:

    #define MY_MQTT_PUBLISH_TOPIC_PREFIX "domoticz/in/MyMQTT"
    #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "domoticz/out/MyMQTT"
    

    The MQTT Publish and Subscribe topic prefixes are hardcoded in Domoticz.
    And of course an MQTT broker is needed.



  • @meanmrgreen
    MQTT being a standard protocol and widely used opens a lot of doors for flexibility, mixing and integrating different kind of solutions. MySensors offers some MQTT Client Gateways. If you are ok with the serial gateway and with your setup you wouldn't gain much changing your gateway.



  • @jpaulin

    I havent built much yet so i gain nothing by replacing my serial gateway with a mqtt?
    using domoticz/rflink



  • My biggest "problem" with domoticz and Mysensors setup is upgrading nodes. Right now procedure Im using is stopping gw in domoticz, running ser2net on rpi. On my desktop i strat Myscontroller and connect via tcp/ip to rpi/ser2net. After upgrading node i stop ser2net and start gw in domoticz. Is it possible to upgrade node with mqtt? That would remove need to stop gw in domoticz.



  • @jpaulin said:

    @MikeF
    Domoticz can now interpret the MySensors MQTT format from a MySensors MQTT Client Gateway without JSON stuff, it's straight forward. To make it work just change the Topic Prefix in the MySensors Gateway and the rest is solved under the hood. Auto discovery etc works now as any other MySensors Gateway with Domoticz.

    Thanks for this, @jpaulin - I'll build an MQTT / ethernet gateway and see how I get on.



  • This post is deleted!


  • This post is deleted!


  • Got this working OK. I built a MQTT / W5100 gateway as per the instructions in the MySensors Build section, and changed the topic prefixes and controller IP address in the example sketch.

    Initially this failed, as I had connected Vcc on the W5100 to 5V instead of 3.3V, and I had the prefixes the wrong way round (i.e., /out instead of /in).

    (BTW: I'm using MySensors 2.1.0 and Domoticz 3.6371 - latest / recent beta.)



  • @siklosi
    mqtt wouldn't do the job to upgrade your nodes or gw. One alternative I'm using. I have some ESP8266-01 mqtt gw working with ota, with sensors wired directly to the gw and put in places hard to reach. They are upgraded over the air directly from the Arduino IDE over WIFI. Following this example explains how. https://github.com/mysensors/MySensors/tree/master/examples/GatewayESP8266OTA



  • @MikeF excelent you finally got it up and running. It's easy to get confused with in/out - topic format swapped between MySensors and Domoticz.



  • Hey, I've been trying for a few weeks now to get Domoticz to talk to MQTT GW. Without success. It connects to the RPI 2 B directly. If you look in the log for mosquitto it will connect there. Sometimes I get socket error and disconnects. But no connection to Domoticz.

    What are I doing wrong? Have reinstalled the software at RPI 2 B many times without any difference.

    Log mosquitto

    Insert Code Here
    ```1484960555: New connection from 192.168.0.178 on port 1883.
    1484960555: New client connected from 192.168.0.178 as mysensors-1 (c1, k15).
    1484960921: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484961568: Client mysensors-1 has exceeded timeout, disconnecting.
    1484961568: Socket error on client mysensors-1, disconnecting.
    1484962722: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484964523: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484966324: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484968125: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484969926: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484971727: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484973528: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484975329: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484977130: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484978931: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484980732: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484982533: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484984334: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484986135: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484987936: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484989737: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1484990881: New connection from 192.168.0.178 on port 1883.
    1484990881: New client connected from 192.168.0.178 as mysensors-1 (c1, k15).
    1484990917: Socket error on client mysensors-1, disconnecting.
    

    And W5100 GW log

    Insert Code Here
    0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.0
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;TSF:WUR:MS=0
    0;255;3;0;9;TSM:INIT:TSP OK
    0;255;3;0;9;TSM:INIT:GW MODE
    0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
    0;255;3;0;9;MCO:REG:NOT NEEDED
    IP: 192.168.0.178
    0;255;3;0;9;MCO:BGN:STP
    0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
    IP: 192.168.0.178
    0;255;3;0;9;Attempting MQTT connection...
    0;255;3;0;9;MQTT connected
    0;255;3;0;9;Sending message on topic: domoticz/in/MyMQTT/0/255/0/0/18
    0;255;3;0;9;TSF:MSG:READ,21-21-0,s=1,c=1,t=0,pt=7,l=5,sg=0:14.0
    0;255;3;0;9;Sending message on topic: domoticz/in/MyMQTT/21/1/1/0/0
    0;255;3;0;9;TSF:MSG:READ,21-21-0,s=0,c=1,t=1,pt=7,l=5,sg=0:40.0
    0;255;3;0;9;Sending message on topic: domoticz/in/MyMQTT/21/0/1/0/1
    
    And Domoticz Log
    
    

    Domoticz Log

    2017-01-21 09:38:08.641 (MySensors Lan) Temp + Humidity (TempHumSrum)
    2017-01-21 09:47:34.718 (MySensors Lan) Temp + Humidity (TempHumSrum)
    2017-01-21 09:49:40.736 (MySensors Lan) Temp + Humidity (TempHumSrum)
    2017-01-21 09:59:06.819 (MySensors Lan) Temp + Humidity (TempHumSrum)
    2017-01-21 10:01:12.836 (MySensors Lan) Temp + Humidity (TempHumSrum)
    2017-01-21 10:10:39.914 (MySensors Lan) Temp + Humidity (TempHumSrum)
    2017-01-21 10:12:45.932 (MySensors Lan) Temp + Humidity (TempHumSrum)
    2017-01-21 10:22:12.010 (MySensors Lan) Temp + Humidity (TempHumSrum)
    2017-01-21 10:24:18.028 (MySensors Lan) Temp + Humidity (TempHumSrum)
    2017-01-21 10:33:44.106 (MySensors Lan) Temp + Humidity (TempHumSrum)
    2017-01-21 10:35:50.124 (MySensors Lan) Temp + Humidity (TempHumSrum)
    2017-01-21 10:41:40.606 MQTT: Connecting to 192.168.0.178:1883
    2017-01-21 10:43:47.836 Error: MQTT: Failed to start, return code: 14 (Check IP/Port)```
    

    //Mattias



  • @MLs In your Domoticz log I see messages with the format "MySensors Lan". Have you chosen correctly the new MySensors MQTT Type in Domoticz? You should see "MySensorsMQTT" messages in the log. This new hardware choice is only available through the new Domoticz Beta version, for the moment.

    Hardware setup screen:
    0_1485095777911_Domoticz Setup.png

    Select "MySensors gateway with MQTT interface." Add the Mosquitto IP address and Port address 1883. It is recommended to first clear the cache in your web browser. Otherwise the screen in your browser sometimes fails to show the new fields correctly.

    I would as well recommend to install an MQTT debugging software. Personally I'm using MQTT-Spy. It's a java application, easy to install on e.g. a PC, connected to the same WiFi network, to listen to your MQTT traffic remotely what's going through your Mosquitto broker in your RPI. Then there's no need to connect to the nodes, gateways or RPI when checking the mqtt events.



  • Yes, i have lan to because I have several GW.

    0_1485098286725_Domoticz_Hardware.png

    And I turn them off when I do not try to solve the problem to reduce the log in Domoticz.
    I'll try a MQTT debugging software.

    But I think my problem lies in the software at RPI 2 B. Thus, communication between MQTT and Domoticz.

    //Mattias



  • @MLs Check this thread from the Domoticz forum about Mosquitto issues with return code 14 (seen in your log).
    https://www.domoticz.com/forum/viewtopic.php?t=14263



  • Thanks for the link but has already read it and also other pages with solutions to problems regarding MQTT.
    Now I will not use MQTT but still want to identify the problem I have.

    //Mattias


  • Mod

    I'm running mysensors mqtt gateway on rpi3, it is publishing to the topic specified in the domoticz configuration guide, I can see the messages being published in mqtt but nothing is showing up in domoticz; looking at the log I can only see the controller connecting without errors ; if I publish data to a dummy sensor as described in the guide it works, so there must be something wrong in the processing of the mysensors messages. Any ideas where to look?



  • @gohan
    Unlike ordinary MQTT gateway that deals with messages to/from all devices, Mysensors MQTT Gateway will only publish messages to the sensors created VIA itself. So, just creating a dummy sensor in Domoticz will not work.
    You have to create a virtual node by publishing to domotinz/in/MyMQTT
    For example (based on Serial API example): domoticz/in/MyMQTT/12/6/0/0/3/"My Light"

    "MyLight" is a payload

    This will create a virtual node #12, child #6. Create a switch based on the node.

    THEN you can monitor the node, by monitoring domoticz/out/MyMQTT/12/6/1/0/2/

    it will publish "1" or "0"


  • Mod

    I am trying to follow the guide -> https://www.domoticz.com/wiki/MySensors#Configuring_Domoticz_to_use_the_MQTT-gateway but actually I am now noticing that is missing the device type "MySensors Gateway with MQTT interface" and in fact I mistakenly added the normal MQTT Client gateway.... I wonder why it has been removed...



  • @gohan the guide was created long time ago, while Mysensors MQTT gateway was added in December


  • Mod

    @Toyman
    The page has been modified on 3 December 2016, it isn't that obsolete

    PS I found it, I had to manually update to beta version. I'll test it in the following days


Log in to reply
 

Suggested Topics

  • 5
  • 1
  • 5
  • 3
  • 2
  • 2

14
Online

11.4k
Users

11.1k
Topics

112.7k
Posts