MCP23017 <=> MQTT bridge

Every time I migrated to the new version of openHab I had huge problems with launching the MCP23017 bindings. Recently I switched to openhab 2.5.10 and the problem appeared again (Cannot start MCP23017 binding for openHAB 2.5.10-1). I said enough and wrote a small program MCP2MQTT for myself. The method of operation is simple, data from MCP inputs are sent to MQTT topics and what is supposed to go to MCP outputs is also received from MQTT topics. The program is very simple and adapted to my needs but can be a starting point for people who have similar problems.

In rules you can use like this:
-output
Switch WtrValveFront <water> {mqtt=">[mosquitto:mcp23017/20/A/output/0:command:ON:1],>[mosquitto:mcp23017/20/A/output/0:command:OFF:0]"}

-input
Switch FloorHeatingAuto “Ogrzewanie podlogowe automatyka” {mqtt="<[mosquitto:mcp23017/21/A/input/1:state:default]"}

Right now it use old MQTT binding but there is a plan to migrate to newer verion of this binding.

Source fies can be found here:

MichaƂ SzymaƄski

When you do, check out this page as it contains a guide to move from v1 to V2:

2 Likes

When I free time for sure I will make it, I spent to much time to create this small program and modify my existing rules :slight_smile:

Another thing you can do if you want to have some remote IO around the house is to connect one to tasmota using a ESP8266

I’m using sonoff + shelly. But MCP23017 is used to control all devices that are conected using wires.

1 Like

@Michal_Szymanski thank you very much for sharing your script. You are right, there are a lot of problems with the MCP binding and I am not sure if it will ever works with OH3.
For my needs your solution is much better, because I can put some logic into the script easily. Before I had to solve it with a lot of rules in OH.
Thank you very much :slightly_smiling_face:

I do want even check it :slight_smile: That is why I decided to write my own program. Program is limited to my case but after small modification everyone can customize it.