Building a Smart Home - Part 3 "Smart" Appliances

Thursday, Aug 18, 2022 7 minute read Tags: smart-home

After exploring a bit of the thought process on the how and why with my journey to a smart home, it’s time to look at a what, and for that I’m going to tackle one of the problems I identified in the last post:

Forgetting the washing machine was done to hang the laundry out

To give a bit of context, my home office is upstairs while the laundry is downstairs, and what this means is that I generally don’t hear when the appliances finish their cycle, and if I don’t realise until half way through the day, then it’s likely that our washing isn’t getting dry unless it goes in the dryer (and because we don’t have solar in yet, I try to reduce the amount of time we use that as it’s expensive!). Queue sad Aaron.

While yes, there’s a whole heap of wifi-enabled appliances, we got new ones with the new house and they are not wifi-enabled, so going out and buying a whole new set is not something that’s in the budget.

So, how do we tackle this?

Is this thing on

How do we know if an appliance is running? The simplest way to do that is looking at whether it’s using power or not and apply some basic logic of if using power - state:running, if not using power and last state:running - state:finished.

This means we’re going to need to figure out whether the appliance is drawing power and to do that we’ll get some smart switches to do power monitoring. There’s a heap of switches on the market, across all protocols from wifi to ZigBee, but since I’m not ready to dive into the world of ZigBee or Z-Wave yet, I went with the TP-Link Kasa KP115 because they were easy to get (I got them from Bunnings, but it seems Bunnings no longer stocks them), they have a very small profile, and they connect to Home Assistant using the TPLink Kasa integration.

I grabbed myself three of them (washing machine, dryer and dishwasher), and set them up in the Kasa app.

Plugs in Kasa

I did setup a Kasa Cloud account for this but I’ve since learnt that they do support local control, so you might not need to do that, but I haven’t had time (or the motivation) to go back and reconfigure the setup.

With the devices on the network it was only a matter of time until Home Assistant picked them up and then they were available as entities for me:

Plugs available in Home Assistant

Great, time to see what it can do.

Looking at the data

When the device was added to Home Assistant it gave me several new sensors. This is the view of my washing machine (which ran a cycle earlier today):

Sensors available

From an automation standpoint, the Current Consumption is going to be most relevant, as that’s reporting the Watts that is being drawn through the plug. We can get a good view of this over time:

Graph of current consumption over today’s cycle

I reckon we can work with this. So, armed with our insights, let’s make an automation.

Automation - take 1

The first automation I created was very simplistic:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
alias: Is washing done
description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - sensor.washing_machine_current_consumption
    to: "0"
condition: []
action:
  - service: notify.mobile_app_aaron_s_phone
    data:
      message: Washing done

This automation will run when the washing machine stops drawing power and that seems right doesn’t it? If it’s not drawing power, it’s done, isn’t it?

Well, the blow up on my phones notifications would suggest otherwise… turns out that this automation works, but doesn’t work quite right. Let’s go back to the graph from before.

Graph of current consumption over today’s cycle

Do you see the problem?

The problem is I’m making a false assumption that the power draw is consistent, when in reality, power goes up and down, depending on the phase of the wash cycle, and as a result, we hit the zero power draw trigger with a lot of false positives.

Automation - take 2

So it turns out that what I really should be doing is using the for parameter of the trigger and have it say if the power is zero for <some duration> - finished. Because I’m sure this is a solved problem, I decided to search the Home Assistant forms and came across this blueprint, which you can install here:

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

If you’ve not used a blueprint, it’s a pre-configured automation in which you just plug in the relevant values, and this one is designed around appliance finished scenarios. Once the blueprint is imported, you can use it as the base for a new automation:

Blueprint starting point

The other thing I like about this blueprint is that it has both start and stop actions that can be configured, so when the appliance crosses the threshold to be considered as started you can do something and then when it’s completed do something else.

Blueprint starting point

Here’s what the automation now looks like, and if we hit save, it’s good to go (and my phone won’t get spammed!).

Bonus points - tracking state

Mainly for fun, but also because I think it might be useful in the future, I decided to expand the actions of the automation to give more rich information about the appliance, specifically, track when the appliance last started, and what its current state is.

This will mean I can make my dashboard look like this:

Blueprint starting point

For this, I created two inputs, date time and text. Next, in the on start phase of the blueprint, I set the values of those to their relative states, and then when it’s finished, I change the text input from Running to Finished.

Here’s the complete automation:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
alias: "Appliance finished: Washing"
description: ""
use_blueprint:
  path: >-
        sbyx/notify-or-do-something-when-an-appliance-like-a-dishwasher-or-washing-machine-finishes.yaml
  input:
    power_sensor: sensor.washing_machine_current_consumption
    actions:
      - service: notify.mobile_app_aaron_s_phone
        data:
          message: Washing finished!
          title: ๐Ÿงบ Laundry
      - service: input_text.set_value
        data:
          value: Finished
        target:
          entity_id: input_text.washing_machine_enriched_status
      - if:
          - condition: time
            before: "19:00:00"
            after: "07:00:00"
            weekday:
              - mon
              - tue
              - wed
              - thu
              - fri
        then:
          - service: tts.google_translate_say
            data:
              entity_id: media_player.whole_house
              message: Washing finished
        else: []
    pre_actions:
      - service: input_text.set_value
        data:
          value: Running
        target:
          entity_id: input_text.washing_machine_enriched_status
      - service: input_datetime.set_datetime
        data:
          datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
        target:
          entity_id: input_datetime.washing_machine_last_started

Setting the last_started requires a value to be set using a template, which you can only do in YAML, but it just grabs now() and formats it for storage.

Also, for fun, I have it announce on all our Google Homes when the washing finishes using the Text To Speech (TTS) service, but that’s wrapped in a condition that only allows it Monday - Friday between 7am and 7pm, so not to wake anyone. Ask me how I knew to add that ๐Ÿ˜…!

Summary

Here we’ve seen how I turned a dumb appliance into a smart one, and done a small quality of life improvement.

By using power monitoring and a simple automation, we can determine when an appliance is running, and by tracking that, work out when it’s finished to give you the feedback needed.

I’ve actually had this automation running for a few months now (I originally set it up at our rental), and it’s by far the most relied upon one that I have.

Sure, there has been a few hiccups - the Kasa plugs occasionally lose connection to Home Assistant (sometimes they go into ’local only’ mode but I’m not sure what triggers that), but since I put them on fixed IP’s they’ve been better.

I’ve got some ideas on how to improve the notifications more, like if I’m out, don’t send the notification until I’m home, but that’s well down the priority list. For now, this is doing the job nicely.