Hi everyone,
I’ve been working on modernizing the MCP23017 binding for OpenHAB 4.3 to resolve compatibility issues I encountered on a Raspberry Pi 5. Despite my efforts, I couldn’t get the existing implementation to work, even after patching the Pi4J library.
To address this, I’ve rewritten the binding to replace the Pi4J dependency, which is no longer maintained, with a new implementation that directly communicates with I2C via Libc. This change should make the binding functional across all Linux environments. The updated code is available on GitHub:
GitHub Repository - MCP23017 Binding for OpenHAB 4.3
Key Changes
- Removal of Pi4J Dependency
- Pi4J has been replaced with a direct Libc-based I2C communication implementation.
- Configuration Compatibility
- The binding remains configuration-compatible. The technical implementation has been updated, but OpenHAB configurations, items, things, and rules should not require changes.
- Behavioral Improvements
- If the I2C communication is interrupted, the thing status changes to OFFLINE and returns to ONLINE once communication is restored.
- Registers of the MCP23017 are checked regularly (every ~5 seconds). Any deviations from the desired values are automatically corrected.
Open Issues
- Logging
- Currently, everything is logged at the
ERROR
level. This will be adjusted in the final version.
- Startup Issue
- When starting OpenHAB, items do not automatically bind to the channels of the MCP23017 thing. I need to manually remove and re-add the items to establish the connection.
- If anyone has insights or suggestions on what might cause this issue, I’d appreciate your guidance!
Next Steps
Once the open points are resolved, I’d be happy to submit a pull request to contribute these changes back to the OpenHAB project.
I’d greatly appreciate any feedback on the implementation, as well as any suggestions for addressing the startup issue. Thanks in advance for your help!
Best regards,
Igor