Posting a reply I made on another thread as a new topic to possibly get better visibility
All,
I am working on a project where I wish to include some contact sensors in a building into openhap using a remote RPi and the GPIO binding. After prototyping things, I found a few issues with the binding. One issue is the lack of reconnect to pigpiod. The other is any form of gpio pin state sync.
With that said, I started digging into the binding code to see what was up. So far I’ve managed to correct the pigpiod reconnect. The binding now supports a heartbeat to detect connection failures.
I’ve also added some configurable actions for when the binding connects or reconnects.
An example Thing config:
Thing gpio:pigpio-remote:shoppi "ShopPi GPIO" [ host="192.168.164.5", port=8888,
heartBeatInterval=10000,
inputConnectAction="REFRESH",
inputDisconnectAction="NOTHING",
inputReconnectAction="REFRESH",
outputConnectAction="REFRESH",
outputDisconnectAction="NOTHING",
outputReconnectAction="REFRESH" ] {
Channels:
Type pigpio-digital-output : BCM18 [ gpioId=18 ]
Type pigpio-digital-input : GPI23 [ gpioId=23,debouncingTime=30,pullupdown="UP",invert=true ]
}
heartBeatInterval:
- Time in ms to check the state of the pigpiod process. This is done by issuing a CMD_TICK on the command socket.
inputConnectAction inputReconnectAction:
- REFRESH - Issues a refresh on the input channels at INITIALIZING connect. This reflects the gpio pin value back on the channel.
- NOTHING - Do nothing (existing binding behavior).
inputDisconnectAction:
- SETUNDEF - Set’s the input channesl to UNDEF
- NOTHING - Do nothing
outputConnectAction:
- ALLON - Set’s the output channels to ON at INITIALIZING connect, commanding the gpio pin.
- ALLOFF - Set’s the output channels to OFF at INITIALIZING connect, commanding the gpio pin.
- REFRESH - This reflects the gpio pin value back on the channel.
- NOTHING - Do nothing.
outputDisconnectAction:
- SETUNDEF - Set’s the output channels to UNDEF
- NOTHING - Do nothing
outputReconnectAction
- REFRESH - Issues a refresh on the output channels at reconnect. On reconnect, the gpio pin value may reflect on the channel state UNLESS a channel item has been commanded to change. This one was confusing to me. It appears that OpenHAB queues channel commands until the Thing goes back online. This negates the REFRESH.
- NOTHING - Do nothing (existing binding behavior).
Few questions:
- While this code is fresh in my mind. I would like to submit for feedback on the functionality.
- Request any other functionality (as long as it is reasonably doable).
- Find some folks other than me that may be willing to test.
I have made a build available: here
Code is: here
Build was made with:
openjdk 11.0.14 2022-01-18 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.14+9-LTS)
Regards,
Jeremy