Harmony Activities, Volume Slider, and Lovelace

templates
Tags: #<Tag:0x00007f058439d920>

#21

I think you’ll have to look up the custom button for Lovelace. It allows buttons that can be sized without text (icon only).


#22

If I have no network enabled Receiver connected to Harmony, how would I send volume up/down commands to it through some nicer UI, like switch or something?
I am able to do this from script, like below, but how do I integrate it to something nicer?

reciever_volume_up:
    alias: Volume up
    sequence:
        service: remote.send_command
        data:
            entity_id: remote.living_room
            command:
                - VolumeUp
            device: 59394436

#23

you can call the script from a button. You won’t be able to make a slider if you don’t have a way of knowing the current volume level. So your only option with harmony is to repeat commands. I.E. call the volume up command 5 times.


#24

Yes, sure, I understand it, I only control the Receiver through IR, so no slider of course.
I don’t even need 5 to repeat, 1 is enough.
I was able to create the scripts and add them to group, which is fine and working (see the screen), however this “EXECUTE” does not look good. If I could somehow put all 3 of them on one row/switch and customize each with an icon, that would be much better. And I could not find a way to define any working switch template for that.


#25

You can’t do anything else unless you use Lovelace. Unfortunately you are limited with the native UI unless you use custom UI.


#26

I might have a solution to your problem. I also don’t have a network controlled receiver yet and have been using this as a workaround in the meantime. It’s not perfect but it does look nicer than using scripts on the frontend.

image

What I did was created an input_number like so…

denon_volume:
  name: Volume
  initial: 5
  min: 0
  max: 10
  step: 5
  mode: slider

Then I created two automations; one that when the slider is moved up it turns the volume up and then resets the slider back to the middle position. Then another automation that does the opposite like so…

- id: denon_vol_down
  alias: Denon Volume Down
  trigger:
    platform: state
    entity_id: input_number.denon_volume
    to: '0.0'
  action:
  - service: input_number.set_value
    entity_id: input_number.denon_volume
    data:
      value: '5.0'  
  - service: remote.send_command
    entity_id: remote.living_room
    data:
      device: '46571740'
      command: 'VolumeDown'
      num_repeats: '10'
  
- id: denon_vol_up
  alias: Denon Volume Up
  trigger:
    platform: state
    entity_id: input_number.denon_volume
    to: '10.0'
  action:
  - service: input_number.set_value
    entity_id: input_number.denon_volume
    data:
      value: '5.0'
  - service: remote.send_command
    entity_id: remote.living_room
    data:
      device: '46571740'
      command: 'VolumeUp'
      num_repeats: '10'

#27

Thanks!
Well, I have used the glance card for that in lovelace ui and that sort of made it look better as well.


#28

Hi petro, is it possible for a link to the png images, going to have a go at this later and have nearly the same setup, even the amp. Many thanks, this looks great!


#29

Yes, here they are


#30

Many thanks, will be working on this tonight!


#31

I’ve been using this card: Lovelace: Button card
to create this:
image

And this is the corresponding code in ui-lovelace.yaml:

  - title: Radio
    icon: mdi:radio
    cards:
      - type: vertical-stack
        cards:
        - type: "custom:button-card"
          name: Radio Channels
          style:
#            - color: rgb(44, 109, 214)
            - font-size: 19px
#            - font-weight: bold
        - type: horizontal-stack
          cards:
          - type: "custom:button-card"
            color_type: icon
            color_off: rgb(44, 109, 214)
            icon: attribute
            entity: script.radio_10
            name: Radio 10
            size: 22%
          - type: "custom:button-card"
            color_type: icon
            color_off: rgb(44, 109, 214)
            icon: attribute
            name: Sky Radio
            size: 22%
            entity: script.radio_sky
        - type: horizontal-stack
          cards:
          - type: "custom:button-card"
            color_type: icon
            color_off: rgb(44, 109, 214)
            icon: attribute
            name: NPO3 FM
            size: 22%
            entity: script.radio_npo3
          - type: "custom:button-card"
            color_type: icon
            color_off: rgb(44, 109, 214)
            icon: attribute
            name: Omrop Fryslan
            size: 22%
            entity: script.radio_frl
        - type: entities
          title: Volume
          show_header_toggle: false
          entities:
            - input_number.slider1
        - type: horizontal-stack
          cards:
          - type: "custom:button-card"
            entity: script.receiver_volume_up
            color_type: icon
            color_off: rgb(44, 109, 214)
            icon: mdi:volume-plus
          - type: "custom:button-card"
            color_type: icon
            color_off: rgb(44, 109, 214)
            icon: mdi:volume-minus
            entity: script.receiver_volume_down
          - type: "custom:button-card"
            color_type: icon
            color_off: rgb(44, 109, 214)
            icon: attribute
            name: Radio OFF
            size: 28%
            entity: script.radio_off

#32

This is such a great documentation. Thanks for that! I have one question regarding the receiver switches. I have an activity on my harmony called “Listen to Music”. Obviously it only turns on the receiver. From looking at the code it seems the switch status and the volume sliders are only displayed correct if the status of the receiver is “on”. But when only listening to music it is either “idle” or “playing”. I did not manage to adapt the code respectively and I’d be happy about some help. Thanks folks.


#33

Hm okay. It was so much easier than expected… Just didn’t realize I need to restart HA in order for switch.yaml changes to take effect. It is a simple ‘or’ like this:

"{{ is_state('media_player.yamaha_receiver_family_room', 'on') or is_state('media_player.yamaha_receiver_family_room', 'idle') or is_state('media_player.yamaha_receiver_family_room', 'playing') }}"