Updating Switch via mqtt when changed manually/Alexa

Hello,

this is a question surely answered before, but I could not find it.

I have a sonoff power socket that is controlled via mqtt. It has a topic that publishes information ( stat/sonoff/POWER) and a topic that is suscribed to my openhab2 instance (cmnd/sonoff/POWER). Moreover, I have concted Alexa with the openhab cloud.

Both work fine on their own. If I turn on the plug using paper UI I can turn it off using Alexa, but if I turn it on with Alexa (or manually by pressing the button on the power socket) it does not get updated in openhab and I have to turn the switch on and off again.

Here are my Item and sitemap declarations:

Group    Home               "Zuhause"      <house>

Group    LivingRoom         "Wohnzimmer"   <sofa>          (Home)

Switch   LivingRoom_Power   "Fernseher"    <poweroutlet>   (LivingRoom, gPower)  ["Switchable"]    {mqtt=">[mybroker:cmnd/sonoff/power:command:ON:1],>[mybroker:cmnd/sonoff/power:command:OFF:0]"}
Switch   LivingRoom_Power   "Fernseher"    <poweroutlet>   (LivingRoom, gPower)      {mqtt="<[mybroker:stat/sonoff/POWER:state],<[mybroker:cmnd/sonoff/POWER:state]"}

Group:Switch:OR(ON, OFF)   gPower   "Steckdose"   <poweroutlet>   (Home)
sitemap zuhause label="Zuhause" {
    Frame {
        Group item=LivingRoom
    }
}

Thanks for your help!!

I’m not familiar with Alex, it looks strange, the same element is declared 2 times

Switch   LivingRoom_Power
Switch   LivingRoom_Power

maybe this is a feature of working with Alex, I do not know, but I doubt it.
I guess you do not have enough mosquito themes, look at how my sonof works for me, maybe it will help you:

Switch room_sl "switch [%s]" <rgb> (gILeaving) { mqtt="<[mqtt-loc:stat/room-sl/POWER:state:default],
													   <[mqtt-loc:tele/room-sl/STATE:state:JSONPATH($.POWER)],
													   >[mqtt-loc:cmnd/room-sl/power:command:*:default]"}

thank you very much :slight_smile: