My automation does not trigger

Thank you! That explains everything now.

It all hinges on the inclusion of the entity_id option in your Template Sensor:

        entity_id: sensor.date, sun.sun, switch.irrig_front_side_yard

On startup, the entities listed in entity_id supersede the ones found within the value_template.

What that means is Home Assistant will listen for changes to:

sensor.date, sun.sun, switch.irrig_front_side_yard

as opposed to listening to:

input_datetime.irrigation_side_lastwatered
  • sensor.date only changes once a day, a moment after midnight. Thatā€™s when it will cause the value_template to be evaluated. Itā€™s infrequent so it doesnā€™t contribute much to this Template Sensorā€™s evaluation frequency.
  • switch.irrig_front_side_yard changes whenever you change it (either manually or perhaps via some automation). In other words, it changes infrequently so it too isnā€™t a significant contributor to the evaluation frequency.
  • sun.sun has elevation and azimuth attributes whose values are updated periodically. The interval is not fixed but varies according to the sunā€™s position (typically every few minutes or less). This is the principal contributor to how often your Template Sensor is evaluated.

This is a strange mix of entities to use as listeners and Iā€™m not sure why you chose them. When thereā€™s a need to evaluate a value_template every minute, the usual choice is to add sensor.time to entity_id`.

I wanted an update first thing every day and if someone triggered the button. I guess sensor sun.sun can be removedā€¦

The template checks if todayā€™s date matches the one specified by input_datetime.irrigation_side_lastwatered. Based on that need, I suggest something like this:

        entity_id: sensor.date, switch.irrig_front_side_yard, input_datetime.irrigation_side_lastwatered

It means the template will be evaluated at the start of every day plus if and when either the switch and input_datetime change state.

1 Like