I’ve recently purchased a Google Home Mini and am playing Pandora through it. They seem to jack up the volume on the ads. So I’m trying to fix that. Here’s the code I’ve got working (via Automations), but watching the logs show that it’s firing every second! There’s gotta be a better way. I looked into AppDaemon and that’s way over my head. Any ideas? (Btw this the format that the Automation helper tool puts it in… sorry the order is confusing!)
Basically what it does is watch to see if the media_duration value is < 60 seconds. If it is, then it’s an ad and mutes it. I was trying to use booleans but that didn’t really work.
You could try a NUMERIC STATE as the trigger instead of the condition.
automation:
trigger:
platform: numeric_state
entity_id: sensor.temperature
# Optional
value_template: '{{ state.attributes.battery }}'
# At least one of the following required
above: 17
below: 25
# If given, will trigger when condition has been for X time.
for:
hours: 1
minutes: 10
seconds: 5
You have double single quotes round the value_template, should be ----> value_template: ‘{{ states.media_player.kitchen_speaker.attributes.media_duration }}’
However not sure how much difference it will make.
I was looking at that. The automation editor is a little funky, I think.
This looks more promising:
value_template: '{{ states.media_player.kitchen_speaker.attributes.media_duration
| int }}'
Adding the | int part seems to fix an unusual error that I was getting: WARNING (MainThread) [homeassistant.helpers.condition] Value cannot be processed as a number: '221'
I hate to necro this, (but since it so close to Halloween anyway), can we put a “delay” statement for the remaining duration of the media to keep it from firing every second?
it probably has something to do with how HA changed the way scripts are handled. I think you can make this script mode single and it won’t run more than once if you put a 30 sec delay at the bottom.