Guys, you can use pimatic-johnny-five for this purpose. It supports a variety of expanders which can be connected to Raspberry Pi, an Arduino connected via USB, or an remote board connected via LAN or WiFi.
Please be aware, that pimatic-johnny-five should not be installed via pimatic-mobile-frontend as this installation process will run as root which currently causes a build error. The package should be installed from the command line instead without root privileges. See also https://forum.pimatic.org/topic/1174/new-plugin-for-johnny-five for details.
I would like to watch the I2c Expander, too and if one of the 16 Ports changes the state, a rule turns a device off or on.
With pimatic-johnny-five you can define devices for expander inputs and outputs. The device types used are based on pimatic base device types like contact, presence, switch. Thus you can easily define pimatic rules like if jf-di-1 is closed then switch jf-do-4 on
.
# plugin
{
"plugin": "johnny-five",
"debug": true,
"boards": [
{
"id": "1",
"boardType": "raspi-io"
},
{
"id": "3",
"boardType": "expander",
"port": "1",
"controller": "MCP23017"
}
]
},
# devices
{
"id": "jf-do-4",
"name": "Johnny Five Expander Output",
"class": "JohnnyFiveSwitch",
"boardId": "3",
"pin": "8"
},
{
"id": "jf-di-1",
"name": "Johnny Five Expander Input",
"class": "JohnnyFiveButton",
"boardId": "3",
"pin": "7"
},
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law