I’ve had an automation to set the volume to a certain level on the Nvidia Shield, and it quit working sometime back. I thought my ADB configuration had stopped working, but testing it today everything works EXCEPT setting the volume to a certain level (either through volume_set or via the slider in the UI). I.e. I can turn up/down/mute the volume but not set it to a certain level any more. It appear to work as far as HA is concerned (no error in the log) but the TV volume does not change.
Any pointers?
service: media_player.volume_set
data:
volume_level: 0.75
target:
entity_id: media_player.bedroom_android_tv_adb
Well I figured out a workaround on my own. I created a script that’s a direct replacement for volume_set:
choose:
- conditions:
- condition: template
value_template: "{{ state_attr(entity_id, 'volume_level')|float > volume_level }}"
sequence:
- repeat:
while:
- condition: template
value_template: >-
{{ state_attr(entity_id, 'volume_level')|float > volume_level|float }}
sequence:
- service: media_player.volume_down
data:
entity_id: "{{entity_id}}"
default:
- repeat:
while:
- condition: template
value_template: >-
{{ state_attr(entity_id, 'volume_level')|float < volume_level|float}}
sequence:
- service: media_player.volume_up
data:
entity_id: "{{entity_id}}"
1 Like
JimBr0
(Jim)
May 16, 2024, 6:05pm
3
Hey @TarheelGrad1998 mind posting the whole script? I’m not familiar with the ‘choose’ part yet.
alias: Volume Set Workaround
sequence:
- wait_template: "{{ is_state(entity_id, 'playing') }}"
continue_on_timeout: false
timeout: "00:01:00"
- choose:
- conditions:
- condition: template
value_template: "{{ state_attr(entity_id, 'volume_level')|float > volume_level }}"
sequence:
- repeat:
while:
- condition: template
value_template: >-
{{ state_attr(entity_id, 'volume_level')|float >
volume_level|float }}
sequence:
- service: media_player.volume_down
data:
entity_id: "{{entity_id}}"
default:
- repeat:
while:
- condition: template
value_template: >-
{{ state_attr(entity_id, 'volume_level')|float <
volume_level|float }}
sequence:
- service: media_player.volume_up
data:
entity_id: "{{entity_id}}"
mode: queued
icon: mdi:volume-equal
max: 10
fields:
entity_id:
selector:
entity:
filter:
- domain: media_player
name: Media Player Entity
description: Entity which will have the volume updated
required: true
volume_level:
selector:
text:
type: number
required: true
name: Volume Level
description: The numeric volume level to set the media player to
1 Like