I have an automation with a template that used to work fine. It searches the results of the sensor.sonarr_upcoming_media sensor for a specific match with a keyword and sets an input boolean.
I hadn’t used it for quite some time and when I recently re-enabled the automation it is now throwing the following error and I can’t figure out what’s wrong.
I’ve tried paring down the conditions of the template and all sort of formatting variations but always get the same error:
UndefinedError: 'dict object' has no attribute 'title'
The automation/template:
alias: Network - Bachelor(ette) Night On/Off
description: ""
trigger:
- platform: state
entity_id: sensor.sonarr_upcoming_media
attribute: data
- platform: time_pattern
minutes: "5"
condition: null
action:
- service: >-
input_boolean.turn_{{ 'on' if state_attr('sensor.sonarr_upcoming_media',
'data')|selectattr('title', 'match', 'Bachelor')|list|length > 0 and
(is_state('sensor.day_of_week', 'Tuesday') and states.sensor.time.state >
'17:00' | timestamp_custom('%H:%M') and states.sensor.time.state < '22:00'
| timestamp_custom('%H:%M')) else 'off'}}
target:
entity_id: input_boolean.bachelor_night
mode: single
max: 10
The output of the sonarr.upcoming_media sensor:
data:
- title_default: $title
line1_default: $episode
line2_default: $release
line3_default: $rating - $runtime
line4_default: $number - $studio
icon: mdi:arrow-down-bold
- airdate: '2022-08-05T04:00:00Z'
release: $day, $time
flag: false
title: For All Mankind
episode: Coming Home
number: S03E09
runtime: 60
studio: Apple TV+
rating: ''
genres: Drama, Science Fiction
poster: >-
https://artworks.thetvdb.com/banners/series/356202/posters/600304db98362_t.jpg
fanart: >-
https://artworks.thetvdb.com/banners/series/356202/backgrounds/6035368ae4176_t.jpg
- airdate: '2022-08-05T04:00:00Z'
release: $day, $time
flag: false
title: Loot
episode: Cahoga Lake
number: S01E09
runtime: 26
studio: Apple TV+
rating: ''
genres: Comedy
poster: >-
https://artworks.thetvdb.com/banners/v4/series/417559/posters/629ae434933f2_t.jpg
fanart: >-
https://artworks.thetvdb.com/banners/v4/series/417559/backgrounds/62b570d982e12_t.jpg
- airdate: '2022-08-06T02:00:00Z'
release: $day, $time
flag: false
title: Real Time with Bill Maher
episode: Episode 607
number: S20E22
runtime: 55
studio: HBO
rating: ★ 9.2
genres: Comedy, News, Talk Show
poster: https://artworks.thetvdb.com/banners/series/72231/posters/62062148_t.jpg
fanart: https://artworks.thetvdb.com/banners/fanart/original/72231-3_t.jpg
- airdate: '2022-08-08T01:00:00Z'
release: $day, $time
flag: false
title: Westworld
episode: Metanoia
number: S04E07
runtime: 58
studio: HBO
rating: ★ 8.9
genres: Adventure, Drama, Mystery, Science Fiction, Western
poster: https://artworks.thetvdb.com/banners/posters/296762-3_t.jpg
fanart: >-
https://artworks.thetvdb.com/banners/v4/series/296762/backgrounds/62ab03c0d4243_t.jpg
- airdate: '2022-08-09T00:00:00Z'
release: $day, $time
flag: false
title: The Bachelorette
episode: TBA
number: S19E05
runtime: 85
studio: ABC (US)
rating: ★ 6.3
genres: Drama, Game Show, Reality, Romance
poster: https://artworks.thetvdb.com/banners/posters/71187-8_t.jpg
fanart: https://artworks.thetvdb.com/banners/fanart/original/71187-4_t.jpg
friendly_name: Sonarr_Upcoming_Media