Smart plug state on devices with soft button

What are the best practices in HA for displaying the state of my Shelly Plug S smart plug?.
I use a smart plug on my washing machine that has a soft button so the power state in HA is always powered on.
Are there other options to visualize when the washing machine is on/of by example monitoring the power consumption?
Thx in advance for some advice.

Sorry, I don’t fully understand you. How have you integrated your Shelly Plug S?
I am also using the Shelly Plug S on my washing machine and tumble dryer using the Home Assistant official integration and as the Shelly 1 PM it shows it’s relay state correctly within home assistant. I can toggle the relay using the Home Assistant interface, the Shelly app, or the button on the Shelly Plug S itself. The state is always reflected correctly.

I use also the official Shelly integration in HA and this works fine. In my case the smart plug need always to be powered on, So the switch state of the smart plug is always on.in the frontend of HA and the Shelly app. When I use the washing machine I need to push on the soft button of the machine to start.
So my question is about the visulization of the state of the washing machine in the frontend of HA.

Then you would need to monitor the power consumption. Do you see a significant change in power consumption between off and on?

If the machine is running you will definitely see a large power increase.

Ah, I understand. Inspired by W3MA I created an input_select with the states of the laundry cycle (Off, Idle, Running, Done), which is set by automations. This input_select is then read by a templated sensor, that shows the current state in Lovelace.

The automations need to be tweaked according to your expierience. For example I noticed, that my tumble dryer remains powered, with little power consumption, after it is done. The washing machine however completly shuts off, so there was not indication if it was in the state ‘Done’, or has already been emptied and is again in ‘Idle’ state. Due to this reason, I added a Xiaomi Aqara Door Sensor on the waching machines door, so I know if it has been emptied, or not and also the power usage thresholds may vary.

Sensor
- platform: template
  sensors:
    washer_status:
      friendly_name: "Waschmaschine"
      icon_template: >-
        {% if is_state("sensor.washer_status", "Running") %}
          mdi:washing-machine
        {% else %}
          mdi:washing-machine-off
        {% endif %}
      value_template: '{{ states.input_select.washer_status_dropdown.state }}'
      attribute_templates:
        Counter: >-
          {{ states('counter.washing_cycles') }}
        Power: >-
          {{ states('sensor.washer_power') }}
        Energy: >-
          {{ states('sensor.washer_energy') }}
        Last Changed: >-
          {{ relative_time(states.sensor.washer_status.last_changed) }}
    dryer_status:
      friendly_name: "Trockner"
      icon_template: >-
        {% if is_state("sensor.dryer_status", "Running") %}
          mdi:tumble-dryer
        {% else %}
          mdi:tumble-dryer-off
        {% endif %}
      value_template: '{{ states.input_select.dryer_status_dropdown.state }}'
      attribute_templates:
        Counter: >-
          {{ states('counter.dryer_cycles') }}
        Power: >-
          {{ states('sensor.dryer_power') }}
        Energy: >-
          {{ states('sensor.dryer_energy') }}
        Last Changed: >-
          {{ relative_time(states.sensor.dryer_status.last_changed) }}
Automations
  ##########################################################
  ## Washing machine / tumble dryer powered off
  ##########################################################
- alias: Laundry - powered off
  id: 'laundry_powered_off'
  trigger:
      #When power plug is turned off
    - platform: state
      entity_id:
        - switch.washer
        - switch.dryer
      to: 'off'
  mode: parallel

  action:
    - service: input_select.select_option
      data_template:
        entity_id: >
          {% if trigger.entity_id == 'switch.washer' %}
            input_select.washer_status_dropdown
          {% else %}
            input_select.dryer_status_dropdown
          {% endif %}
        option: 'Off'
  
  ##########################################################
  ## Washing machine / tumble dryer idle
  ##########################################################
