How to update the Switch State?

Hello there.

Im using more then one States for On/OFF…

on the OPENHAB i switch on/off with 1/0
on a other gui i switch on/off with 2/3

so i want to know on which way was the Switch used.

Switch LED_Switch  "LED" {mqtt=">[mosquitto:LED:command:ON:1],>[mosquitto:LED:command:OFF:0]"}
String LED_State    "LED [MAP(status.map):%s]" 	{mqtt="<[mosquitto:LED:state:default]"}

status.map

0=Aus durch OPENHAB
1=An durch OPENHAB
2=An von Hand
3=Aus von Hand

but when i switch now on/off with the other gui i see my map message but the Switch icon has the last OPENHAB state… is there a way to say the icon green on 1+2 and red on 0+3 ? or is there a better way for my problem…?

Have you discovered dynamic icons?

thx, but i have an second problem… when i send via mqtt a 1 or a 0 then there is no change of the button state… only the state of my LED_State is changing.

how can i appear it to the switch state?

You need to add an “in-bound binding” to your Switch item, like you have for the String item.

Try this and see if it works:

Switch LED_Switch "LED" {mqtt=">[mosquitto:LED:command:ON:1], >[mosquitto:LED:command:OFF:0], <[mosquitto:LED:state:default]"}

thx iv found the solution:

Switch LED_Switch “LED” {mqtt="
<[mosquitto:LED:state:ON:1],
<[mosquitto:LED:state:OFF:0],
<[mosquitto:LED:state:ON:3],
<[mosquitto:LED:state:OFF:2],
<[mosquitto:LED:state:ON:5],
<[mosquitto:LED:state:OFF:4],

[mosquitto:LED:command:ON:1],
[mosquitto:LED:command:OFF:0]
"}