[SOLVED] Problem on time-switch with Expire-Binding

Hello there, im new to the community :slight_smile:

I want to build a switch that, when toggled turns off after 2 seconds. The switch is connected to a Smart-Plug with sonoff-tasmota flashed and addressed over MQTT. For this reason I installed the Expire-Binding.

Switch Licht_1 "Licht 1" { mqtt=">[mosquitto:cmnd/Licht1/POWER:command:ON:1]", expire="2s,command=OFF"}

log:

12:14:41.391 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'Licht_1' received command ON
12:14:41.393 [INFO ] [smarthome.event.ItemStateChangedEvent] - Licht_1 changed from NULL to ON
12:14:43.799 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'Licht_1' received command OFF
12:14:43.801 [INFO ] [smarthome.event.ItemStateChangedEvent] - Licht_1 changed from ON to OFF

In Basic UI the switch turns ON and OFF after 2 sek but the Smart-Plug only turns ON but doesnt turn OFF. A normal switch is fully working with these MQTT commands.

How can I make this work?

Grettings

That’s because your MQTT binding definition is not set-up for sending the OFF command, only the ON one.
Change your item to this:

Switch Licht_1 "Licht 1" { mqtt=">[mosquitto:cmnd/Licht1/POWER:command:*:default]", expire="2s,command=OFF"}

The tasmotta will accept either 0/1 or ON/OFF so you can send ON of OFF to the tasmotta sonoff.

2 Likes

Thanks a lot! Its working now.