[SOLVED] - Dryer cycle complete - automation - 4$ motion sensor SW-420

UPDATE: This is a simple method how to use cheap motion sensor SW-420 and ESP8266 with Tasmota taped to a side of dryer to measure motion ( Dryer is ON ) and to tell when motion ended ( Dryer is OFF ) using cycle in HA to avoid false measurements.

This post is mainly for US where dryer has industrial RV power outlet/plug thus conventional power monitoring using smart plug is not possible

Hello Team

Im trying to create simple automation to announce via Alexa that DRYER is complete. Im using SW-420 motion sensor which is now integrated in HA and works. See in the picture.

The problem I have is that can not create a logical automation to recognize that Drying cycle is complete. The sensor goes ON and OFF very quickly and I can not use single movement event with delay since sensor can register if somebody will accidental trigger the motion e.g. wife putting a basket on top of the dryer.

something like
When Cycle Count = 20 or more
and last OFF was before 5 min
than execute the Voice Notification.

Would you be able to suggest which way to go?

thank you

V.

1 Like

Probably not what you want to hear, but IMHO the easiest way to detect dryer cycles is to use a smart socket with power measurement.

4 Likes

Hey there! I am doing the same thing but with the Xiaomi vibration sensor. This device allows me to read the sensivity of the vibration which helps me figure out the spin cycle.

However, in your case, all you need to do is check that the state has been “off” for a certain amount of time, which is perfectly possible in Home Assistant. I use it on my washing machine sensor.

So, setup an automation, with a trigger like so:

platform: state
entity_id: switch.washing_machine_motion
to: 'off'
for: '0:05:00'

You will need to change the for attribute to be longer than the longest gap between state changes during a cycle.

I hope that makes sense.

1 Like

I have to disagree with hsepm. There is an obvious point where the dryer is finished. See my previous comment for an explination.

Just to expand on my explination comment, I didn’t account for the off activation if someone knocks it.

In that case, I would make an input_number that counts how many times the sensor was activated. Then, add a condition in the automation trigger that checks that that input boolean is greater than 10.

This will stop false positives.

Also remember to reset the input_number to 0 every time your automation triggers after passing the condition.

1 Like

Thank you Darren, it is what I was thinking about at first, But then when somebody would bump into the Dryer which unfortunately could happen when for example my wife puts something on top of it it will trigger ON/OFF falsely this automation.

I have to somehow group ON/OFF cycles and when it reaches e.g. 50 than execute time off.

something like

When Cycle Count = 20 or more
and last OFF was before 5 min
than execute the Voice Notification.

yes it would be easiest way to use smart plug and I`m using it for Washing Machine, but Dryer in US have different 230V socket. so NO GO.

Agree with @hsepm and @vendo232, monitoring power consumption is probably more reliable. I use Hive plugs (UK), but TP Link HS110 plugs provide power monitoring too.

Bear with me…

I set up a sensor to expose the power attribute (which can be graphed);

    dryer_power:
      friendly_name: "Dryer Power"
      value_template: >
        {{state_attr('switch.dryer', 'current_power_w') | int}}
      unit_of_measurement: "W"

…and then a binary sensor off this using the threshold platform - which, crucially, allows hysteresis. (graphing the above sensor helps to establish what values to use);

- platform: threshold
  name: Dryer Running
  entity_id: sensor.dryer_power
  upper: 260
  hysteresis: 250

…and then an automation off the binary sensor…

- id: '1566420576659'
  alias: Dryer Finished
  trigger:
  - entity_id: binary_sensor.dryer_running
    for:
      minutes: 1
    from: 'on'
    platform: state
    to: 'off'
  condition: []
  action:
  - data:
      id: 5
      message: Dryer has finished.
    service: script.notify_both
  - data:
      message: The dryer, has finished.
    service: script.kitchen_announce

I know it’s not exactly what you asked for, but it’s an alternative that may prove easier to achieve.

1 Like

What is your motion sensor connected to? I have the same sensor on an esp8266 and I am using ESPHome to run this. In the yaml file for the esp device you can define delayed on and delayed off. See https://esphome.io/components/binary_sensor/index.html
I set the delayed_on to 5s, meaning the sensor only turns on when it detects motion for 5 seconds. This is long enough to avoid false triggers from someone opening the door.
I set delayed_off to just longer than the longest pause in the dryer cycle. In my case 6 minutes. So the sensor will only switch off when it hasn’t detected motion for a full 6 minutes.
This means the vibration sensor now stays on for the entire cycle instead of rapidly switching between on and off all throughout.
I then get my notification when the sensor goes off (which is 6 minutes after the dryer actually finishes but I can live with that.)

@murtoz this might be it. The delay. I`m using it with D1Mini and Tasmota. Never tried ESPHOME although it is on my bucket list with Node Red.

