I’m trying to use a time-based condition in a lambda form to activate a switch but It doesn’t really work. It compiles fine and gives no errors but nothing really happens:
Do you have api: in the configuration file? That might be necessary for the home assistant time.
The turn_on_action: and turn_off_action: triggers get executed when the switch state changes. So they would only get executed if some other logic in the configuration or HA changes the state. The time logic needs to be in the lambda: trigger for the template switch. It will get evaluated periodically and the switch state will change based on the return statement.
The SNTP Time Source — ESPHome could be used if the device can reach a NTP server. Might be able to configure router or the MQTT-server for this. If there are only a few times of interest, could just publish a MQTT topic for each state.
That did the trick. I’ve setup a text sensor that indicates the state and activates the switch at a certain time. Code below if someone else might need it: