Volume Slider with Broadlink

Hi All,

I am trying to control the volume of my tv with a slider (see picture attached). Based on the config below I managed to get the slider in frontend but that is not functional. Below is also the input_number and automation that i tried to set up but i suspect I am not doing something right by the last part of automation.

Any help would be appreciated.

PS. I am totally new to HA.

Imgur

switch:
  - platform: broadlink
    host: 192.168.0.20
    mac: '34:EA:34:C7:9F:7D'
    switches:
      receiver:
        friendly_name: "Resiveri Ipko"
        command_on: 'JgBQAAABJJETERMRFBETERQRExETEhMRFBETNhM2EzYUERM2EzYUERMRFBETNhM2FBAUERMRFBEUNRQ1FBISEhM1FDYTNhM2EwAFZgABJEcUAA0FAAAAAAAAAAA='
        command_off: 'JgBQAAABJJAUERMRFBETERQRExEUEBQRFBETNhM2FDUUERM2EzYUERMRFBETNhM2FBETEhISExITNRQ1FBITEBQ2EzYTNhM2FAAFZQABJEcUAA0FAAAAAAAAAAA='
      tv_box:
        friendly_name: "TV"
        command_on: 'JgCMAJOVETkRORE5EBUQFRAUERQRFBE5ETkQOREUERQRFBEUERQQFRA6EBQRFBEUERQRFBEUEDoQFRA5ETkRORA6EDkROREABgeTlhA5ETkRORITEBURFBEUERMSOBI4EjgRFBETEhMSExITEhMSOBEUERQRExITEhMSExI4ERQROBI4EjgSOBE4EjgSAA0FAAAAAAAAAAAAAAAA='
        command_off: 'JgCMAJOWEDoQORI4EhMSExEUEhMSEhM3EzcTNxITEhITEhMSExITEhM3ExISExISExITEhMSEzcTEhI3EzcTNxM3EzcSNxMABgWVlBM3EjcTNxMSExITEhMSEhMSNxM3EzcTEhITEhITEhMSExITNxMSExISEhMSExITEhM3ExITNhM3EzcTNxM2EzcTAA0FAAAAAAAAAAAAAAAA='
      tv_box_volume_up:
        friendly_name: "Volume +"
        command_on: 'JgCMAJWUEzcTNxM2ExITEhMSExITEhM3EjcTNxMSExITEhMSExISNxM3EzcTEhMSEhMSEhMSExITEhMSEzcSOBI3EzcTNxMABgSWkxM3EzcTNxISExITEhMSExITNxM2EzcTEhMSExITEhMSEjcTNxM3ExITEhMSEhITEhMSExITEhM3EzYTNxM3EzcTAA0FAAAAAAAAAAAAAAAA'
      tv_box_volume_down:
        friendly_name: "Volume -"
        command_on: 'JgCMAJWUEjgSNxM3ExITEhITEhITEhM3EzcTNhMSExITEhMSExITNxI3ExITNxMSExITEhITEhITEhM3ExITNxM2EzcTNxMABgWVlBI3EzcTNxMSEhMSEhMSExITNxM3EzYTEhMSExITEhMSEzcSNxMSEzcTEhMSExISExISExITNxMSEzcSNxM3EzcTAA0FAAAAAAAAAAAAAAAA'
  - platform: broadlink
    host: 192.168.0.20
    mac: '34:EA:34:C7:9F:7D'
 
input_number:
  tv_box_volume:
    name: Volume
    initial: 0
    min: 0
    max: 100
    step: 1

automation:
  - alias: Volume TV Box
    hide_entity: True
    trigger:
      platform: state
      entity_id: input_number.tv_box_volume
    action:
      - service: input_number.set_value
        data_template:
          entity_id: switch.volume_
          value: '{{ states.input_number.tv_box_volume.state | int }}'

Anyone that can lead me to the right direction?

From what I can tell, you’re trying to send a numeric value from input_number.tv_box_volume, to an on/off switch. This won’t work. The on/off switch doesn’t know what to do with a numeric value. It’s like sending “25” to a switch that only recognizes “on” or “off”.

Basically my hardware is this: raspberry pi (HA) -> broadlink -> TV

What i am trying to achieve is to have a slider that I can change the volume from 1 to 100. The script probably is wrong but that is what i did till now. Any idea what changes should i do in order to achieve that?

The hardware should be capable enough to support this, correct?

From what I understand, your TV only receives the IR codes, so it doesn’t return its state ?
This way, you cannot know how loud is the volume. Thus when you move the slider, you can’t decide if you’re going to send vol+ or vol- to achieve what the user wants.

Either you stick with vol+/vol- (look at the broadlink IR/media_player component to make it look nice).

Either you force the volume depending on the slider : Since you don’t know the current TV volume, you have to put it in a state you’ll know. Say TV has 20 levels of volume. When the slider has moved to, say 12, you’ll have to : send 20 ‘vol-’ command, here you KNOW you are at vol 0, then send 12 ‘vol+’. Depending on the device, it can be very long…:sleeping:

Or you keep a trace of the current volume in some variable, you assume that the volume isn’t changed by any other mean, and after slider change, you send vol+/vol- as many times as needed depending on the previous value.

@Mister_Slowhand thank you for your explanation. I was pretty confident about the facts that you presented but nevertheless I thought maybe there was a simple way to do so. I like the idea of broadlink IR/media_player component and I just found a good link which I am going to try. Thank you again for you feedback.

I’m expecting a RM-Pro (it’s in transit… for 1 month now) when it arrives I’ll test this in deep !

has any one found a way to get the slider to work ? i have read thi issue with the broadlink not returning a value to ha and figure that would be the end of it but if there are any updates please keep me informed

Dear,.
Do you find a way to get it work.
Can you please share your configuration, sui that we can also have your way of getting it worked.

I tested this but not using it anymore.

Dear, I am usint this components,
but i cant get volume slider to work,
do you have any idea?

If you are attempting to use IR remote commands to set the specific volume of the TV, as mentioned earlier you are unlikely able to.

Normal TV IR remotes just use a volume up, volume down, and HA has no way of telling what the current volume is in order to make informed changes. Suggest you just use a Volume Up and Volume Down button tied to the appropriate IR code.

Have you seen whether the TV has an API you could interface to through the network? E.g. just looked up my ‘sharp tv api’ and it has this apparently https://github.com/jmoore987/sharp_aquos_rc