Next time please be more verbose.
You must not conceal parts of your setup that are important for someone to answer the question. You made me victim to the XY problem (see link below).
And frankly, this is no smart home application at all. And there’s a gazillion solutions on the Inet.
How to ask a good question / Help Us Help You - Tutorials & Examples - openHAB Community