Simultaneous access to GPIO pin from Java singleton instance and OH on RasPi

Hi,
I have a native java binary controlling 4 GPIO activated relays via 4 singleton instances 0 that are also controlled and monitored by OH. The problem I get is access conflicts when all 4 instances run. This is on a RasPi. Has anyone done something similar who can give me some guidance?

Cheers

Access to physical devices like GPIO pins, serial devices, and usb devices is limited to a single process. You do not want more than one process to be able to write to a physical device at the same time. The operating system creates a lock and controls this access. So you cannot have your Java programs AND openHAB access the same pin at the same time.

The proper approach would be to not use the native Java programs or to have your native Java programs report changes and receive commands from openHAB through some other mechanism (e.g. REST API, MQTT, etc.).

Thanks Rich,
that makes sense. HestiaPi is actually an open thermostat for homes with a web interface and local buttons for “backward compatibility”. The java binary apart from checking button presses and relay control is also running the scheduling engine (start heating at x degrees at y o’clock).
Do you know if I can recreate such functionality inside OH (any version) with the typical UI elements a scheduler would require to enter dates, start times, desired temperature, etc so that can I ditch my java binary and go 100% OH?

thanks again for the info!

Yes but…

Search the forum for “Alarm Clock” and you will see lots of examples of how people have hacked around the sitemap and rules to allow users to enter a time and create an event at that time. Its pretty hacky and requires a lot of work just to set a time but it supposedly works.

People have done just what you are after using OH.

However, consider using events besides time to control your HVAC. For example, inside/outside temperature, whether or not someone is home, and time of day based on solar events (sunrise, sunset). I use this approach and I find it works great and I don’t have to do anything as the days lengthen and shorten over the year. I’ve not had to touch my controller logic in over a year.

Sorry for the late reply. Was trying to investigate the area. This looks really promising and doable!
I am totally with you on the events subject. I plan to include other items in my OH rather than simply heating and hot water, like awning motor which should take into consideration time of day, wind, rain, indoor temperature. I already started building it in my mind :slight_smile:
Thank you Rich for all that help!