What did you load to the ESP HOME?

I think you meant to reply to Vendo232’s post, not mine. All I offered was the possibility of using the Counter integration.

Good luck!

so far, trying to incorporate the simple cycle count and run the announcement when 20 counts are reached and OFF state for 5 min is present. Will have to figure out how to Reset the counter once the Dryer Complete automation runs.

  - alias: Counting Dryer
    trigger:
      - platform: state
        entity_id: sensor.dryer
        to: 'on'
    action:
      service: counter.increment
      entity_id: counter.dryer_counter

  - alias: Dryer Complete
    trigger:
      - platform: numeric_state
        entity_id: counter.dryer_counter
        above: 20
    condition:
      condition: state
      entity_id: sensor.dryer
      state: 'OFF'
      for: '00:05:00'
    action:
      - service: notify.alexa_media
        data:
          data:
           type: tts
          target: 
            - media_player.echo_show
          message: " Dryer is complete "

and here it is, not an Programmer`s choice but working solution for simple guy like me.

  - alias: Counting Dryer
    trigger:
      - platform: state
        entity_id: sensor.dryer
        to: 'ON'
    action:
      service: counter.increment
      entity_id: counter.dryer_counter

  - alias: Dryer Complete
    trigger:
      - platform: numeric_state
        entity_id: counter.dryer_counter
        above: 20
    condition:
      condition: state
      entity_id: sensor.dryer
      state: 'OFF'
      for: '00:05:00'
    action:
      - service: notify.alexa_media
        data:
          data:
           type: tts
          target: 
            - media_player.echo_show
          message: " Dryer is complete "

  - alias: Counting Reset
    trigger:
      - platform: state
        entity_id: sensor.dryer
        to: 'OFF'
        for: '00:06:00'
    action:
      service: counter.reset
      entity_id: counter.dryer_counter

The “Dryer Complete” automation may not work the way you expect.

It triggers when dryer_counter exceeds 20. This trigger will occur when the count changes from 20 to 21 It will not trigger when it changes from 21 to 22, or 22 to 23, etc (it triggers when the threshold value is crossed). So when the count is 21, it will check if dryer has been off for at least 5 minutes. If it has not the automation’s action is not executed … and the automation will not be triggered again (because the count has to drop below 20 and then rise above 20 to trigger the automation again).

you are correct , this part of automation is not working yet :frowning:
I will try to swap condition and trigger.

this is the working Solution ! thank you all for your inputs. The sensor + D1mini was ~4$

  - alias: Counting Dryer
    trigger:
      - platform: state
        entity_id: sensor.dryer
        to: 'ON'
    action:
      service: counter.increment
      entity_id: counter.dryer_counter

  - alias: Dryer Complete
    trigger:
      - platform: state
        entity_id: sensor.dryer
        to: 'OFF'
        for: '00:03:00'
    condition:
      - condition: numeric_state
        entity_id: counter.dryer_counter
        above: 20
    action:
      - service: notify.alexa_media
        data:
          data:
           type: tts
          target: 
            - media_player.echo_show
          message: " Dryer is complete "

  - alias: Counting Reset
    trigger:
      - platform: state
        entity_id: sensor.dryer
        to: 'OFF'
        for: '00:05:00'
    action:
      service: counter.reset
      entity_id: counter.dryer_counter

Why not use the “Dryer Complete” automation to reset the counter? What’s the need to wait another 2 minutes before resetting it?

When “Dryer Complete” executes its action, the counter has served its purpose so you may as well reset it there as opposed to using a separate automation.

  - alias: Counting Dryer
    trigger:
      platform: state
      entity_id: sensor.dryer
      to: 'ON'
    action:
      service: counter.increment
      entity_id: counter.dryer_counter

  - alias: Dryer Complete
    trigger:
      platform: state
      entity_id: sensor.dryer
      to: 'OFF'
      for: '00:03:00'
    condition:
      condition: template
      value_template: "{{states('counter.dryer_counter')|int > 20}}"
    action:
      - service: counter.reset
        entity_id: counter.dryer_counter
      - service: notify.alexa_media
        data:
          data:
            type: tts
          target: 
            - media_player.echo_show
          message: " Dryer is complete "
2 Likes

of course! makes perfect sense.

I`m afraid I could reduce tons of lines in my code if we work together more often :slight_smile:

cheers

1 Like

I have tried both: Xiaomi vibration sensor and power measurement and found power management far superior in terms of reliability.

You could even use the temporary additional power usage of crease protection (or anti-creasing, if your dryer has that feature) for a repeating reminder.