So I got a set of Wyze Outdoor Plugs for Christmas lights outside and after a bit of cursing, inhaling of soldering fumes and almost ripping out a trace (thanks wyze for not putting through hole contacts and only having pads), I got ESPHome onto each of them working as expected using this yaml as a baseline (modified to use core default yamls):
Everything seems to be working as expected, but I just noticed that the default behavior when there is a power loss event is for both relays to turn on. This is less than ideal since I am also using these to power a fountain pump that is not always in use/drained. Unfortunately the pump does not have run dry protection so I think you guys can see why this is an issue.
Any ideas on how/if it is possible to configure the power loss behavior (on/off would be fine, but previous would be better)?
Edit: I found this but I am not sure if it is actually related:
Edit 2: I think I found the right setting, there is an on_boot setting
I can give a complete example later today if needed:
on_boot is probably the way to go to set to off when rebooting and then handle restore to current state in NR by checking for the device coming online and then sending the current state as kept in NR.
So I just did some further testing and the power loss behavior is actually weirder than I thought (but I feel like it is somewhere in the yaml doing it because no way this is default).
The default action when they experience a power loss event is to toggle from the previous state. So if both relays were off, cut the power put the power back, both are on, and if both are on when power is lost, when they come back they are both off.
Also this does not seem to be the case when you initiate a software reboot, which results in the same state of the relay as before the reboot.
Looking through the yaml nothing jumps out other than all of the inverted true and false. I have not made sense of why some are true and why some are false.
The only thing I see which could potentially cause this is if those switch.toggle entries are activated during boot. You could try commenting out that whole section.
No worries, it’s raining currently so there is no use for a fountain anyway and now that I know about this I can monitor/unplug to make sure the pump isn’t at risk.
Just monitor for new online messages and send off to the pump outlet when one is received, that should solve it for now at least. Then later you can find the proper firmware based fix.
Quick question about handling firmware for multiple devices:
I am assuming you follow the framework of the generics, where you have just a main firmware for a given device and then you have the actual device that includes that main code plus and specific configs like name or mqtt location correct?
If so what is the normal process for making sure those new changes are applied downstream? I assumed when I saved the “template” wyze plug all of the others would not say that there is an update available and to please install, but to my surprise they did not. Do I just have to force an install and hope it recompiles the correct code and doesn’t just reload the old compilation?
Also any idea why only the IP monitor from the generic yamls is coming in but not the restart switch, uptime, wifi signal, or status?
This is getting really weird. Somehow the below code results in a always off when power is lost even though it clearly should be always on, and I tried the always off option and it always turned it on. I really hate inverted logic…
At least now it’s clear where the issue is, which was the point of disabling that block. You could try to enable that block and changing “inverted: True” to False on both locations, then try if the state remains correct and if the buttons still work. If not there are other ways to filter this, but for that I’d need to check on my own configs at my computer.
Thank you so much Markus for helping to fix this. I feel like someone should put a PR in so it gets updated for anyone in the future:
Also just a reminder for you or someone else later: I still have a few secondary questions outstanding (generic yamls monitors not showing up and how to handle yamls for multiple of the same device)