This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.

[APP] MQTT Broker for Homey

edited November 2017 in Apps

MQTT Broker for Homey

Today the MQTT Broker App has been released in the App store beta channel.

With this App it is now possible to have a complete MQTT Broker on Homey. The app is based on the Mosca nodejs library. The Mosca library is a library that is used to implement a MQTT Broker on a web based platform using nodejs.

So you no longer need to install a MQTT Broker on a NAS, homeserver or use a MQTT Broker in the cloud. You can simply install one on your Homey (https://apps.athom.com/app/nl.scanno.mqttbroker ).

What is a MQTT broker?
A MQTT Broker is a service that provides a Publish / Subscribe mechanism often used in IoT solutions. This means that an App or Device can subscribe to a topic. When another App or Device publishes a message on that topic, all Apps or devices subscribed to that topic, will receive that message.

What do I need?
You just have to install the MQTT Broker for Homey App and go to its settings page. There you have to provide the IP port you want the broker to listen on for messages. If you don't know what to enter there, use the default 1883 value.
Second you will need to enter usernames and passwords for Apps or Devices that need to have access to the Broker. Answer that's it.

What is planned:
- ACL on topics

Comments

  • Fire69Fire69 Member
    edited September 2017
    Just installed it, haven't been able to test it but did notice some typos :p


    To connect from the outside - like with Owntracks on your cellphone - I suppose you need to use your external IP in Owntracks and forward the chosen port in your router?
  • @Fire69 correct.
    You have to do a port forward on your router to homey.

    Regarding your external ip Adress, if you don't have a dns address and a dynamic IP Adress, you could think about using a DDNS provider. 

    And yes there are some typos and still some missed resources 
     
  • There is a new beta version available in the App store.
    The new version includes the ability to enable TLS.

    Using TLS requires a X509v3 certificate and private key. You can either generate a key and selfsigned certificate in settings (please wait a few seconds after pressing the generate button. Generating the private key takes a while...). Or provide a private key and certificate chain yourself. They should be in PEM format.

    If there are any problems or questions, please let me know.

    Remember this is still beta software,
  • Selfsigned certificates


    With the MQTT broker for Homey it is possible to generate selfsigend certificates to enable TLS connections. Using offically signed certificates is always better, but not everybody knows how to do this and even with a service like Letsencrypt it is still difficult to do so without having a running HTTP server that is connected to the internet.

    Generating a selfsigned certificate is very easy with the MQTT Broker for Homey. After you have installed the MQTT Broker for Homey from the App Store, go to the settings page an go to the Session Settings. On that page check the Generate a selfsigned certificate checkbox.

    In the CommonName field enter the DNS name where your Homey resolves to (or use the internet IP adress). As default the Days Valid field is set to 365 days. That means that the certificate will be valid for 365 days. After 365 days you will need to generate a new one.



    After entering the CommonName field, just press the Generate Certificate button to start generating the selfsigned certificates. Please be patient because it can take up to 30 seconds (or more) until the generation has been completed.

    Once generation has been completed, you will see the Private key and Certificate text boxes filled with data:




    After the text boxes are filled, the generation process has finished. Press the Save certificate button to save them the the internal storage of homey.

    Make sure you have enabled TLS also:



    The secure connection will be available once you Stop en Start the Broker again:



    Please enable Selfsigned certificates in apps like the Owntracks client and MQTT client if you use them.



  • AlleAlle Member
    After installing the broker i get the following error and the broker fails to function.

  • Alle said:
    After installing the broker i get the following error and the broker fails to function.



    That's a normal error. The file doesn't exist yet and is newly created. What doesn't work? Did you add users? 
  • AlleAlle Member
    Alle said:
    After installing the broker i get the following error and the broker fails to function.



    That's a normal error. The file doesn't exist yet and is newly created. What doesn't work? Did you add users? 
    When i install the app i get the message that my Homey unreachable. But the app is installed



    The broker does not start. I can add users, but they don't show in the settings page. 

  • @Alle try restartimg the app. Installing the broker is sometime too heavy for Homey. The other settings are correct? Port numbers etc?
  • EddepetEddepet Member
    HI,

    I have Homey now for 10 days and now I am trying to install MQT on my Homey.. Unfortunately I do not understand very well above. Can someone explain me in Dutch Jip en Janneke language what i have to do ? <span>:smile:</span>

    For now I installed MQQT Client, MQQT Broken en Owntracks Clients on Homey. My goal is that Homey sees accurately when I (and my girlfriend) are at home and when not.


  • EddepetEddepet Member
    edited May 2018
    Ok. I have a MQTT server now and connected my phone and Homey :) 
    Now I have to find out what the advantage is of client and broker.

    Is this link up2date ?
    https://forum.athom.com/discussion/2804/setup-homey-with-mqtt-for-location-detection

  • cbhcbh Member
    Try https://www.hivemq.com/resources/ for a rather good introduction to MQTT
  • AlleAlle Member
    @Alle try restartimg the app. Installing the broker is sometime too heavy for Homey. The other settings are correct? Port numbers etc?
    After a few reboots/installs the broker works.
Sign In or Register to comment.