Hi Ive flashed a Nodemcu with Tasmota , and configured it with 4 inputs and 1 relay output. But I’ve noticed if it can’t connect to my Mqtt broker, then any input seems to trigger the relay I have connected. can this be disabled as I can’t have the relay operating by accident
If it can’t connect to the mqtt broker, then how is it getting any inputs?
How do you know it isn’t connecting- do you have a serial monitor watching the console from the device, or open the Tasmota console over the device IP address? Have you looked at the mqtt logs?
Are your inputs through the NodeMCU GPIO inputs? If they are configured in Tasmota as switches or buttons, then MQTT is not in the loop at all. I know of no way within Tasmota to disable local inputs if there is no connection to mqtt. If this describes your problem, then you may want to make the inputs as sensors and control the on/off of the relay in Home Assistant or Node-Red. In other words, without the mqtt broker, Home Assistant would never see the input and never send a relay power output. But, on this last suggestion, I am completely out of my experience level.
Note: I am a rank amateur at these things, and probably completely wrong.
Yes the 4 inputs are gpio input which send mqtt messages when there status changes, the problem is if home assistant has crashed, or the broker , then any status change on an input, activates the relay. Home assistant is not asking the relay to operate, it is in the tasmota code, but I can’t see how to disable it
If you’re comfortable with coding, you can write your own firmware for the NodeMCU. I used to write all my own for my mqtt nodes, usually on esp8266 or NodeMCU boards. But I have been moving all of them to Tasmota.
Anyway, if you want, I can send you the code from one of my devices that you could start with. (I comment heavily since I forget why I did something in the code). This way you could get the behaviour you expect.
Hi, I did download Arduino first, but got a bit lost, then found Tasmota, so yes any code you have that might help would be great
Here’s a link to a test project where I was making a light blink in morse code. It is liberally commented, but kaywinnet.h is simply my WiFi credentials.
Hope this helps.
That’s the way Tasmota works by default - there is a lot of discussion on the Tasmota forums about this behaviour.
The best way I have found to ignore switch actions (for instance if you want a PIR configured as a switch NOT to turn the relay on, is to use Rules. To use rules the define USE_RULES
has to be enabled in file user_config_override.h. An example:
RULE1 1
RULE1 on switch4#state=1 do publish stat/sonoff4/PIR ON endon on switch4#state=0 do publish stat/sonoff4/PIR OFF endon
You don’t need to do a different rule buffer for each switch (there are 3), you just append each trigger and action e.g.
on [trigger1] do [command] endon on [trigger2] do [command] endon ...
See here: https://github.com/arendst/Sonoff-Tasmota/wiki/Rules
And here: https://github.com/arendst/Sonoff-Tasmota/wiki/Commands#management
Thanks, I did try using a rule, but must have done it wrong as it only worked on one input, I’ve managed to get an Arduino sketch working now
Thanks, I have managed to write a sketch, I’ll compare
I did forget to mention switchmode and SwitchTopic - which may be why it failed. SwitchTopic needs to be zero for that particular event to trigger, SwitchMode to whatever value matches the behaviour of the switch you are using.