My own Home Assistant State Machine for Dryer and Washing Machine (now retired)

Posted by ads on Wednesday, 2026-10-14
Posted in [Home-Assistant]

When I first installed Home Assistant, I wasn’t aware of the Home Assistant Community Store (HACS) with custom-made integrations. And because the first thing I automated at home was a notification for the Washing Machine and the Dryer, this is also the first thing I ported over when migrating from openHAB to Home Assistant.

In openHAB, I already had a state machine implemented. Over time, I decided to move away from openHAB, and looked at Home Assistant.

This blog posting documents the state machine before replacing it with Appliance Tracker for Home Assistant.

Current State

I have two power plugs, which measure power consumption for the washing machine and the dryer. Both are DECT devices, connected to the Fritz!Box. That works, and I haven’t found a reason to replace the two devices - even though all later power plugs are Zigbee devices.

Fritz!SmartEnergy DECT Power Plug in Home Assistant
Fritz!SmartEnergy DECT Power Plug in Home Assistant

State Machine for the Washing Machine

Both washing machine and dryer have their own state machine.

 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
alias: State Machine Washing Machine
description: >-
  Updates the state of the washing machine (Off, Standby, Active, Finished)
  based on the power consumption from sensor.fritz_smart_energy_210_1_power.
triggers:
  - entity_id: sensor.fritz_smart_energy_210_1_power
    above: '0.0'
    id: standby
    trigger: numeric_state
  - entity_id: sensor.fritz_smart_energy_210_1_power
    below: '0.1'
    id: 'off'
    trigger: numeric_state
  - entity_id: sensor.fritz_smart_energy_210_1_power
    above: '8.0'
    id: active
    trigger: numeric_state
  - entity_id: sensor.fritz_smart_energy_210_1_power
    below: '8.0'
    id: finished
    trigger: numeric_state
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: standby
          - condition: state
            entity_id: input_select.washing_machine_state
            state: 'Off'
        sequence:
          - target:
              entity_id: input_select.washing_machine_state
            data:
              option: Standby
            action: input_select.select_option
      - conditions:
          - condition: trigger
            id: active
        sequence:
          - target:
              entity_id: input_select.washing_machine_state
            data:
              option: Active
            action: input_select.select_option
      - conditions:
          - condition: trigger
            id: finished
          - condition: state
            entity_id: input_select.washing_machine_state
            state: Active
        sequence:
          - target:
              entity_id: input_select.washing_machine_state
            data:
              option: Finished
            action: input_select.select_option
      - conditions:
          - condition: trigger
            id: 'off'
        sequence:
          - target:
              entity_id: input_select.washing_machine_state
            data:
              option: 'Off'
            action: input_select.select_option
mode: single

The sensor.fritz_smart_energy_210_1_power entity is the power socket, through the Fritz!Box integration.

Each device also has an input_select as state storage, here the name is input_select.washing_machine_state. It can have four different values:

  • Off
  • Standby
  • Active
  • Finished

Screenshot of the input_select with the four possible states
Screenshot of the input_select with the four possible states

Automations

The automations then trigger on a change in input_select.washing_machine_state, respective input_select.dryer_state.

State Machine for the Dryer

At some point we got a new dryer. It has a more “sophisticated” anti-wrinkle cycle. Which, in practice just means that the dryer will turn on more often after the main program finished. Which then caused more problems, because it more often looks like another drying run is going on. Here is the YAML for the 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
alias: State Machine Dryer
description: >-
  Updates the state of the dryer (Off, Standby, Active, Finished) based on the
  power consumption from sensor.fritz_smart_energy_210_2_power. Handles
  anti-crease cycles by requiring power to be high for a sustained period before
  restarting a cycle.
triggers:
  - entity_id: sensor.fritz_smart_energy_210_2_power
    trigger: state
actions:
  - variables:
      power: '{{ trigger.to_state.state | float(0) }}'
      current_state: '{{ states(''input_select.dryer_state'') }}'
  - choose:
      - conditions:
          - condition: template
            value_template: '{{ power < 0.2 }}'
        sequence:
          - target:
              entity_id: input_select.dryer_state
            data:
              option: 'Off'
            action: input_select.select_option
      - conditions:
          - condition: state
            entity_id: input_select.dryer_state
            state: 'Off'
        sequence:
          - choose:
              - conditions:
                  - condition: template
                    value_template: '{{ power >= 5.0 }}'
                sequence:
                  - target:
                      entity_id: input_select.dryer_state
                    data:
                      option: Active
                    action: input_select.select_option
              - conditions:
                  - condition: template
                    value_template: '{{ power >= 0.2 }}'
                sequence:
                  - target:
                      entity_id: input_select.dryer_state
                    data:
                      option: Standby
                    action: input_select.select_option
      - conditions:
          - condition: state
            entity_id: input_select.dryer_state
            state: Standby
          - condition: template
            value_template: '{{ power >= 5.0 }}'
        sequence:
          - target:
              entity_id: input_select.dryer_state
            data:
              option: Active
            action: input_select.select_option
      - conditions:
          - condition: state
            entity_id: input_select.dryer_state
            state: Active
          - condition: template
            value_template: '{{ power < 5.0 }}'
        sequence:
          - target:
              entity_id: input_select.dryer_state
            data:
              option: Finished
            action: input_select.select_option
      - conditions:
          - condition: state
            entity_id: input_select.dryer_state
            state: Finish
          - condition: template
            value_template: '{{ power > 150.0 }}'
        sequence:
          - target:
              entity_id: input_select.dryer_state
            data:
              option: Active
            action: input_select.select_option
mode: restart

It already has a few more conditions, compared to the washing machine automation. That was also the point when I decided to replace this automation with a HACS integration.


Categories: [Home-Assistant]

Comments

With an account on the Fediverse or Mastodon, you can respond to this post. Known replies are displayed below:



Note: This will load data from mastodon.social.

Learn how this is implemented here.


Share: