Feedback on my rules to power on and off devices in a specific order

Ruledriven item updates not always reflected on sitemap.

I will start with a small introduction. Recently i picked up home automation
as hobby. After trying multiple solutions I decided that OpenHAB would be
my solution because I enjoy tinkering around with stuff and it offers me a lot
of learning possibilities like MQTT and KNX bindings.

Now I was able to setup OpenHAB 2.0 with bindings for the RFXCOM and Aeon labs
Z-Wave stick. My first project in OpenHAB will be automation of the power on and
off sequences for a rack with AV equipment.

The rack contains four devices which need to be powered on and off in a specific
order. Basically I need to power on the amps last and I want to use a sparkfun motorized slider to set the volume slider.
My current poc looks like this:

Relevant files
|-- OpenHAB2
    |-- conf
       |-- sitemaps
       |   `-- example.sitemap
       |-- items
       |   |-- LIGHTS.items
       |   `-- AUDIO.items
       `-- rules
           `-- AUDIO.rules


sitemap example label="Basement"
        Frame label="LIGHTS" {
            Switch item=SW_KLD
        Frame label="Audio" {
            Switch item=Audiorack
            Slider item=Master
            Group item=GR_AUDIO label="test"


Switch	Audiorack "Audiorack"              <light>    	{ Command }
Dimmer  Master    "Master volume [%s %%]"  <light>	{ Command}

Switch	Mixer	"Mixer"          <light>         (GR_AUDIO)	{ Command }
Switch	Crossover "xover"        <light>         (GR_AUDIO)	{ Command }
Switch	TOPAMP	"Top-amp"        <light>         (GR_AUDIO)	{ Command }
Switch	SUBAMP	"Sub-amp"        <light>         (GR_AUDIO)	{ Command }

I realize that light might not be the optimal category for the audio equipment, but it worked for my POC goals.


// Rules for Audioequipment

rule "AudiorackPWRon"
      Item Audiorack changed from OFF to ON
    Master.state = new PercentType(0)
    if Master.state == (0) then
        sendCommand(Mixer, ON)
        sendCommand(Crossover, ON)
        sendCommand(TOPAMP, ON)
        sendCommand(SUBAMP, ON)

rule "AudiorackPWRoff"
    Item Audiorack changed from ON to OFF
    Master.state = new PercentType(0)
    if Master.state == (0) then
    sendCommand(TOPAMP, OFF)
    sendCommand(SUBAMP, OFF)
    sendCommand(Crossover, OFF)
    sendCommand(Mixer, OFF)

These rules feels very inefficient to me but I don’t have enough programming
or scripting knowledge to think of a more elegant solution, so feedback is welcome.

The main issue I’ve been having is that when I set the main switch the updates are not always reflected
in the basic UI (my sitemap), I need to refresh before the UI reflects the changes.
Could this be caused by inefficient rules or the lack of persistence?

At the moment there’s a Fibaro RGBW controllers dimmer function linked to the master volume control slider and the led strip is always powered off when I switch the main switch so the rules are processed.

The system was also having issues with items defined in files like audio.items not showing up in the paperUI so I couldn’t link it but it appears to be solved after recreating the files with another editor. However I seem to recal a topic or document about the way items and things defined through config files or the paper ui are processed and stored, does someone have any idea what document or topic this might have been?