I recently bought some tuya devices on sale when I realised I could flash them with esphome. The only problem is that the relays are turning off when it reboots (when I OTA flash it). I’ve tried a few things: using on_boot to turn the relays on, changing the restore_mode, removing everything not needed in the config etc but no matter what the relays always turn off.
when esphome is rebooting or updating it will momentarly reset, so you will have a moment the ralay is OFF, as soon as it has booted it will set the relay in the requested condition. For example on boot turn on, this action will happen as soon as the boot is completed.
The is no way to avoid the ralay to change condition while powering on or rebooting after an update or similar.
I have other esphome smart plugs and I’ve never encountered a device powering off on OTA flashing. I thought maybe this was something to do with the Tuya chip.
Hi,
can I ask you which device with relay does not power off? even if these are US plug, because I am looking at something similar.
In my experience any relay device will switch off during an update, it is my experience.
looking at the code they restore the relay condition: # Restore the relay (GPO switch) upon reboot to state: relay_restore_mode: RESTORE_DEFAULT_ON
So they restore the mode when booting.
that is my understanding
I have a similar issue with a plug with relay lying around; I just wanted only to monitor current draw roughly but this might switch on/off in some condition, eventually I will use a monitor device only.
What is your end user requirement? Heart pacemaker? ISS Oxygen generator?
There are commands in both OpenBeken and ESPHome to set relay status to on at powerup, but the mechanical nature of relays is that the unpowered status is usually off for one portion of a SPST relay, while the other part is on.
If you want SPDT relay rather than SPST, then you may have to externally connect an appropriate relay.
My end user requirement is power monitoring my modem and server so yes, I’d prefer them to not be powered down.
I’m just shocked that a 5 year old esp8266 device I bought from a dolar store can stay powered during reboot but a fairly recent and much more expensive device can’t. I assumed there must be a bug in esphome or there was a setting I was missing for the bk7231T.
I seriously doubt the ESP8266 itself is holding a GPIO in a non-default state through a reboot. I don’t think you’ll find any chip that can do that.
That of course doesn’t mean a relay has to open during a reboot. Depending on how it is connected, what the default state of the GPIO is, what the pull-up/pull-down resistors are, and whether the relay is NC/NO will all affect the behavior observed during a chip reboot.
Blaming the chip itself for this behavior is misdirected.
More expensive but tuya? You paid too much.
MCU pins have all kind of different behaviours during reboot, if the relay trigger doesn’t have pullup (or pull-down), quite likely switching will happen. Independently how pricy the device is.
All my devices latch the relay when rebooting, esp & beken. If relay control is not required I’ve shorted the AC thru the relay. I did this on 3 fridges so they can never open, accidentally or by device failure. Comes down to your use case.
I think it’s impossible that any esp will hold state during reset. If any device holds relay in pre-set position i’m pretty sure that hardware is made so that it allows such a state. So, any external chip, could be MCP23008, MCP23017, SN74HC595… i can’t say for any of them if they hold state, but i’m sure to can be done.