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.

Arduino Types and Use Cases

Arduinos come in all shapes and sizes and it can be intimidating to choose between them. This post should clear up some confusions you might have. This is based on my experience and opinion, because I have spent time figuring what works and what doesn’t in different situations.

How to use Logic Level Shifters

How to use Logic Level Shifters

If you need to use an Arduino that outputs 3.3v logic in a circuit that requires 5v logic signals, you can use a component known as a logic level shifter.

4-channel logic level shifter

I am using this component in circuits controlling addressable LED strips. A NodeMCU ESP8266 chip (which outputs 3.3v logic) can then be used to drive 5v logic signals to the LED strip.

This circuit requires:

  1. A logic level shifter to shift 3.3v logic signals to 5v.
  2. A 3.3v and 5v reference voltage to be applied across its pins.
  3. Which in turn requires a DC voltage converter to splice off 3.3v off of whatever your power supply generates. I only found out recently that the NodeMCU (and Arduinos) have a built-in DC voltage converter. It turns out you can connect any voltage 3.3-12V to the chip’s Vin and GND pins, and the built-in converter steps down the voltage to run the chip! This is great because we do not need our own voltage converter. Using a 5v power supply, we can connect the NodeMCU’s Vin to 5v and the NodeMCU creates a 3.3v voltage across its 3.3v pins. Voltage converter built in! Awesome!

How to wire LLS

The shifter has a high voltage and a low voltage side. LV1, LV2, LV3 and LV4 take in low voltage signals that you want to convert. You can input 4 independent signals to be stepped up to 5v. HV1 to HV4 are the corresponding output pins.

LV and GND on the low voltage side require the expected input signal voltage to be applied to it. In our case you would connect the Arduino’s 3.3v and adjacent GND pins to those pins respectively.

HV and GND on the high voltage side require the “high” potential to be applied to it. In our case that is +5v and ground, respectively.

The component then converts all incoming LV signals to the supplied HV voltage.

As we are working with different voltages here it is easy to mix them up and damage your components. Be very careul about connecting your wires correctly the first time.

How to get around not using LLS

Avoid using logic level shifters if possible. They complicate your circuit and add room for error.

It is a good idea to eliminate having to use a logic level shifter if it can be avoided at all. How? Different ways:

  • If you need to control 5V logic, get a controller that runs on 5v and outputs uses 5v logic on its pins. That way you don’t need to work with different voltages and theres no need to convert logic signals.
  • (for LED controller projects): Use of RGB adapters. These adapters take low voltage PWM signal (say 5v) and a target voltage (12V) on one side and automatically step up the signal to the required voltage. They are essentially compact circuits that integrate the DC voltage converter and transistors. This is a lot easier to use than creating a custom circuit. They are made to step up the PWM signal voltage to control common anode LED strips (which run on 12V). This makes for a much neater and simpler circuit than wiring your own MOSFETS.