String output based on status of multiple items

Hi all,

I am using openhabian and the GPIO binging to read inputs from my alarm system.

I have items setup and working for reading each of the GPIO inputs. These read the different modes of the alarm system (armed home and armed away).

I would like my site map to show me a single text item that reads “armed away”, “armed home” or “disarmed” based on the status of these GPIO inputs. What would be the best way to do this?

My thought was to create rules that would print a string value to a separate Alarm_Status item triggered by the status of the inputs. Only one of the 2 inputs would ever be on at a time indicating either armed away or armed home. When both are off this would be disarmed.

I don’t know how to get a rule to print a string value to an item. How would I achieve this?

Thanks for your help.

Well I think you have a pretty good idea to start with James. Create what in OpenHAB terms is called an ‘unbound item’ meaning it is not directly bound to any specific physical ‘thing’. It is a place holder for your display value. Make it a String item. This example would need placed in an items file.

String MyAlarmValue "the value I want displayed" <alarm> (gMyCoolGroup)

docs for items:

here is Rich’s terrific explanation of unbound items

Thanks for the information Andrew. That is a good description of what an unbound item is.

Are you able to provide any clarity on how to have a rule change the value of the unbound item? I know what I need to trigger the rule (the “when”) but I’m not sure how to use the rule to change the unbound item’s string value (the “then”) part of the rule.

I believe this is the missing piece of my puzzle.

You can use the send command method like with any other item. The send command method will also accept a var or Val as an argument.


Johannes

Well strictly you don’t need to send a command if you just want a state change.

myItem.postUpdate("New text I want")

A command usually results in a state change via OH autoupdate mechanism, which is enabled for each Item by default, but it is an extra step.

1 Like

Thanks all. I was over complicating it thinking I need a specific command.

I have achieved the result I was looking for with .sendCommand but Rossko57 I understand your point on .postUpdate

Many thanks.

1 Like