As it should because when you manually execute an automation, it skips the trigger
and condition
(if any) and simply executes the action
.
This behavior is documented in Automations - Troubleshooting.
Please note that if you click on Trigger of an automation in the frontend, only the action
part will be executed by Home Assistant. That means you can’t test your trigger or condition part that way. It also means that if your automation uses some data from triggers, it won’t work properly as well just because trigger
is not defined in this scenario.
You should review the documentation’s Automation chapter because you don’t appear to understand how triggers and conditions operate. If you are trying to do this:
then you don’t use a State Trigger based on a switch entity. You can use a State Trigger based on the sun.sun
entity or simply use a Sun Trigger.
Here’s an example of an automation that turns on the switch at 08:00
and off at sunset.
alias: 10gal aquarium lights
description: On at 8AM and off at sunset
trigger:
- platform: time
at: '08:00:00'
- platform: sun
event: sunset
action:
- service: "switch.turn_{{ 'on' if trigger.platform == 'time' else 'off' }}"
entity_id: switch.sonoff_1000cf6gh8
mode: single