Page 1 of 1

Door contact + MQTT -> "On action" & "Off action" do not execute

Posted: Friday 11 April 2025 22:21
by fdemees
Hello, dear Community,

Version: Version 2024.7 (July 13th 2024)
Platform: RPi3B+, Debian 11.11
Plugin/Hardware: MQTT Client Gateway with LAN interface, other unrelated
Description:
I have set up a door sensor, based on a esp8266 Wemos, running the most recent version of Tasmota.

A Domoticz switch device is created from the Dummy hardware device, as usual.
The communication between the door sensor and Domoticz is done with MQTT and is reliable.


I want to use this door sensor in order to action an alarm system reachable via https.
2025-04-10 15_05_20-Domoticz — Mozilla Firefox.png
2025-04-10 15_05_20-Domoticz — Mozilla Firefox.png (22.9 KiB) Viewed 2139 times
I have discovered that the switch configured as "Door sensor" triggers the notifications on every status change, but does not trigger the "On action" or "Off action".

If I set the switch as an on/off standard switch (with a bulb as default icon) instead of a Sensor, when I change the status via the GUI the On and Off actions are successfully called, but when the trigger comes from MQTT, again no action is performed.

(Please note that I have tried both https:// and script:// in Actions, and neither method works)

Is this a defect, or a feature, is there a workaround ?
Thank you for your bright ideas :)

Re: Door contact + MQTT -> "On action" & "Off action" do not execute

Posted: Friday 11 April 2025 22:29
by waltervl
What is the MQTT message that the switch sends to Domoticz/in?
It should not contain command "udevice"
See also the wiki https://wiki.domoticz.com/MQTT#Sending_a_Switch_Command

Re: Door contact + MQTT -> "On action" & "Off action" do not execute

Posted: Saturday 12 April 2025 11:17
by fdemees
Hello @waltervl

The message sent by the Tasmota device (door sensor) is:
(door opened)

Code: Select all

domoticz/in = {"idx":203,"nvalue":1,"svalue":"","Battery":100,"RSSI":7}
(door closed)

Code: Select all

domoticz/in = {"idx":203,"nvalue":0,"svalue":"","Battery":100,"RSSI":7}

What I did (and I may be wrong)

This is the esp8266 module I had purchased years ago: (https://www.banggood.com/Geekcreit-ESP8 ... 36275.html) (https://templates.blakadder.com/geekcreit_10A.html)
2025-04-12 11_03_01-.jpg
2025-04-12 11_03_01-.jpg (17.02 KiB) Viewed 2071 times
I have uploaded the most recent version of Tasmota 14.5.0
and configured the module as shown:
2025-04-12 10_47_30-Wemos1 Module — Mozilla Firefox.png
2025-04-12 10_47_30-Wemos1 Module — Mozilla Firefox.png (11.51 KiB) Viewed 2071 times
The module is designed in factory with: GPIO4=output relay , GPIO5=input sensor via optocoupler.
As for many esp8266, GPIO2 drives the status LED on board.

I have thus configured GPIO5 as Switch1 in Tasmota device configuration.
Any change on the door switch generates MQTT messages like

Code: Select all

tele/wemos1/SENSOR = {"Time":"2025-04-12T09:53:05","Switch1":"OFF"}
but these messages are not addressed to the Domoticz MQTT queue.
So I have used the feature of Tasmota, linking the input contact to the output #1 (here the blue LED on GPIO2 declared as Relay1), and the LED status change is reported to domoticz/in
Now I understand why Domoticz would not trigger the actions, because it receives a reported status change of a relay. (and not a switchcmd)

I have just discovered your other reply on a similar topic viewtopic.php?t=40656
I will now study how to make scripts within Tasmota.

Thank you a lot for the suggestions.

Re: Door contact + MQTT -> "On action" & "Off action" do not execute

Posted: Saturday 12 April 2025 21:14
by fdemees
Dear Walter,

I have typed the following commands on the Tasmota console: (as suggested here viewtopic.php?t=40656)

Code: Select all

SwitchMode1 1
SwitchTopic1 0
Rule1 on Switch1#state=1 do Publish domoticz/in {"command": "switchlight", "idx": 203, "switchcmd": "On" } endon on Switch1#state=0 do Publish domoticz/in {"command": "switchlight", "idx": 203, "switchcmd": "Off" } endon
Rule1 1
it is a success. Great !

Re: Door contact + MQTT -> "On action" & "Off action" do not execute

Posted: Saturday 12 April 2025 21:39
by waltervl
Nice that it works now!