By default, Tasmota's switches are attached to relays to control them, and while they can be detached, they don't show up with the discovery plugin and there is no added field enter the idx under the "configure Domoticz" section in Tasmota. So, I can wire up a simple reed switch to a free GPIO of the ESP, but I couldn't get it's state into a Domoticz device. I was unable to find a simple solution and figured I'd need to do some normalization using Node-Red to get the MQTT messages from Tasmota parsed and sent to Domoticz using the JSON API- I had done something similar previously to get UPS stats from apcupsd into Domoticz.
When I finally got around to implementing this in earnest, I discovered this was easily accomplished with built-in tools using Tasmota's own documentation on switches.
Again, this isn't anything new or groundbreaking, I was just unable to find this information presented very clearly so I am attempting to do so. Maybe it wasn't laid out because it's so straightforward!
- Create a virtual switch in Domoticz using the dummy hardware. Configure as a door contact.
- Ensure the "MQTT Client Gateway with LAN Interface" hardware to Domoticz is pointed to the same MQTT server as Tasmota.
- In Tasmota, configure the GPIO as a Switch with an unused switch number. Configure a Rule (below) using the Tasmota console to publish that switch's state using MQTT.
In this example, my Domoticz idx is 649 and I am using Switch 5 on Tasmota. Tasmota allows up to 4 rules active, and this is using Rule1.
Code: Select all
Backlog SwitchMode5 1; SwitchTopic5 0
Backlog Rule1 on Switch5#state=1 do Publish domoticz/in {"command": "switchlight", "idx": 649, "switchcmd": "On" } endon on Switch5#state=0 do Publish domoticz/in {"command": "switchlight", "idx": 649, "switchcmd": "Off" } endon; Rule1 1