About Us Knowledge Base Community Forum Electronics Toolbox FAQ Shipping & Delivery

Community Forum

Share your projects and post your questions

Search
Register or Sign In
Forum

IO Pi Plus & Mosquitto MQTT

1148 Views - Created 19/12/2017

19/12/2017

Posted by:
PJ Bear

Users Avatar

Location:
Devon

I have been using these boards with Home assistant however wish to have more inputs than I can with 4 boards direct on to a Pi.  As I use MQTT for the main parts of the house automation using Mosquitto as the broker I thought the best way forward would be to have another Pi with the boards attached and for that to read the pin and send an MQTT message to the broker where Home Assistant could be subscribed to and then react.

It would be great to do this the outher way round as well so Home Assistant could publish a MQTT messge and the Pi could then turn on the output.

So I know what I want to happen and that it can be done but I do not know how in python to program the boards and to interface with the Mosquitto python library.

 

Is there a great python programmer that can help me I do not think it should be very hard to achieve - if you know how to program python.

 

If I can get this to work it will allow endless automations and real life onteraction

Pete

20/12/2017

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

Hi Pete

I found this tutorial on using MQTT with the Raspberry Pi and Python.

http://www.ev3dev.org/docs/tutorials/sending-and-receiving-messages-with-mqtt/

The code in the subscriber example could be modified to work with the IO Pi library.  You would need to add your code into the on_message function so it checks to see if a certain message has been received and if so it can then send the command to the IO Pi to read or write to the pins.

AB Electronics UK Tech Support

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.