Home Assistant Community

Harmony Activities, Volume Slider, and Lovelace

templates
Tags: #<Tag:0x00007fcf515fb090>
#41

Yeah I’m getting the same impression to be fair
I’ve set the update interval to 120 secs, in the hope of staying within the request limit. I can live with a 2 minutes delay.

#42

Mine is set to 90 and I hit the limit around half way through the day for some reason. I think they lowered the free limit.

#43

According to the site, it’s 60 API requests per hour

#44

Awesome write up Petro! I will definitely be attempting to set this up once we get into our new home. I also have a newer Yamaha receiver, but waiting until we move into our new home to set it up. Right now I have two harmony hubs running (one in LR and BR).

Do you have any recommendations for a simple setup on the lovelace IU? I’m only running
TVs in each room with soundbars (two hubs), so this seems like overkill for my current setup. I was just wondering if you have an suggestions. Again, thank you for all your contributions within the community. I’m fairly new to the Home Assistant community and noticed you are always posting awesome stuff.

#45

It’s really up to you. You need to answer these questions:

  1. How do you want to turn on your activities? Dropdown or Switch? Personally, I hate dropdowns on cellphones, so I went with switches.

  2. Do you want quick access to volume controls?

  3. Do you want the volume to disappear when the system is off?

If yes, then you still will pretty much mimic a lot in this thread. For the simplest setup. You’d still need a way to activate your activities, which would just be the template switches. Volume controls are on the media players so you wouldn’t need that.

1 Like
#46

Thank you again, Petro. Great points! I’m sure I’m just over thinking it as far as incorporating volume using standard harmony controls. If I understand correctly, I just wont be able to incorporate the slider given harmony won’t report volume back to Ha. Is this correct? I definitely prefer switches over dropdown too. Going to start on this tonight.

#47

Hi, I reached this page because an user in our italian community for HA linked it to me, I managed alone to create volume slider for my Alexa media player and read that the lag of slider not immediatly refreshing with volume level is due to an update time setting of the Alexa integration. So I’m asking if I had understood well : is not possible an instant refresh of the slider if I have no cloud Alexa integration with Hassio (in my case I use hassio and haaska method for alexa integration)? What can I do to fasten the refreshing of the slider? I have added this feature now so I did not make many experiments in this field, sorry if I say something wrong.

#48

There’s nothing you can do other than implement a different volume method for alexa. Your limitation is with the components polling rate.

#49

So, been working on this damn slider in automation and had to adjust a few things from your example, below is what made it work for me: (had to remove the condition part of setting volume, couldn’t understand why validation of config kept failing )
Some trip to get to understand this stuff, but thx for the lead to solution :slight_smile:

  alias: 'Woonkamer :  set DB waarde'
  trigger:
  - entity_id: media_player.yamaha_receiver
    platform: state
  condition:
  - condition: template
    value_template: '{% set converted = ( -1.0 + trigger.to_state.attributes.volume_level
      | float ) * 100.0 | round(0.0) %} {{ converted != states(''input_number.yamaha_receiver'')
      | float }}

      '
  action:
    service: input_number.set_value
    data_template:
      value: '{{ ( ( -1.0 + trigger.to_state.attributes.volume_level | float ) * 100.0
        ) | round(0.0) }}
        '
      entity_id: input_number.yamaha_receiver
  alias: 'Woonkamer: set volume'
  trigger:
  - entity_id: input_number.yamaha_receiver
    platform: state
  action:
    service: media_player.volume_set
    data_template:
      volume_level: '{{ (1.0 + trigger.to_state.state | float / 100.0 )
        | round(2) }}
        '
      entity_id: media_player.yamaha_receiver
#50

The equation might be wrong

Try this one:

- id: denon_media_to_slider
  alias: Zone 1 Volume (Media to Slider)
  trigger:
    - platform: state
      entity_id: media_player.denon_avr_3310
  condition:
    - condition: template
      value_template: >
        # convert to decibel.
        {% set converted = ( -1.0 + trigger.to_state.attributes.volume_level | float ) * 100.0 | round(0) %}
        # Removes feedback loop
        {{ converted != states('input_number.denon1_receiver') | float }}
  action:
     service: input_number.set_value
     data_template:
       entity_id: input_number.denon1_receiver
       value: >
          {{ ( (-1.0 + trigger.to_state.attributes.volume_level | float ) * 100 ) | round(0) }}

- id: denon_slider_to_media
  alias: Zone 1 Volume (Slider to Media)
  trigger:
    - platform: state
      entity_id: input_number.denon1_receiver
  condition:
    - condition: template
      value_template: >
        # convert from decibel.
        {% set converted = (1.0 + trigger.to_state.state | float / 100) | round(2) %}
        # Removes feedback loop
        {{ converted != state_attr('media_player.denon_avr_3310','volume_level') | float }}
  action:
    - service: media_player.volume_set
      data_template:
        entity_id: media_player.denon_avr_3310
        volume_level: >
          {{ (1.0 + trigger.to_state.state | float / 100) | round(2) }}
#51

ok thank you, what method do you suggest? So I start searching, beacause I’m not so expert in coding and for me a step by step or done example is usefull. Maybe for different method you referr to buttons instead of sliders? You have done many differents things so I will look at your projects.

#52

If there is a noticable delay, I’d look for template switches or scripts that increment your volume by a large ammount, say 3 or 5 or 10. I know people have done it so it should exist. Don’t bother using the search on this site either. Go to google to search and use the tag ’site:community.home-assistant.io and it will find relevant forum posts for what you are trying to do. It won’t be step by step instructions, but it will be a bunch of people trying to figure it out.

#53

Is there a way to use use this with two different hubs?

entities:
  - switch.music
  - switch.music_downstairs
entity: sensor.harmony_activity
state_image:
  PowerOff: /local/remote.png
title: Harmony
type: picture-glance

sensor.harmony_activity works with switch.music, but switch.music_downstairs is tied to another hub

#54

No you’d need 2 different picture-glances. What happens when both are on at the same time?

#55

ok, thanks, only one works

#56

Thank you for sharing, great job ! Do you mind sharing the logos you are using?

#57
1 Like
#58

I’m having trouble with the automation that updates the volume level in the interface when changing the volume from Harmony. I don’t need the conversion to db, but since I don’t really understand templates yet, I tried using those anyway in hopes that it would work. It doesn’t.

This is what I have:

  • id: ‘1556652485641’
    alias: Harmony to Slider
    trigger:
    • platform: state
      entity_id: media_player.onkyo_tx_nr626
      condition:
    • condition: template
      value_template: >
      {% set converted = ( -1.0 + trigger.to_state.attributes.volume_level | float ) * 100.0 | round(0.0) %}
      {{ converted != states(‘input_number.harmony_my_volume’) | float }}
      action:
      service: input_number.set_value
      data_template:
      entity_id: input_number.harmony_my_volume
      value: >
      {{ ( ( -1.0 + trigger.to_state.attributes.volume_level | float ) * 100.0 ) | round(0.0) }}

Any help with removing the unnecessary conversions?
Thanks!

#59

if you don’t have to convert to DB, then it’s a 1 to 100 equation. You need to set the range of your slider from 0 to 100. Then just remove the negative 1 from the equations. You’ll have to adjust the equations too mathematically, I.E remove unnecessary parenthesis and such.

#60

That makes sense. Thank you!