# Can the HAT relay IO state be read in multiple python programs

**URL:** <https://forums.pimoroni.com/t/can-the-hat-relay-io-state-be-read-in-multiple-python-programs/21563>\
**Category:** Support\
**Created:** [February 25, 2023, 10:23pm UTC](https://forums.pimoroni.com/t/can-the-hat-relay-io-state-be-read-in-multiple-python-programs/21563 "2023-02-25T22:23:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JimB](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@JimB](https://forums.pimoroni.com/u/JimB)\
**Post date:** [February 25, 2023, 10:23pm UTC](https://forums.pimoroni.com/t/can-the-hat-relay-io-state-be-read-in-multiple-python-programs/21563/1 "2023-02-25T22:23:59Z")

</div>

I’m using a automation hat to monitor moisture level in a planter. When it gets dry a pump is turned on. All is done in a python program. I tried to use a second python program to read the state of the relay that is driving the pump so I can send that state to my openHab program but it never sees an active relay (.is\_on() always returns a false). If I run .is\_on() in same python program that turns on the relay, it works as expected.

This tells me that the pimoroni library is not saving the state of the relays in a global sense. Anyone know if this is the truth or am I missing something about the library and python?  
Thanksinadvance, JimB

---

<div class="post-metadata">

**Author:** ![JimB](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@JimB](https://forums.pimoroni.com/u/JimB)\
**Post date:** [July 4, 2023, 2:47pm UTC](https://forums.pimoroni.com/t/can-the-hat-relay-io-state-be-read-in-multiple-python-programs/21563/2 "2023-07-04T14:47:44Z")

</div>

Still wondering about this - does anyone from Pimoroni read these posts?

---

<div class="post-metadata">

**Author:** ![hel](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/hel/32/6075_2.png) [@hel](https://forums.pimoroni.com/u/hel)\
**Post date:** [July 5, 2023, 9:41am UTC](https://forums.pimoroni.com/t/can-the-hat-relay-io-state-be-read-in-multiple-python-programs/21563/3 "2023-07-05T09:41:51Z")

</div>

We do! It’s been a while since I did anything with Automation HAT but think there might be some hardware locking in the library which means running multiple scripts that use the same hardware won’t work. Is it not possible to combine the two Python scripts into one?

---

<div class="post-metadata">

**Author:** ![JimB](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@JimB](https://forums.pimoroni.com/u/JimB)\
**Post date:** [July 5, 2023, 1:58pm UTC](https://forums.pimoroni.com/t/can-the-hat-relay-io-state-be-read-in-multiple-python-programs/21563/4 "2023-07-05T13:58:58Z")

</div>

I was hoping to use two different programs - one running constantly to monitor inputs and set outputs. The second program runs from a cron task to send data collected to a server at a different interval. I did finally combined the two functions. I am using the cron task on several pi’s so wanted to keep it separate so updates would be simpler.  
Thanks for replying.
