Hi all. I have a USB IR Reader attached to a Raspberry PI, which works correctly with the Smartmeter binding. That is, it works correctly for a period of time before it suddenly stop working, spitting out the error “Serial port /dev/ttyUSB0 not found or port is busy”. Disabling and re-enabling the Thing doesn’t help. Restarting openhab (“sudo systemctl restart openhab”) does the trick though. This leads me to believe that it’s the java process itself that locks the port.
Any ideas on the cause of this or a possible work around (that could preferably be implemented as a rule)?
It always is java to lock the serial port on start (or whenever a binding is configured to use the port, actually).
Try to (manually in the first place) restart (in Karaf openhab console) a) the binding b) the serial transport bundle c) nrjavaserial to see if that helps.
Further research shows that NeuronRobotics/nrjavaserial#111 is the most likely cause. For a proper fix, this bug needs to be solved and the smartmeter binding updated to use the new version, which can then be included in the next openhab release.
In the meantime, I’ve decided to just periodically restart the openhab service by adding the following to /usr/lib/systemd/system/openhab.service:
and then running
systemctl restart openhab
It’s a bit of a sledgehammer approach, but I can live without openhab during the restart period
@mstormi in short, no, not completely. When the problem originally occurred, I disabled the Thing and re-enabled it, but that didn’t solve the problem. (That would be equivalent to suggestion “a”, right?)
I could wait a number of days for the problem to re-occur and try the other suggestions, but even one of those worked, I couldn’t see a way to easily detect the problem and restart a particularly component from within openhab. Hence the approach I chose (which is arguably a bad workaround, but it solves my problem for now).
Are you expecting regular meter readings or something like?
Add expire to your metering Item for period NN minutes and state UNDEF
Write a rule triggered from change to UNDEF that rings bells or sends you an email etc.