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.

[PUBLISHED] Mosquitto MQTT client app

JohanKusterJohanKuster Member
edited April 2016 in Apps
I am currenty working on a MQTT client app that makes it possible for Homey to publish/receive message to/from a MQTT message broker. I am only testing the for the Mosquitto broker but it will probably work for most of the brokers out there. 

In the app setting you have to specify the url where the broker can be found:



In the flow editor you have a trigger (receive message) and action (publish message):



In the end the following should be possible. Replace Domoticz with Homey and place Mosquitto and Node-Red on eg a PI. You can now interact with many more devices/sensors and almost anything that is connected to the internet.


I will try to get this working as soon as possible. No promises here ;-) since most of the stuff I am doing is new to me. 

Remarks are welcome
«1

Comments

  • Nice. Would love to have a send all option.  I use Mosca. A simple and fast mqtt broker written in nodejs. You can run it as a standalone service or embed it into your node application
  • Great
  • Would this work? I am a noob in this section, but I think for this price I would give it a try.

    https://www.itead.cc/smart-home/sonoff-wifi-wireless-switch.html
  • Any idee when we could test it

  • TarikFaik said:
    Any idee when we could test it

    I do my best to have the first version ready in 2 weeks. Have problems at the moment when using more than 1 queue
  • @JohanKuster Oke thanx 
  • This will be awesome, thank you so much!
  • MarkSwiftMarkSwift Member
    edited April 2016
    I just posted a comment to your github, thanks for building this!

    Any particular restrictions with the current version?

    Perhaps submit it to the Appstore!

    Edit: I'm new to MQTT, does it handle acknowledgements, so we can ensure message is sent / received? I Plan to try the MySensors MQTT client connected to Mosquito. ***Update: Got it working***.

    Edit 2: Seems to work great, I have a number of flows that use better logic and variables, my plan is to pipe the MQTT messages into the variables. Right now it looks like I need to create a flow for every MQTT message I want to pipe into a variable, can you think of a more efficient way of doing this? For example, I have 2 sensors, when they're both "ON" I need to trigger sensor 3.
  • Read it very carefully  ;)

    MQTT Client for Homey

    This app makes it possible to subscribe to messages available on a message broker. Messages can also be published on the message broker.

    The app has a trigger with an argument where you have to define the topic you are subscribing to. There is a token "message" that will contain the message received.

    There is an Action where a message on a topic can be send to the broker.

    In the app setting an URL where the broker can be found must be entered. Format is like 192.168.1.40:1883. At the moment I assume that the broker is in your local network, probably installed on a Raspberry Pi together with Node-red :wink:.

    Because there is a kind of chicken and egg problem here, you need to reboot/unplug the homey after you have defined the URL and first active trigger. A new trigger will work after any other active trigger was triggered. Of course you could also restart your Homey.

    What works:

    • Multiple topics, triggers and actions can be used
    • The same topic can be used more than once
    • works for Mosquitto MQTT broker but probably also for any other broker that supports MQTT.

    What doesn't:

    • Use brokers that require username/password
    • Starting from scratch without restarting Homey

    Future enhancements:

    • Support username password
    • More than one broker?
    • No reboot necesarry
  • MarkSwift said:
    I just posted a comment to your github, thanks for building this!

    Any particular restrictions with the current version?

    Perhaps submit it to the Appstore!

    Edit: I'm new to MQTT, does it handle acknowledgements, so we can ensure message is sent / received? I Plan to try the MySensors MQTT client connected to Mosquito. ***Update: Got it working***.

    Edit 2: Seems to work great, I have a number of flows that use better logic and variables, my plan is to pipe the MQTT messages into the variables. Right now it looks like I need to create a flow for every MQTT message I want to pipe into a variable, can you think of a more efficient way of doing this? For example, I have 2 sensors, when they're both "ON" I need to trigger sensor 3.
    Great the you've got it to work properly. 

    I can't think of any better way to solve your 3 sensor problem. Looks pretty interesting already. We need to wait untill Homey allows more than 1 trigger in a flow.
  • I could think of a way. Make a message card with two tokens, key and value. Then use something like the mathjs logic card to set the value. If you want this I could see if I can make a setter card with no restrictions on the to variable, but instead allow a drop token as variable name. 
  • Don't know if I did something wrong here, but it only connects to my synology NAS when I use the IP adress.

    Giving in DS215j:1883 wont connect, is that correct? 
  • sj3fk3sj3fk3 Member
    Wishlist:
    • Feedback on connection (is client connected ok)
    • Example of topic syntax (do you use '/topic', 'topic' or /topic/#')?
    n.b.
    I've got Plugwise-py, Fibaro HC2, node-red and Domoticz working just fine with a single Mosquitto broker, but can't get a incoming trigger from Homey..
  • sj3fk3sj3fk3 Member
    Don't know if I did something wrong here, but it only connects to my synology NAS when I use the IP adress.

    Giving in DS215j:1883 wont connect, is that correct? 
    That would depend on your network setup, but since homey uses a google-dns. I would say yes, that's as expected.
  • PetePete Member

    Remarks are welcome
    Questions too, I hope? :) Can you please give some examples regarding real-life applications for Mosquitto and Homey? That is, how will Homey benefit by having Mosquitto support?
  • MQTT is a very lightweight communication protcol and can be used to connect all kinds of stuff. Do take a look here: https://github.com/mqtt/mqtt.github.io/wiki it has a couple of examples 
  • Do you plan to be able to log any of the data to the insights page?   This would be really useful as people can start to make Humidity, temperature, light loggers and easily graph the data with a simple Arduino, without having to create a dedicated app
  • PBaan93PBaan93 Member
    edited September 2016
    AndyWilde said:
    Do you plan to be able to log any of the data to the insights page?   This would be really useful as people can start to make Humidity, temperature, light loggers and easily graph the data with a simple Arduino, without having to create a dedicated app
    This can probebly be done with the better logic app. Update V0.10 of better logic brought :
    • Feature: Turn on insights for boolean and number values. Existing variables will also be turned on
  • @JohanKuster I saw username and password support are on the to do list. I realy would like that! @MennoVanGrinsven has done a nice Job on intergrating this, maybe you could take a look at his code on this part? 

  • @JohanKuster ;
    The app is working fine for me. I use it to let domoticz send text to the speech engine.
    After the app is running a few days it , it sends (reads) everything multiple times , the longer it tuns the more repeats.
    after an app restart it is fine again.

    is this something you have seen more?
  • ArenBreur said:
    @JohanKuster ;
    The app is working fine for me. I use it to let domoticz send text to the speech engine.
    After the app is running a few days it , it sends (reads) everything multiple times , the longer it tuns the more repeats.
    after an app restart it is fine again.

    is this something you have seen more?
    Yup, same problem here... I can reproduce it by resetting my Rpi (the mqtt hosts) all msgs double.. Reset again and they tripple.. 

    Looks like this app does not check existing connections, it should try to reuse first I think. 
  • Will this app be updated? It's incompatible with The latest homey version.
  • +1
    It would be greatly appreciated if someone can update it.
    Maybe it's only a limitation of the version-number in the installer (just hoping :) ) ?
    @JohanKuster

  • +1
    It would be greatly appreciated if someone can update it.
    Maybe it's only a limitation of the version-number in the installer (just hoping :) ) ?
    @JohanKuster

    Yves,  I will do my best and start working on it. Somebody else was supposed to takeover my app. 
  • Hi Johan

    Thanks for the effort.
    BTW: my message was by no means to put pressure on you (or somebody else).
    I only wanted to emphasise the fact that the app could be useful to some people, and that it would be a shame if your initial work on the app would be waisted if nobody did anything with it anymore.

    Take this as a big thank you to EVERYBODY that is working on ANY app. You're doing a really great job !
  • I downloaded the code from github, changed the version number of the Homey firmware in the app.json file and it was running fine.
  • That's what I was hoping for.
    If that's all there is to, what are the steps you (/we/I) have to take, to update it on github and ask Athom to update it in the app store ?
  • +1
    It would be greatly appreciated if someone can update it.
    Maybe it's only a limitation of the version-number in the installer (just hoping :) ) ?
    @JohanKuster

    Yves,  I will do my best and start working on it. Somebody else was supposed to takeover my app. 
    I would have started on using my owntracks app to make a generic MQTT app, but could not find the time yet. 

    Sorry about that. 
  • Waiting for approval...
  • Waiting for approval...
    Johan, https://github.com/scanno/nl.scanno.mqtt

    Almost done.

Sign In or Register to comment.