MQTT switch with state

Hi,

I am very new to openhab. I do have some problems with the state of a switch. My switch works a bit different to others. When I publish “home/dev1/output/rel0/set_off_ms 100” the light switches on and therefore I get the state message “home/dev1/input/in0 ON” when I publish the next message with “home/dev1/output/rel0/set_off_ms 100” the light switches off and therefore I get “home/dev1/input/in0 OFF”

light on:

openhab2 pub: home/dev1/output/rel0/set_off_ms 100
openhab2 should sub: home/dev1/input/in0 ON

light off:

openhab2 pub: home/dev1/output/rel0/set_off_ms 100
openhab2 should sub: home/dev1/input/in0 OFF

So the light works. But the state does not work as expected. So the light bulb stays always yellow in the UI. And also if I publish the set_off_ms … message over an other client (mossquitto_sub …) also the switch state in the UI does not change.

I think I am missing anything or I do not exactly know how that works.

Group    Home            "home"      <house>

Group    Bedroom         "Bedroom"   <bedroom>   (Home)

Switch   Bedroom_Light   "Light"     <light>     (Bedroom, gLight)      {mqtt=">[mosquitto:home/dev1/output/rel0/set_off_ms:command:*:100], <[mosquitto:home/dev1/in0:state:default]"}

Group:Switch:OR(ON, OFF)   gLight   "Light"   <light>   (Home)
sitemap home label="home" {
    Frame {
        Group item=Bedroom
    }

    Frame {
        Text label="Light" icon="light" {
            Default item=Bedroom_Light label="Bedroom"
        }
    }
}

I hope someone can help me here.
many thanks

Your topics are wrong according to above you have:
home/dev1/output/rel0/set_off_ms
and
home/dev1/input/in0

but in your item binding you have
home/dev1/in

Also add autoupdate="false" as a last binding

Switch   Bedroom_Light   "Light"     <light>     (Bedroom, gLight)      {mqtt=">[mosquitto:home/dev1/output/rel0/set_off_ms:command:*:100], <[mosquitto:home/dev1/input/in0:state:default]", autoupdate="false" }

Many thanks - I did not see that it is to late :slight_smile:
Now it works why autoupdate?

But… is this the correct behaviour?

I have created that little thest with the homebuilder. The builder generates also this entry.

Group:Switch:OR(ON, OFF)   gLight   "Light"   <light>   (Home)

And this on the sitemap:

    Frame {
        Text label="Light" icon="light" {
            Default item=Bedroom_Light label="Bedroom"
        }
    }

I do not understand why I need this? Also when I navigate over that entry on the UI the state does not work correct. If I navigate over the bedroom to the light everything works correct now.

What entry?

The home builder will automatically create groups for rooms ans types of appliances, they can get very useful when your installation grows and your rules become more complex :smile: