How to control openHAB widget state with rules?

hello !

in short my question are:
how to change an openHAB button state (active/inactive) from a rules file? What is the syntax?

and the full story… :slight_smile:

I built my own home control system hardware and software, based on two Beaglebone Greens.
Theres a board for input (switches) and one for output (relays or lights basically).
The input board reads the switches and sends a command to the output board.
The output board then sends a status of all outputs back. Like this
switch number 4 pressed -> INPUTBOARD -> send command ‘P4’ -> OUTPUTBOARD -> toggle some light -> return string “0,1,0,1,0,1,1,0,0,1,1,0,0,0,1,0,0”
The return string are comma seperated 0’s or 1’s reflecting the state of the lights in a numbered order.
It works nice, but I’d like to have a nice GUI/dashboards, so that’s why I started looking at openHAB.

I used the exec binding and button widget in the HABPanel.
When I click that button, I pass the value P4 to the control item of the exec binding, and with %2$s in the command line, the P4 is passed to my command that sends P4 to my output board.
The button is configured with the Action type as : “send a fixed command to an item” and the Command value is whatever P-number needed
Cool! that works

I like to get the return value from the command, which tells the actual status of the lights and set the active/inactie state of the button widget accordingly.
I can’t find how to address these button properties.

I figure it must be a rule like

rule “statusupdate”
Item setswitch_output received update
if setswitch_output[1]==0 ; then panel.button1.state=inactive; else panel.button1.state=inactive
if setswitch_output[2]==0 ; then panel.button2.state=inactive; else panel.button1.state=inactive


thing is… I don’t know how to control the state of the button
I tried:

but the logs always show
Rule ‘statusupdate’: The name ‘button1’ cannot be resolved to an item or type;


You can’t, at least not from the rules DSL
HABpanel is an independent app pooling values and publishing though the REST API
Your have to do that inside HABpanel by create your own custom widget

thanks for your reply

I didn’t know that. Any hint you can give me how what REST command to use to change the state (or at least background color) of a standard button? - I’m afraid creating my own widget is a step too far for me


Again, openHAB provides a REST api, not HABpanel.