Saving money (and the environment) with Home Assistant

When I started designing my new home a couple years ago, I knew I wanted whole home audio. What I didn’t know at the time was how expensive the products on the market were. I wanted 10 stereo zones of audio in the house, and there was no way I was going to pay $600 a pop for Sonos speakers.

I did some searching and found a relatively in-expensive multi-channel amplifier. For the price of about 1 Sonos speaker, I was able to get 12 channels of audio. On the plus side, they were manufactured by a company just up the road and have great reviews. I ended up buying 2 of the DMA-1240’s from Home Theatre Direct.

I then bought 10 Chromecast Audios (unfortunately, no longer manufacturered) @ roughly $30 ea and 10 sets of inexpensive speakers from monoprice. So, for roughly the cost of 1 room worth of Sonos, I was able to have 10 different sources of audio piped to any combination of 10 different rooms in the house. It works great! An alternative to the Chromecast Audios would be to use Raspberry Pi’s. There are lots of examples out there on how to do the same thing with them.

Now, here comes the home automation part. One of the things I didn’t like about my setup, was that the amplifiers were always on. 24 hours a day, 7 days a week, they were drawing about 50 watts of power each, when idle. This puts off a lot of heat and probably will make them fail earlier than needed, so one of the first things I tried to do with Home Asistant was solve that problem.

Easy peasy, with a custom component called Entity Controller, two in-expensive “smart” plugs, and a couple simple lines of configuration, the amplifiers now only turn on if there is a need, and only the amplifier(s) that need to be on, turn on.

First, I setup the 2 sensors to drive Entity Controller. Due to a limitation in Home Assistant, I currently have to list the items I want to track state changes on because, but was able to use a “group” in the template to simplify that part. Basically, what these sensors do is: If the state changes on any of the listed entities, evaluate the template, which turns the sensor “on” if any of the devices is “playing”.

- platform: template
  sensors:
    wholehouseaudioamp1_on:
      entity_id:
        - media_player.office_speaker
        - media_player.laundry_room_speaker
        - media_player.peyton_s_room_speaker
        - media_player.jason_s_room_speaker
        - media_player.back_patio_speaker
      value_template: >-
        {{ expand('group.home_amp1') | selectattr('state', 'equalto', 'playing') |list | length > 0 }}

- platform: template
  sensors:
    wholehouseaudioamp2_on:
      entity_id:
        - media_player.family_room_speaker
        - media_player.garage_speaker
        - media_player.gym_speaker
        - media_player.master_bath_speaker
        - media_player.master_bedroom_speaker
      value_template: >-
        {{ expand('group.home_amp2') | selectattr('state', 'equalto', 'playing') |list | length > 0 }}

Then, the Entity Controller config, uses the sensor, to turn on the amplifiers.

wholehouseaudioamp1:
  sensor_type: duration
  delay: 120
  sensor:
    - binary_sensor.wholehouseaudioamp1_on
  entities:
    - switch.ihome_smartplug_e9d2d1

wholehouseaudioamp2:
  sensor_type: duration
  delay: 120
  sensor:
    - binary_sensor.wholehouseaudioamp2_on
  entities:
    - switch.ihome_smartplug_192f8f

It cost me about $50 for the two smart switches, but this configuration is going to save over $100 a year in electricity, not to mention, now my equipment room stays cooler, and the amplifiers are only on when someone is streaming something on the house audio system!

Leave a Reply

Your email address will not be published. Required fields are marked *