Automation stopped working after update to core-2021.9.6

I have an automation that turns my living room lights to dark blue and turns on synching on my Hue Sync Box. This automation has been working well for weeks but after the update to core-2021.9.6 it fails with an error that the attribute media_duration doesn’t exist in the Apple TV entity.

Here’s a screen shot of the error

The automation condition that refers to it, showing it’s available in the attributes drop down

Finally the entity attribute list from the Dev Tools State screen

So it certainly does seem that this attribute exists but the automation (which been using it successfully) is now no longer able to access it.

Does anybody have any ideas?

Thanks in advance.

Can you post your automation YAML code?

Hey Andy. Here ya go.

alias: Turn on Hue Sync box and sync
description: >-
  When playing video media on the living room Apple TV, turn on the Hue Sync box
  and start syncing. 
trigger:
  - platform: device
    device_id: 06a9b13909da3ca094ec79940850c39c
    domain: media_player
    entity_id: media_player.living_room_atv
    type: playing
condition:
  - condition: template
    value_template: >-
      {{ state_attr('media_player.living_room_atv', 'app_name') in ['ABC',
      'AMC', 'Disney+', 'Hulu', 'Movies', 'Netflix', 'Paramount+', 'Plex',
      'Prime Video', 'STARZ', 'SYFY', 'HBO Max'] }}
  - condition: state
    entity_id: group.livingroom_lights
    state: 'on'
  - condition: state
    entity_id: group.livingroom_shades
    state: closed
  - condition: numeric_state
    entity_id: media_player.living_room_atv
    above: '4200'
    attribute: media_duration
action:
  - device_id: 0d23577df85f9bbcdd90a94dbf66cc58
    domain: huesyncbox
    entity_id: media_player.sync_box
    type: turn_on
  - delay:
      hours: 0
      minutes: 0
      seconds: 3
      milliseconds: 0
  - device_id: 0d23577df85f9bbcdd90a94dbf66cc58
    domain: huesyncbox
    entity_id: media_player.sync_box
    type: sync_video_on
  - service: light.turn_on
    target:
      entity_id: group.livingroom_lights
    data:
      brightness_pct: 30
      color_name: darkblue
mode: single

I also experience the same error on my LG Web OS TV. The problem is because sometime the TV is not ready so the state attribute is not showing up in Home Assistant. Try this-

alias: Turn on Hue Sync box and sync
description: >-
  When playing video media on the living room Apple TV, turn on the Hue Sync box
  and start syncing. 
trigger:
  - platform: state
    entity_id: media_player.living_room_atv
    to: 'playing'
condition:
  - condition: state
    entity_id: group.livingroom_lights
    state: 'on'
  - condition: state
    entity_id: group.livingroom_shades
    state: 'closed' #You might want to verify again the actual state in Developer Tools
action:
  - delay: '00:00:03'
  - wait_template: "{{ expand('media_player.living_room_atv') is search('media_duration') and expand('media_player.living_room_atv') is search('app_name') }}"
    timeout: 10
    continue_on_timeout: false
  - condition: numeric_state
    entity_id: media_player.living_room_atv
    above: '4200'
    attribute: media_duration
  - condition: template
    value_template: >-
      {{ state_attr('media_player.living_room_atv', 'app_name') in ['ABC',
      'AMC', 'Disney+', 'Hulu', 'Movies', 'Netflix', 'Paramount+', 'Plex',
      'Prime Video', 'STARZ', 'SYFY', 'HBO Max'] }}
  - service: media_player.turn_on
    target:
      entity_id: media_player.sync_box
  - delay: '00:00:03'
  - device_id: 0d23577df85f9bbcdd90a94dbf66cc58
    domain: huesyncbox
    entity_id: media_player.sync_box
    type: sync_video_on
  - service: light.turn_on
    target:
      entity_id: group.livingroom_lights
    data:
      brightness_pct: 30
      color_name: darkblue
mode: single

Notice that I add-

  - wait_template: "{{ expand('media_player.living_room_atv') is search('media_duration') and expand('media_player.living_room_atv') is search('app_name') }}"

This is to check first that the attribute exist before attempting to check the condition. If both attributes exist, then it will check the condition. If not, the automation will not proceed.

Hey Ardy. Thanks so much for taking the time to help. So if I’m reading things right, the wait template will look for the attribute for 10 seconds, then timeout and stop the rest of the automation. That’s great! I don’t know enough about templates but it seems there’s a lot to love there. I did get the value for the shades state from the Dev Tools. That part seems to work fine. I’ve used the code you posted above to build a new automation. I’ll test it tonight. Thanks again for all your help. I owe you a beer.