Lately, I’ve been fascinated with idea of derivative helpers within Home Assistant. I thought this was a neat example case: My TV inputs the sound into the stereo amplifier via an optical audio cable which does not relay volume changes. Before, I had to manually control the stereo with a IR remote or IR blaster. Now, I have my IR blaster (Broadlink) controlled stereo synchronized with the Chromecast volume controls! Here’s how you can too:
- Create a yaml template sensor with the state_attr() of the chromecast’s volume multiplied by 100 (%).
- Create a derivative helper imputing this sensor’s volume.
- Thus a derivative >0 indicates a desire to increase the volume
- And a derivative <0 indicates a desire to decrease the volume.
- Set up automations that trigger when the derivative reaches certain thresholds (example below). The action should increase or decrease the stereo’s volume via IR command in proportion to the derivative.
- 3-6 = volume +++
- 1-3 = volume ++
- 0.01-1 = volume +
- (-1)-(-0.01) = volume -
- (-3)-(-1) = volume –
- (-6)-(-3) = volume —
- Create a separate automation that examines the sensor’s volume such that when it is 0% the stereo is muted and when it is 100% the stereo is un-muted.
The end result is your non-smart stereo can be controlled by your phone/PC within the casted player!