Ok, so the Echo allows me to say things like:
“Alexa, set the lights to 50 percent” or “Alexa, increase the lights by 5 percent”
Also, what’s cool, is that it allows me to say “Alexa, set the lights to 50” or “Alexa, increase the lights by 5”. In these cases, “percent” is inferred, and the lights do what I want.
This, to me, is considerably better than asking Alexa to ask Home Assistant to do something.
So… I’ve got a Yamaha receiver with volume control through HA. The Emulated Hue bridge (in my mind), should allow me to expose the volume control and say something to the effect of: “Alexa, set Vol to 35” or “Alexa increase Vol by 2”. I want the value I ask for to correspond to on-screen values. I don’t want to ask for 60% to get an on-screen value of -40 dB - that’s just annoying.
If I ask for a volume of 35, I actually want -35 dB. In this case, Alexa will try to change the volume level to 0.35, but what I want is 1-.35=.65.
If I ask for a volume increase of 5 and volume is at -40 dB, I want a result of -35 dB. Alexa will query current level - find it is 0.60, then increase it to 0.65 (resulting in an on-screen value of -(1-.65)*100).
In my scenario, each case can be detected. If I ask for a direct volume level, it will always result in a requested volume level below 0.50. If I ask for an increase or decrease in volume, it’ll always result in a requested volume level above 0.50.
It wasn’t particularly hard to figure out a slider component and an automation component that result in the values that I want. I’ve got it working pretty well - needs a tweak here and there, but at a basic level it does what I want. Unfortunately, sliders do not appear to be exposed to Emulated Hue Bridge (at least not by default).
My question: What component can I use to expose a “custom” dimmable device to the Echo?
#input_sliders.yaml
vol:
name: vol
initial: .6
min: 0
max: 1
step: .005
#automation.yaml
- alias: Set Volume
hide_entity: True
trigger:
platform: state
entity_id: input_slider.vol
action:
- service: input_slider.select_value
data_template:
entity_id: input_slider.vol
value: >-
{%- if is_state('media_player.receiver', 'on') %}
{%- if states.input_slider.vol.state|float >= 0.5 %}
{{-states.input_slider.vol.state}}
{%- else %}
{%- set n = states.input_slider.vol.state|float %}
{{- '%.005f'%( (1.0-n)|round(0.000) ) }}
{%- endif %}
{%- else %}
0
{% endif %}
- service: media_player.volume_set
data_template:
entity_id: media_player.receiver
volume_level: '{{ states.input_slider.vol.state }}'