more G-Labs products

Author Topic: Help with input from MQTT source  (Read 800 times)

February 20, 2016, 11:24:00 PM
Read 800 times

gmeister

  • *
  • Information
  • Newbie
  • Posts: 1
I have made a wireless SmartButton using an ESP8266-01.  When the button is pushed it sends a message to the MQTT broker that simply says "ESP8266/16494995 Payload: Button pushed".  The only important part is the ESP8266 serial number (16494995) so that I know which SmartButton was used, since I could eventually have several of them in use. 

I want to have HomeGenie recognize when this specific message has been received by the MQTT broker.  I suspect that I have to have HomeGenie subscribe to the topic "ESP8266/16494995", raise an event when the message is detected, and then energize a virtual input to indicate that the button has been pushed.  But I am at a complete loss as to how accomplish this in HomeGenie.

I am not a programmer, but I have been using HomeGenie for quite a while, at a very rudimentary level.  Could someone please give me some pointers on how best to proceed?

Thank you.





February 22, 2016, 04:53:52 PM
Reply #1

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
The built-in MQTT code is somewhat useful, but I used CptJack's code as the base for mine.

http://www.homegenie.it/forum/index.php?topic=758.0

Basically, you subscribe to either all or a specific set of topics and use C# to parse through.  In my case, I look for topics that indicate the sensor that generated the data (weather station, power meter, temperature sensor), but you could do it your way too.  Then, read the payload and parse it as necessary.  It's fairly straight forward.  Basically, take the MySensors code and modify it as needed.