Defining and executing quick commmands

When creating Docker files, writing blog posts, or working on my home automation server there are a number of repetitve tasks that you find yourself executing. Let’s define them in a script to speed up invocation and allow them to be version controlled!

Don't Break the Chain - Important Tip

I gave the “Don’t break the chain” methodology a try whereby you mark off consecutive days on which you accomplished a certain task with a red permanent marker on your calendar. Here is an important tip to increase the impact of this method and boost motivation.

Creating Project Documentation

As part of my never-ending search for the ultimate blog theme, I stumbled across other static site generators similar to Jekyll (which this blog uses). This new site generator is called MkDocs and it generates absolutely stunning project documentation.

Home Assistant API Tool

The ultimate development tool for the Home Assistant API. Connect to your hub, load in your entities and start exploring the capabilities of Home Assistant’s REST API. Edit entity states, trigger automations, send data and call services.

Custom Binary Sensors

Using the binary sensor component, we can define virtual sensors in our Home Assistant configuration that allow us to track states derived from related input data.

Add the following to your configuration to start using binary sensors.

  - platform: template

Laundry sensor

Let’s say we want to receive notifications when laundry cycles start and end. Since I don’t think its worth investing in smart appliances, I’ve figured out a way to use virtual sensors and Home Assistant instead.

The following sensor uses a power meter attached to my laundry appliances to determine the state of the cycle (whether a load is running or not).

  friendly_name: "Load is running"
  value_template: '{{ states.sensor.laundry_power.state > 5}}'
    minutes: 5

The idea is that if it is washing a load of laundry, the power consumption will likely be more than 5 watt. I’ve added a delay_off such that the sensor does not flip to off when the washer drum is stationary for a few seconds.

Using this virtual sensor in an automation, we can send ourselves a notification:

- alias:             Laundry Notification
    platform:        state
    entity_id:       binary_sensor.load_on
    - service:       notify.pushbullet
        message:     >
          Washing load{% if trigger.to_state.state == 'true' %} started{% else %} finished{% endif %} at {{ now().time() }}.

I usually set up the laundry but use the machines delay start feature to schedule the start time such that the load finishes when im expected to come home from work the next day. The notifications keep me up to date on the program cycle and serve as a reminder.


I actually had a power meter hooked up to the laundry and TV already, so it was just a matter of defining the binary_sensor and automation in Home Assistant.

TV Sensor

Applying a similar configuration, we can create a sensor telling us whether we left the TV on or not.

  friendly_name: "TV is on"
  value_template: "{{ states.sensor.tv_power.state > 20 }}"

I am using this sensor in an automation that turns off all devices at night (in case I forget to turn off a light before going to bed.)

For determining whether someone is watching TV, I can use the media_player.cast component, which is more relable than basing a virtual sensor on TV power consumption. I don’t have cable TV hooked up to my TV as I watch Netflix and YouTube on Chromecast. If you have other inputs, then defining this tv_on sensor is a nifty way for you to check whether the TV is running. You might even be able to distinguish between different states using the power consumption for each state.

Say playing a movie consumes 40 to 40w, but just playing some music consumes 20watts. It’s not perfect, but you might be able to make it work.