rkoshak / sensorReporter

A python based service that receives sensor inputs and publishes them in various ways.
Apache License 2.0
105 stars 41 forks source link

improved restart routine #92

Closed DanielDecker closed 2 years ago

DanielDecker commented 2 years ago

fixed freeze on disconnect of the openHAB restAPI connection modified gpio.setup and cleanup so it works properly +added GPIO parmeter for pin numbering mode and the expected input level for button press events modified GPIO log messages to include the new parameters moved GPIO sensor button press code to separate class to shrink RpiGpioSensor init function +added example circuit diagram to the GPIO readme (ceated with GIMP)

I looked into several ways to fix the openHAB connection freeze on disconnect. The one I implemented is the simplest one. It works basically like the solution before, but we won't wait until the thread has closed. Since the thread has it's own class it will remember the stop flag. During the start up of the new connection several messages to openHAB are send and received so the old connection thread is closed immediately. I tested this in detail. Btw. using the request timeout wouldn't work. After the timeout expired, which always happens cos the connection is usually idle, the response object was no longer valid. So after every timeout a new connect to openHAB would be required.

fixes #91, #70

rkoshak commented 2 years ago

I'm pretty out of it today so probably didn't do as thorough of a review as was warranted but I didn't see anything glaring so I'm just going to merge it. I'm sure you tested it. If something non-obvious breaks we can open new issues.

DanielDecker commented 2 years ago

Yes, I tested all these changes with several different configurations and multiple connections (local, mqtt, openHAB).

DanielDecker commented 2 years ago

I regret the change view looks rather messy. I guess this is because I moved some code blocks to group logical parts together. I hope you can edit this pull request anyway.