Hi, i am new to openhab, so maybe this answer will be stupid for someone, but … ,
i’ve got one Switch and i want to print state of this Switch (ON/OFF).
My sitemaps:
Switch item=A mappings=[ON=“ON”, OFF=“OFF”]
Text item=StateA label=“State A”
All items in openHAB defaults to an undefined state after startup, and remains in this state until they are set to a specific state (e.g. ON or OFF for a switch).
Please note that if you are using persistence with restoreOnStartup the items will be set to the last (persisted) state during startup, and thus should ideally* never have an undefined state while the system is running.
*) Note that this is not strictly true due to the way that openHAB loads files at startup.
and it should end up in your openhab.log (/var/log/openhab/openhab.log if you are on Linux).
All of this is assuming you already have a proper state. Your problem, on the other hand, may be that you have not been able to set a proper state from the Exec binding.
I have only briefly used the Exec binding myself, so I am far from an expert, but I think your binding should be an in-binding (i.e. you need to use “<” instead of “>”). You may also need to do the “@@” trick for the spaces in your command line.
Try the following and see if it works:
String StateA "state is [%s]" {exec="<[/home/pi/openHAB/program@@getState@@b1:1000:REGEX((.*?))]"}