[SOLVED] Sitemap auto detect current status of relays

Hi there,

Is there any rule to detect OFF status or the current status of the relay?

Everytime I open Openhab on the phone or in the laptop, I can not see the status OFF of the switches:

Actually, they are all OFF, but there is no feedback every time I open the page. I have to click on OFF to highlight them.

Could you post your sitemap code, please?

Like this:

   Switch item=sonoff01 mappings=[ON="ON",OFF="OFF"]
   Switch item=sonoff02 mappings=[ON="ON",OFF="OFF"]
   Switch item=sonoff03 mappings=[ON="ON",OFF="OFF"]
   Switch item=sonoff04 mappings=[ON="ON",OFF="OFF"]
   Switch item=sonoff06 mappings=[ON="ON",OFF="OFF"]

I think I am missing something, to detect the current state.
Thanks.

Try removing the mappings

It does not work.

If I switch on from the device or from MQTTfx for example, the page does refresh , does not pick up the status :confused:

My items delacartions:

Switch sonoff01 “LEDS”
{
mqtt="

[mosquitto:cmnd/sonoff01/POWER:command:ON:1],
[mosquitto:cmnd/sonoff01/POWER:command:OFF:0],
<[mosquitto:stat/sonoff01/POWER:state:ON:1],
<[mosquitto:stat/sonoff01/POWER:state:OFF:0]
"
}

You need to add autoupdate=“false” in the binding {}

Hi there,
According to the documentation, this is not working for me:

>[mosquitto:sonoff01/command:command:ON:1],
>[mosquitto:sonoff01/command:command:OFF:0],

I need to out the sentece like the doc here: https://github.com/arendst/Sonoff-Tasmota/wiki/MQTT-Overview#configure-mqtt-settings

>[mosquitto:cmnd/sonoff01/POWER:command:ON:1],
>[mosquitto:cmnd/sonoff01/POWER:command:OFF:0],

Then I am using the MAP(onoff.map), it does not work. I mean, after sending a command from MQTTfx on or off, the status is not updated in the openhab BASIC/CLASIC. Of course, if I command from the BASIC page, it works, but if someone turn on the switch from the device or from other device, it is not refresh. Something I am missing…

Switch sonoff01 "LEDS" <light>
{ 
mqtt="
>[mosquitto:cmnd/sonoff01/POWER:command:ON:1],
>[mosquitto:cmnd/sonoff01/POWER:command:OFF:0],
<[mosquitto:sonoff01/state:state:MAP(onoff.map)]", autoupdate="false"
}

In MQTTfx what topic is the update sent by the sonoff and what payload?

Can you post your onoff.map file, please?

In MQTTfx,

To publish: “cmnd/sonoff01/POWER” with the PAYLOAD ON or OFF and works with 1 and 0.
To suscrbie: “stat/sonoff01/POWER”

Everything works fine between broker an client, and witches works perfect.

in transform/onoff.map:
0=OFF
1=ON

Switch sonoff01 "LEDS" <light>
{ 
mqtt="
>[mosquitto:cmnd/sonoff01/POWER:command:ON:1],
>[mosquitto:cmnd/sonoff01/POWER:command:OFF:0],
<[mosquitto:stat/sonoff01/POWER:state:MAP(onoff.map)]", autoupdate="false"
}

Mmmm now, it is working fine.
What it the meaning of &lt and &gt?

Thank you very much.

OOOOOKkk the symbols < and > o_O… loooool

Copy and paste browser errors, I corrected it, see above

Good, please mark the thread as solved.