Tweaking the dryer state machine

Below I have a helper object that tells me the status of my dryer based on current draw. I found today it has a problem. At the end of a cycle, if the dryers wrinkle guard function is enabled, it will kick back on a toss the laundry around for 16 or 17 seconds every several minutes until either the drum cools down or the laundry is removed. so my template thinks the dryer is having mini cycles and I am constantly being notified the dryer is done.

I think it’s cleanest to fix this in the template rather than the notification, so I need to tell it it’s not considered drying unless it has been doing it for at least 18 seconds. I should probably also tell it the doors not open unless its been that way for at least 2 seconds since the history does show the trailing end of wrinkle guard may be confusing it too but one thing at a time.

I’m not sure I can create that condition cleanly in a single object. Ideas?

template:
  - sensor:
      - name: "Dryer status"
        unique_id: dryer_status
        state: >
            {% set currentSnapshot = states('sensor.basement_dryer_plug_effective_current') | float(0) %}
            {% if currentSnapshot > 1 %}
                drying
            {% elif currentSnapshot > 0.08 %}
                door opened
            {% else %}
                off
            {% endif %}
        icon: >
            {% set currentSnapshot = states('sensor.basement_dryer_plug_effective_current') | float(0) %}
            {% if currentSnapshot > 1 %}
                mdi:tumble-dryer
            {% elif currentSnapshot > 0.08 %}
                mdi:tumble-dryer-alert
            {% else %}
                mdi:tumble-dryer-off
            {% endif %}

You could use triggers to time the state changes:

template:
  - triggers:
      - id: drying
        trigger: numeric_state
        entity_id: sensor.basement_dryer_plug_effective_current
        above: 1
        for: 18
      - id: door_open
        trigger: numeric_state
        entity_id: sensor.basement_dryer_plug_effective_current
        above: 0.08
        below: 1
      - id: dryer_off
        trigger: numeric_state
        entity_id: sensor.basement_dryer_plug_effective_current
        below: 0.08
    sensor:
      - name: "Dryer status"
        unique_id: dryer_status
        state: >
            {% if trigger.id == "drying" %}
                drying
            {% elif trigger.id == "door_open" %}
                door opened
            {% else %}
                off
            {% endif %}
        icon: >
            {% if trigger.id == "drying" %}
                mdi:tumble-dryer
            {% elif trigger.id == "door_open" %}
                mdi:tumble-dryer-alert
            {% else %}
                mdi:tumble-dryer-off
            {% endif %}

Thanks, I’m going to try this.

You may want to take a look at the WashData custom integration.

what the…this is the coolest thing ever! if this actually works this is amazing!