Smartifying a washing machine

2026-02-15

This article extends the basics covered in Smartifying your devices to a device with a more complicated state: A washing machine. By using both a smart power plug and a contact sensor, we can track the activity of the machine, and the state of the door. For example, this helps us identify when a washing machine cycle has finished, but the load has not yet been emptied.

We'll build up the washing machine's state machine incrementally, based on specific triggers that we get from the smart devices.

In this article, we'll skip the imperative approach and go straight to the state machine examples. Continue scrolling to see the Node Red implementation.

Keep reading if...

  • You have access to advanced Smart Home tooling, like Home Assistant.
  • You're familiar with state machines, and modeling device state in Node Red
  • You keep forgetting to take the washing out when it's finished

Sensors and triggers

We will use a contact sensor and a smart power plug. Instead of imperatively mapping the smart home sensor events directly to actions, we will treat them as "triggers" to influence the device state.

In addition, we'll also take advantage of the device state itself to provide additional information - state duration helps us identify if a cycle has finished, and trigger reminders if a cycle has finished, but if the door has not been opened for a while since then.

We'll start with the contact sensor.

Contact sensor: Is the door open?

The door sensor let us estimate when a load is added or removed. We won't know if the washing machine is empty or full, but we can cross-reference this with other sensors soon.

Contact sensors give us isOpen and isClosed triggers.
 
We can use these triggers to start modeling the door state.

Smart power plug: Is it washing?

While it may be possible to identify specific cycle information by monitoring the power usage, we only need to identify when the washing machine is running a cycle, or when it isn't.

Categorising power usage gives us powerHigh, powerLow and powerOff triggers.
 
We assume that the door can't be open while the washing machine is washing.

While it's possible to model the "Power off & door open" and "Power off & door closed" as separate states, the added complexity does not benefit us because the transitions are the same. Ideally we would model them as a substates in a hierarchical finite state machine, so the information is still available in the model without additional overhead.

Timing transitions: Did the cycle finish?

We're still missing something critical from these triggers; the ability to identify when the washing machine has finished a cycle. Cross-referencing the powerLow trigger with the washing state duration, we can decide which next transition is most appropriate:

 
  • If powerLow triggers soon after starting a cycle (e.g. pausing it to add more clothes), consider the cycle cancelled.
  • If powerLow triggers after the cycle has been running for 30 mins or more, consider the cycle finished.

This expands our model further, to represent "finished" as new state, distinct from "ready".

 

"Finished" represents a washing machine that has finished a cycle, and is full of clean clothes. We assume the clothes are removed when the door is opened.

modeling the state machine

Because we're using a simple state machine instead of a hierarchical state machine, the states and transitions look a little more complicated than we saw in the diagrams above.

Since this state machine is just a rough model of a physical process using simple sensors, there are cases where transitions may be missed. We can add safe defaults for some triggers, allowing transitions without regard for the "from" state.

Trigger From To Comment
doorOpened readyOff doorOpenedOff Door opened while the washing machine is turned off.
(any) doorOpenedOn Door opened while the washing machine is in any other state.
doorClosed doorOpenedOff readyOff Door closed while the washing machine is turned off.
(any) readyOn Door closed while the washing machine is in any other state.
powerHigh (any) washing The washing machine is running a cycle. Implies that it's on and the door is closed.
powerLowLongTime washing finished The only way to transition to "finished", low power after washing for > 30 mins.
powerLowShortTime washing ready Low power after washing for < 30 mins.
powerOff doorOpenOn doorOpenOff Substate for doorOpen, when the power is turned off.
finishedOn finishedOff Substate for finished, when the power is turned off.
(any) readyOff Safe default for other states when the power is turned off.
powerOn doorOpenOff doorOpenOn Substate for doorOpen, when the power is turned on.
finishedOff finishedOn Substate for finished, when the power is turned on.
(any) readyOn Safe default for other states when the power is turned on.

Putting it all into Node Red

As with Smartifying your devices, we're representing the device state using the node-red-contrib-home-assistant-websocket and node-red-contrib-persistent-fsm, nodes, which do not render properly in this preview.

Reminders

Further taking advantage of the state duration, we can add additional state nodes that fire when the washing machine has been in the finished state for a certain duration. The "announcement" node delegates to a TTS to verbalise messages and play them as announcements.

Which reminds me to stop what I'm doing and put the washing out:

  1. 🤖 Smart Home agent
  2. ...🙄

Wrapping up

Smartifying a washing machine with multiple sensors led to a more complicated state machine than the example in Smartifying your devices, but it's good to prove that the process can scale. I'll be keeping an eye out for other Smart Home sensors and actuators at IKEA that can further smartify my devices.


If you have feedback or questions about this article, let's catch up via email.