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

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!

Moderators: leecollings, remb0

Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
fdemees
Posts: 18
Joined: Sunday 29 March 2020 17:33
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Belgium, close to Brussels
Contact:

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

Post 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 2135 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 :)
Domoticz on Rpi 3B+, ZigbeeforDomoticz, Sonoff Zigbee coordinator, several Sonoff/ESPEasy/Tasmota, IPX800, several Zigbee things, Ksenia Lares
User avatar
waltervl
Posts: 5893
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

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

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
fdemees
Posts: 18
Joined: Sunday 29 March 2020 17:33
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Belgium, close to Brussels
Contact:

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

Post 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 2067 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 2067 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.
Domoticz on Rpi 3B+, ZigbeeforDomoticz, Sonoff Zigbee coordinator, several Sonoff/ESPEasy/Tasmota, IPX800, several Zigbee things, Ksenia Lares
fdemees
Posts: 18
Joined: Sunday 29 March 2020 17:33
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Belgium, close to Brussels
Contact:

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

Post 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 !
Domoticz on Rpi 3B+, ZigbeeforDomoticz, Sonoff Zigbee coordinator, several Sonoff/ESPEasy/Tasmota, IPX800, several Zigbee things, Ksenia Lares
User avatar
waltervl
Posts: 5893
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

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

Post by waltervl »

Nice that it works now!
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest