Help with automation - template and sun state, scripts not firing

Hey,

I’m having some difficulties getting this to work. I get no errors but none of the scripts actually triggers.

Any help is appreciated

> - alias: When we get home
>     
>   trigger:
>     platform: state
>     entity_id: input_select.xxxx
>     from: "Away"
>     to: "Home"  
> 
>   condition:
>     condition: or
>     conditions:
>       - condition: state
>         entity_id: input_select.home_mode
>         state: "Good Morning"
>       - condition: state
>         entity_id: input_select.home_mode
>         state: "Good Day"
>       - condition: state
>         entity_id: input_select.home_mode
>         state: "Good Afternoon"
>       - condition: state
>         entity_id: input_select.home_mode
>         state: "Good Evening"
> 
>   action:
> #turn on hue lights
>     service: script.turn_on
>     data_template:
>       entity_id: >
>         {% if is_state("sun.sun", "above_horizon") %}
>           script.home_before_sunset
>         {% else %}
>           script.home_after_sunset
>         {% endif %}

In your trigger did you mean input_select.xxxx or is that a typo? Are it’s state’s really Away and Home, or might they be lower case?

Yes this is correct except for the xxxx part, I just removed some information there. The automation itself runs when triggered, but not the scripts which are supposed to trigger.

So what makes you say the automation runs, but not the script it calls? I.e., what do you see that leads you to believe the automation triggered, and at the same time, what do you see that indicates one of the scripts did not get called? FWIW, I don’t see anything wrong with your automation, at least syntactically. Have you tried triggering the automation manually to see if one of the scripts runs? Have you tried starting the scripts manually to see if they do what you expect?

I can see in the logbook that the automation is triggered and I can trigger the script manually and everything works. But when the automation is triggered none of the scripts actually runs.

Ok, thanks. Hmm, very interesting. So one thing I’m not sure about is, will it say the automation runs, even if the conditions evaluate to false??? Going on the assumption that it does (although I had assumed the opposite), how about temporarily removing or commenting out the conditions of the automation? If you do that, does it work? If so, then apparently none of the conditions are evaluating to true. If it still doesn’t work, then I’m stumped. (Or, I know, probably a stupid question, but is the automation on?)

Solved it. Was a naming error. Thanks for assisting.

1 Like