Getting item state from script / procmail

Hi All,

Is there an easy way to query an item state from a shell script?

I have a surveillance system, which can trigger events based on motion detection, line crossing, etc. When an event happens, it will send an email with an attached image. I currently forward this to pushover for notifications on my phone.

What I want to do is have the mail go through procmail, which calls a script (could be bash, but more likely perl). I would like to make the forwarding of the email dependent on the state of a Switch item in openHAB (perhaps using presence or just manually set). In other words a way for openHAB to enable/disable the forwarding of these emails.

I guess one way would be to bind the switch to MQTT and get the item state that way, but it seems a bit cumbersome for something like this.

Any suggestions are welcome
Mikkel

Use the REST api.

Thanks @vzorglub! That seems like a good way of achieving my goal.