Volume slider with button - like light type sensor

Hello,
Can you please help me how to create switch button with slider? Similar to light sensor as is defined in HA.
For better explain I include image how it should look like.

speaker-slider-example

Actually I have switch which is operating as on/off for speakers. Also I defined number slider 0-100 of system volume, which is used with automation to set system volume. I would like have this two entities altogether. Is it possible control both entities even if switch will be off, it will be nice to set volume first and then turn on speakers.

Used entities:
entity: switch.socket_sound (on / off)
entity: input_number.volume_value (0 - 100)

Thank you for your advice.

What happens if you create a template light entity and change the icon to a speaker?
Do you get that result?
If so then I think you can use a template light to do the job

Closest I can think of for what you want would be the slider button card (available in HACS under frontend)

Than you for your reply, time ago I was looking at HACS, but I’m wondering with compatibility with HA after updates, so I’m trying to do not use it. Also I’m not sure how well it is working with HA installed on docker.

Good point, thank you.

I tried it, that looks well, but I’m not sure what I’m doing wrong, slider is working from 1% to 100% which is acceptable, but if i go to lovelace first time it is showing 1% until I change it, something with level_template is wrong . Code what I’m trying:

light:
  - platform: template
    lights:
      bedroom_speaker:
        friendly_name: "Bedroom speaker"
        value_template: >-
          {% if is_state('switch.socket_sound', 'on') %}
              on
          {% else %}
            off
          {% endif %}
        icon_template: >-
          {% if is_state('switch.socket_sound', 'on') %}
            mdi:speaker
          {% else %}
            mdi:speaker    
          {% endif %}
        turn_on:
          service: switch.turn_on
          target:
            entity_id: switch.socket_sound
        turn_off:
          service: switch.turn_off
          target:
            entity_id: switch.socket_sound
        set_level:
          service: input_number.set_value
          data:
            value: "{{ (brightness / 255 * 100)|int }}"
            entity_id: input_number.volume_value
        level_template: "{{states('input_number.volume_value') |float / 100 |float * 255 | int}}"

That’s fine, just pointing out that there was something that might do what you want.

As to compatibility with HA, the primary dev of HACS is actually an employee of Nabu Casa, so they work full time on HA :wink: also, towards the comment of HA installed on docker, HAOS itself is just using the docker container version of HA.

I use HACS with HAOS and when I first started playing with HA, it was in a pure python virtual-env. It just works.

Finally, you don’t have to install HACS to make this work. The repository I linked to has instructions on how to install the custom card without HACS.

When the switch is off, level is showing 0, when switch is on, then level is showing correct volume value. Any idea how to force show level even if switch is off? :slight_smile:

I don’t think that is possible.
Lights are 0 when off

I tried this module, but it’s the same as light bulb, if switch is off, then no slider value is visible.

I worried about that, so I will accept with this state. Thank you.