Rule or script to detect states

I think you have a problem with you installation.
Without knowing what you have done it is painful to asking all details.
There are different raspian-versions.

I would start with a new installation unsing this way https://docs.openhab.org/installation/openhabian.html
and Raspberry Pi image v1.4.1 openHABian v1.4 released!