Closed Salvora closed 2 weeks ago
Just guess, try to handle case when emre_tv_power
has no state:
lambda: |-
if (id(emre_tv_power).has_state()) {
if (id(emre_tv_power).state) {
return true;
} else {
return false;
}
} else {
return {};
}
Just guess, try to handle case when
emre_tv_power
has no state:lambda: |- if (id(emre_tv_power).has_state()) { if (id(emre_tv_power).state) { return true; } else { return false; } } else { return {}; }
Nope, does not work. Still the same behaviour. The binary sensor should always have some state in any case.
Tried a USB flash instead of OTA in case some configuration file is not getting a proper update. Still the same behaviour.
issue closed. RESTORE_DEFAULT_OFF", "RESTORE_DEFAULT_ON", "ALWAYS_ON", and "DISABLED, works now as it was my mistake and I was editing wrong config files.
The problem
I have two issues with template switches after updating to 2024.4.1. I don't remember which version I was before since I did not check it before but it was at least 9 months old. After updating
Case 1:
Every time I reboot ESP device, it engages the template switch There is a GPIO binary sensor to get the TV state and an IR transmitter to control the TV. There is a template switch where all of that comes together to create a switch for TV power.
For some reason, every time the device reboots, the action is engaged. I did not have this issue pre-update.
Case 2:
Global variable states are not preserved and do not survive the reboots. I highly suspect that this is related to Case 1. I have another template switch that controls the screen of a tm1637 which gets the screen state from a global variable. This global variable is set to restore_value but it is not working.
Which version of ESPHome has the issue?
2024.4.1
What type of installation are you using?
Home Assistant Add-on
Which version of Home Assistant has the issue?
2024.4.4
What platform are you using?
ESP32
Board
nodemcu
Component causing the issue
Compopnents/Switch Component/Template Switch
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Additional information
Looking at the logs, for both of the template switches I am seeing an "always OFF" mode. I tried to modify this by checking these docs https://esphome.io/components/switch/#base-switch-configuration
and tried multiple combinations but, it is not changing. I tried "RESTORE_DEFAULT_OFF", "RESTORE_DEFAULT_ON", "ALWAYS_ON", and "DISABLED". For some reason, the logs show this as OFF all the time no matter what config you use.
I suspect that during shutdown or boot up or in both at the same time, the board turns off the switches and the lambda is ignored.