Washing Machine / Wasmachine status button

I created a set of buttons that reveal the status of my 2 washing machines (wasmachines in dutch), so that I don’t forget to take out the wet laundry too late.

Scherm­afbeelding 2024-03-15 om 11.55.01

The machines themself are not smart, therefor I use two smart switches from Tuya:

that reveal the power consumption.

I make use of the folowing helpers:

input_boolean.wasmachine_1_aan (Schakelaar)

This one I created in the UI under ‘helpers’ in the 'Devices & Servcis" menu

sensor.wasmachine_1_state (Sensor)
I added this sensor in my sensors.yaml:

- platform: template
  sensors:
    wasmachine_1_state:
      value_template: >-
        {% set power = states('sensor.zolder_wasmachine_stekker_1_power') | int %}
        {% set power_history = states('input_number.wasmachine_1_power_history') | int %}
        {% if power < 2 %}
          is klaar!
        {% elif 3 <= power < 299 %}
          wast
        {% elif 300 <= power < 1000 %}
          centrifugeert
        {% elif 1000 <= power < 3500 %}
          wast en verwarmt
        {% else %}
          unknown
        {% endif %}

Depending on the wattage it returns a state string, in my case in Dutch.

I created an automation that tests wether the power is above 2 watt for more than 5 seconds, and then triggers a input_boolean to ‘on’, so that my conditional card is revealed for this machine in my Dashboard that I share further on:

Washing Machine 1 on Detection automation:

alias: "Washing Machine 1 On Detection "
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.zolder_wasmachine_stekker_1_power
    above: 2
    for:
      hours: 0
      minutes: 0
      seconds: 5
action:
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.wasmachine_1_aan

You need to create more equivalent helpers for additional washing machines.
I have 2, so I have these helpers and automation for wasmachine_2 as well.

And this is my code for the cards that I use for this buttons:

Dashboard card

type: horizontal-stack
cards:
  - type: conditional
    conditions:
      - condition: state
        entity: input_boolean.wasmachine_1_aan
        state: 'on'
    card:
      type: custom:button-card
      entity: sensor.wasmachine_1_state
      name: AEG Wasmachine
      show_name: true
      icon: mdi:washing-machine-alert
      show_state: true
      tap_action:
        action: call-service
        service: input_boolean.turn_off
        service_data:
          entity_id: input_boolean.wasmachine_1_aan
      styles:
        grid:
          - grid-template-areas: '"n n n" "i s s" "start_time start_time start_time"'
          - grid-template-columns: 1fr 1fr 1fr
          - grid-template-rows: 1fr 1fr 1fr
        icon:
          - color: white
          - align-self: start
        card:
          - height: 120px
          - background: '#B31942'
          - font-size: 15px
          - overflow: unset
          - padding-left: 10%
          - padding-right: 5%
          - padding-top: 1%
          - padding-bottom: 1%
        img_cell:
          - justify-content: start
          - align-self: start
        label:
          - align-self: center
          - justify-self: start
        name:
          - align-self: center
          - justify-self: start
        state:
          - padding-right: 0%
          - align-self: start
          - font-weight: bold
          - font-size: 28px
        start_time: null
      custom_fields:
        start_time: |
          [[[
            const timestamp = new Date(states['input_boolean.wasmachine_2_aan'].last_changed);
            const hours = timestamp.getHours().toString().padStart(2, '0');
            const minutes = timestamp.getMinutes().toString().padStart(2, '0');
            return `Gestart om: ${hours}:${minutes}`;
          ]]]
  - type: conditional
    conditions:
      - condition: state
        entity: input_boolean.wasmachine_2_aan
        state: 'on'
    card:
      type: custom:button-card
      entity: sensor.wasmachine_2_state
      name: INDESIT Wasmachine
      show_name: true
      icon: mdi:washing-machine-alert
      show_state: true
      tap_action:
        action: call-service
        service: input_boolean.turn_off
        service_data:
          entity_id: input_boolean.wasmachine_2_aan
      styles:
        grid:
          - grid-template-areas: '"n n n" "i s s" "start_time start_time start_time"'
          - grid-template-columns: 1fr 1fr 1fr
          - grid-template-rows: 1fr 1fr 1fr
        icon:
          - color: white
          - align-self: start
        card:
          - height: 120px
          - background: '#1866E1'
          - font-size: 15px
          - overflow: unset
          - padding-left: 10%
          - padding-right: 5%
          - padding-top: 1%
          - padding-bottom: 1%
        img_cell:
          - justify-content: start
          - align-self: start
        label:
          - align-self: center
          - justify-self: start
        name:
          - align-self: center
          - justify-self: start
        state:
          - padding-right: 0%
          - align-self: start
          - font-weight: bold
          - font-size: 28px
        start_time: null
      custom_fields:
        start_time: |
          [[[
            const timestamp = new Date(states['input_boolean.wasmachine_1_aan'].last_changed);
            const hours = timestamp.getHours().toString().padStart(2, '0');
            const minutes = timestamp.getMinutes().toString().padStart(2, '0');
            return `Gestart om: ${hours}:${minutes}`;
          ]]]

I hope I help any out there with my solution and code to inspire and solve their problem. Feel free to comment, suggest changes or ask questions!

1 Like

I tried that too, but power graph is so fluctuating, that I really cant make a nice profile for state


this is one full cycle

You might try to take an average over the last -let’s say 1 minute- at least you can distinguish wether the machine is on or not. What phase might be less accurate, but the high power peaks is warming aka washing. And the less high at the end is centrifugal activity.

average might be a good item… currently i need to wait for a minute below 10 watts to know it’s done…
Was thinking maybe i can do profiles, but different whashing programs are behaving differntly in power usage.
image
see how low it can get just in the middle of the program. Will try with averages, or maybe even PID approach when i have some time.

1 Like