Dyson Vacuum Charger – Auto On/Off

Dyson Vacuum Charger – Auto On/Off

This automation automatically turns off a smart plug if the power consumption drops below 3 W, and turns it back on after a set time interval, with checks happening every minute.
I created this automation to prevent the vacuum’s battery from being damaged by staying on the charger in the dock indefinitely.


How It Works

  1. Every minute, the automation checks conditions.
  2. If the plug is ON and the current consumption < 3 W:
    • The plug is turned OFF.
    • The current time is stored in input_datetime.dyson_charger_off_time.
    • A notification is created to confirm it turned off.
  3. If the plug is OFF and a certain amount of time has passed since it was last turned off, the plug is turned ON again, and a notification is created to confirm it turned on.

By default, the code below uses 9 days (777,600 seconds) as the interval. To truly make it 4 hours, replace 777600 with 14400 (4 × 3600).


Required Helper

Create an [Input Datetime][1] helper to store the timestamp of when the plug was last turned off:

  1. Go to SettingsDevices & ServicesHelpersCreate Helper.
  2. Choose Date and/or time.
  3. Name it (for example) “Dyson Charger Off Time”.
  4. Select Store time (or Store date/time, either works).
  5. Make sure it has the Entity ID: input_datetime.dyson_charger_off_time.

Automation YAML

alias: Dyson Vacuum Charger - Auto On/Off
description: >
  Automatically turns off the smart plug if the power consumption is < 3 W,
  and turns it back on after a specific delay. Runs every minute.
trigger:
  - platform: time_pattern
    minutes: "/1"  # Check every minute
action:
  - choose:
      # 1) If plug is ON and consumption < 3W -> Turn OFF
      - conditions:
          - condition: state
            entity_id: switch.smart_plug
            state: "on"
          - condition: template
            value_template: >-
              {{ states('sensor.smart_plug_current_consumption') | float(999) < 3 }}
        sequence:
          - service: switch.turn_off
            target:
              entity_id: switch.smart_plug
          - service: input_datetime.set_datetime
            target:
              entity_id: input_datetime.dyson_charger_off_time
            data:
              timestamp: "{{ now().timestamp() }}"
          - service: persistent_notification.create
            data:
              title: Dyson Vacuum - Off
              message: "Outlet turned off due to consumption < 3 W."

      # 2) If plug is OFF and X seconds (default 777,600s = 9 days) have passed -> Turn ON
      - conditions:
          - condition: state
            entity_id: switch.smart_plug
            state: "off"
          - condition: template
            value_template: >-
              {{
                state_attr('input_datetime.dyson_charger_off_time', 'timestamp') | default(0) | int > 0
                and
                as_timestamp(now()) - (
                  state_attr('input_datetime.dyson_charger_off_time', 'timestamp') | int
                ) > 777600
              }}
        sequence:
          - service: switch.turn_on
            target:
              entity_id: switch.smart_plug
          - service: persistent_notification.create
            data:
              title: Dyson Vacuum - On
              message: "Outlet turned on after the defined delay."
    default: []
mode: single

Personally I had an idea that goes into the similar direction…
As Li-Ion batteries go, they don’t like being charged while warm/hot. So I thought of attaching a magnet somewhere in the vacuum cleaner and together with a contact sensor that would sit on the charger, detect when the vacuum is removed/returned. A smart socket would sit between the charger and the power grid.
When the vacuum cleaner is removed, turn the socket off. When the cleaner is returned, only turn the socket on after a certain time.
Now I only have to find a thin enough magnet or a sensible enough contact sensor.