- alias: Laundry - Idle
  id: 'laundry_idle'
  trigger:
      #Initial state, when power plugs are turned on
    - platform: state
      entity_id:
        - switch.washer
        - switch.dryer
      to: 'on'
      #Return to idle, when washing machine is emptied
    - platform: state
      entity_id: binary_sensor.washing_machine_door
      to: 'on' #'Open'
      #Tumble dryer is manually set to 'Off', when emptied. 
      #When turned off, power consumption drops to 0W.
    - platform: template
      value_template: "{% if states.sensor.dryer_power.state | float == 0.0 %} true {% endif %}"
  mode: parallel
  
  condition:
    - >
      {{( trigger.to_state.entity_id == 'switch.washer' ) 
        or 
        ( trigger.to_state.entity_id == 'switch.dryer' )
        or
        ( trigger.to_state.entity_id == 'binary_sensor.washing_machine_door' and
          states('input_select.washer_status_dropdown') == 'Done' )
        or 
        ( trigger.to_state.entity_id == 'sensor.dryer_power' and
          states('input_select.dryer_status_dropdown') == 'Done' )}}

  action:
    - service: input_select.select_option
      data_template:
        entity_id: >
          {% if trigger.entity_id in ['switch.washer', 'binary_sensor.washing_machine_door'] %}
            input_select.washer_status_dropdown
          {% else %}
            input_select.dryer_status_dropdown
          {% endif %}
        option: 'Idle'
        
  ##########################################################
  ## Laundry process started
  ##########################################################
- alias: Laundry - process started
  id: 'laundry_process_started'
  trigger:
      #Power consumption threshold to sense washing machine is running 
    - platform: template
      value_template: "{% if states.sensor.washer_power.state | float > 5.0 %} true {% endif %}"
      #Power consumption threshold to sense tumble dryer is running
    - platform: template
      value_template: "{% if states.sensor.dryer_power.state | float > 5.0 %} true {% endif %}"
  mode: parallel
  
  condition:
    - >
      {{( trigger.to_state.entity_id == 'sensor.washer_power' and
          states('input_select.washer_status_dropdown') == 'Idle' )
        or 
        ( trigger.to_state.entity_id == 'sensor.dryer_power' and
          states('input_select.dryer_status_dropdown') == 'Idle' )}}

  action:
    - service: input_select.select_option
      data_template:
        entity_id: >
          {% if trigger.entity_id == 'sensor.washer_power' %}
            input_select.washer_status_dropdown
          {% else %}
            input_select.dryer_status_dropdown
          {% endif %}
        option: 'Running'

  ##########################################################
  ## Laundry process finished
  ##########################################################
- alias: Laundry - process finished
  id: 'laundry_process_finished'
  trigger:
      #Power consumption threshold to sense washing machine is done
    - platform: template
      value_template: "{% if states.sensor.washer_power.state | float <= 4.0 %} true {% endif %}"
      #Power consumption threshold to sense washing machine is done
    - platform: template
      value_template: "{% if states.sensor.dryer_power.state | float <= 5.0 %} true {% endif %}"
  mode: parallel
  
  condition:
    - >
      {{( trigger.to_state.entity_id == 'sensor.washer_power' and
          states('input_select.washer_status_dropdown') == 'Running' )
        or 
        ( trigger.to_state.entity_id == 'sensor.dryer_power' and
          states('input_select.dryer_status_dropdown') == 'Running' )}}

  action:
    - service: input_select.select_option
      data_template:
        entity_id: >
          {% if trigger.entity_id == 'sensor.washer_power' %}
            input_select.washer_status_dropdown
          {% else %}
            input_select.dryer_status_dropdown
          {% endif %}
        option: 'Done'
    - service: counter.increment
      data_template:
        entity_id: >
          {% if trigger.entity_id == 'sensor.washer_power' %}
            counter.washing_cycles
          {% else %}
            counter.drying_cycles
          {% endif %}
2 Likes

Thx a lot for this explanation! I will try this.

A bit late of course, but for the benefit of others - how about this: How To Monitor Your Washing Machine in Home Assistant - YouTube