Rule broken

Can’t find any breaking changes in 0.85.1 which could affect a rule that was working for 2 years.
85 and not 86 introducing a breaking change with time_pattern

Script checker also keeps silence. but in the logs

[homeassistant.components.automation] Error while executing automation automation.sound_vannaya_gong_at_12_clock. Invalid data for call_service at pos 1: Service does not match format .

- alias: Sound Vannaya Gong at 12 Clock
      initial_state: 'on'
      trigger:
        platform: time
        hours: 12
        minutes: 00
        seconds: 0
      condition: 
      - condition: state
        entity_id: input_boolean.rules_away
        state: 'off'
      - condition: state
        entity_id: input_boolean.rules_sleeping
        state: 'off'
      action:
      - service_template: >
          {% if states.media_player.vannaya.state == "paused" or states.media_player.vannaya.state == "idle" %}
          {% else %}
            media_player.media_pause
          {% endif %}
        entity_id: media_player.vannaya
      - service: media_player.volume_set
        data:
          entity_id: media_player.vannaya
          volume_level: 1.0
      - service: shell_command.sound_12am

My understanding of time trigger is

  trigger:
    platform: time
    at: '12:00:00'

I could be wrong

1 Like

is it just the way it’s been pasted into the forum? The indentation looks out for the listed service calls. They should be indented 2 spaces, then the dash relative to action…same for the conditions

but looking at the indentation of everything relative to ‘alias’, it looks like maybe its a forum post thing… indentation is off

      action:
      - service_template: >
          {% if states.media_player.vannaya.state == "paused" or states.media_player.vannaya.state == "idle" %}
            ### YOU NEED TO PUT A SERVICE HERE ### <-----------------
          {% else %}
            media_player.media_pause
          {% endif %}

@tom_l is right and this has been the bane of my (HA) life.

I wish service_template would just do nothing if none of the if conditions are met.

What is interesting though is that you say it has been working for two years. The only way I can see that that would be true is if your if condition has never been true. And if that is the case it is possible you might be suffering from a problem that I am with media_player states seemingly being inconsistent / wrong / unexpected. See here… Sonos component and unexpected state changes (BUG?)
(I use Sonos but maybe it is a more general issue?)

maybe give this a try:

- alias: 'Sound Vannaya Gong at 12 Clock'
  id: 'Sound Vannaya Gong at 12 Clock'
  initial_state: 'on'
  trigger:
    platform: time
    at: '12:00:00'
  condition:
    - condition: template
      value_template: >
        {{ is_state('input_boolean.rules_away','off')}}
    - condition: template
      value_template: >
        {{ is_state('input_boolean.rules_sleeping','off')}}
  action:
    - service_template: >
        {% if states('media_player.vannaya') in ['paused', 'idle'] %} #add media_player.command
        {% else %} media_player.media_pause
        {% endif %}
      entity_id: media_player.vannaya
    - service: media_player.volume_set
      data:
        entity_id: media_player.vannaya
        volume_level: 1.0
    - service: shell_command.sound_12am

edited the spacing, use states() format all over, changed to the new time trigger format, changed the condition templates so you can check them in dev-template, compacted the service_template (check too in dev-template) and remember to add a service in the ‘true’ section…

Strangely enough your code worked without errors in the log
Of course i didn’t put anything to the #add media_player.command as this is the only way to tell the template to do nothing. Very strange…

{% if states('media_player.vannaya') in ['paused', 'idle'] %} #add media_player.command
{% else %} media_player.media_pause

thats not strange… its using the correct formats :wink:

no its not, and it not very wise to do so. You leave your automation in limbo. Sorry I didn’t understand that from your triggers.

If you don’t want to do anything use a dummy script:

script:
  dummy:
    sequence:
      delay: 00:00:00

but that might not work with the entity_id, so I have to give this anther thought.

at 12, you want all to stop (if they’re playing) to sound the 12am. thats it isnt it?

easiest would be to write to small scripts

script stop
script play 12sound

and call these with:

 - service_template: >
     {% if states('media_player.vannaya') in ['paused', 'idle'] %} script.play_12sound
     {% else %} script.stop
     {% endif %}

the script can have the same services as before.

Why is using the states format the correct one?

it takes care of situations where entities are not or not yet initialized, and stop a template from throwing an error, see Template - Home Assistant for more explanation.

I also think is much better on the eye, and easier to spot typo’s. But that’s just my preference.