Using INPUT_NUMBER to control TV Volume

I’m hoping somebody can point me in the right direction here.

I’ve created an automation to control the volume on an android TV device using a slider as input

alias: TV_Volume
description: ""
trigger:
  - platform: state
    entity_id:
      - input_number.tv_volume
    attribute: volume
condition:
  condition: template
  value_template: '{{ states.input_slider.tv_volume.state != states.sensor.sm_t510_volume_level_music }}'
action:
  - service: notify.mobile_app_sm_t510
    data:
      message: command_volume_level
      data:
        media_stream: music_stream
        command: "{{ states('input_number.tv_volume') | int }}"
mode: single

and under configuration.yaml

input_number:
  tv_volume:
    name: volume
    initial: 10
    min: 0
    max: 15
    step: 1

When I change the slider value the automation isn’t getting triggered. If I trigger the automation manually then the slider value gets updated and the TV volume changes.

What am I doing wrong?

Remove this from the trigger:

    attribute: volume

The input number has no attribute called “volume”. You want to trigger on the input number state change.

Also change your template condition to

value_template: "{{ states('input_number.tv_volume') != states('sensor.sm_t510_volume_level_music') }}"

Also note you only have a notification action. You have no actual action to change the volume.

Thanks! I did see the typo and I got rid of the “attribute: volume” and the slider now works.

I’m not sure what you mean by “have no actual action to change the volume” as I’m using the service “service: notify.mobile_app” to send the volume change command

1 Like