Problems with Templates, Volume Control as a Light, and Homekit
I've been trying to add voice control of my AVR via Home Assistant and Homekit, but I'm having difficulty setting this up. First off, before anyone says: "using a light for voice control? WTF?" Please refer to this link:
https://community.home-assistant.io/t/template-light-as-speaker-volume-control/80742
Homekit apparently has no mechanism in controlling volume. (At least so it seems, the article above may be old? But I haven't seen anything contrary to this? I digress). Regardless, I've implemented the yaml example contained in the above link, but for clarity sake, here's mine:
- platform: template
lights:
media_zone:
friendly_name: "Media Zone"
value_template: "{{ is_state('media_player.denon_avr_s730h', 'on') }}"
turn_on:
service: media_player.turn_on
data:
entity_id: media_player.denon_avr_s730h
turn_off:
service: media_player.turn_off
data:
entity_id: media_player.denon_avr_s730h
set_level:
service: media_player.volume_set
data_template:
entity_id: media_player.denon_avr_s730h
volume_level: "{{ (brightness | float / 255 ) }}"
level_template: "{{ (state_attr('media_player.denon_avr_s730h', 'volume_level')|float * 255)|int }}"
In Homekit, this kind of works, what's weird is in how it works. For some reason, even whole base ten #s work, but odd base ten #s do not. Additionally, nothing in between works. In other words:
"Hey Siri, set the Media Zone volume to 40%" This works 20%, 40%, 60%, 80% all work
But, 10%, 30%, 50%.... and 23%, 44%, 32%, etc. do not.
Any help? I've tried tweaking the templates but I still get the same results as above. Or, is there a better way?
Posted Jul 17, 2020, 1:23 AM UTC