## Smart EV Charging Socket – Power-based detection with cooldown lock

Smart EV Charging Socket – Power-based detection with cooldown lock

This blueprint provides a robust and event-driven solution to manage an EV charging socket using real power consumption detection, instead of timers or fixed schedules.

It was designed for small EVs and city cars (such as Citroën AMI–style vehicles), but it works with any charger connected to a smart socket with power monitoring.


:wrench: How it works

  1. The automation runs a probe at a configurable interval (default: every 30 minutes).
  2. During the probe, the socket is turned ON and the system waits a short stabilization delay.
  3. If the measured power exceeds a configurable threshold (default: 500 W), real charging activity is detected.
  4. The socket remains ON while charging is in progress.
  5. Charging is considered finished when power drops below a low threshold for a stable period (default: below 30 W for 3 minutes).
  6. The socket is automatically turned OFF at the end of the charge.
  7. The end-of-charge timestamp is stored in an input_datetime helper.
  8. A cooldown lock (default: 12 hours) prevents further probes until the next realistic charging window.

:brain: Why this approach

  • Avoids continuous polling loops
  • Prevents unnecessary ON/OFF cycles
  • No repeated checks during charging
  • Safe across Home Assistant restarts
  • Matches real-world EV usage (typically one charge per day)
  • Fully event-driven using wait_for_trigger

:white_check_mark: Key features

  • Power-based charging detection
  • Stable end-of-charge recognition
  • Configurable probe interval and thresholds
  • Cooldown lock after charging
  • Works with any smart plug providing power data
  • Home Assistant UI-friendly blueprint

:package: Requirements

  • Smart socket with power monitoring
  • One input_datetime helper to store the last charge time
  • Recent Home Assistant version (UI automation schema)

:gear: Configuration notes

  • If your charger does not drop below 30 W at the end of charging, increase the stop threshold (e.g. 50–80 W).
  • Cooldown duration can be adjusted to match your charging habits.
  • All parameters are configurable through blueprint inputs.

:test_tube: Tested scenario

Tested with:

  • Smart plugs with integrated power sensors
  • Small EV chargers with long idle phases
  • Daily charging patterns (1 charge per day)

Feedback, suggestions and improvements are welcome.
I hope this blueprint can be useful to others managing EV charging through Home Assistant.


blueprint:
  name: Smart EV Charging Socket (Power detection + Cooldown)
  description: >
    Automatically manages an EV charging socket using power consumption detection.
    Periodically probes the socket, detects real charging via power threshold,
    turns the socket off at end of charge, and applies a cooldown lock.
  domain: automation

  input:
    charger_socket:
      name: EV charger socket
      description: Smart socket used to power the EV charger
      selector:
        entity:
          domain: switch

    power_sensor:
      name: Power sensor
      description: Sensor reporting charger power in Watts
      selector:
        entity:
          domain: sensor
          device_class: power

    last_charge_datetime:
      name: Last charge helper
      description: input_datetime helper used as cooldown lock
      selector:
        entity:
          domain: input_datetime

    probe_interval:
      name: Probe interval (minutes)
      default: 30
      selector:
        number:
          min: 5
          max: 120
          step: 5
          unit_of_measurement: min

    probe_delay:
      name: Probe delay (seconds)
      default: 30
      selector:
        number:
          min: 5
          max: 120
          step: 5
          unit_of_measurement: s

    start_power:
      name: Charging start threshold (W)
      default: 500
      selector:
        number:
          min: 100
          max: 3000
          step: 50
          unit_of_measurement: W

    stop_power:
      name: Charging end threshold (W)
      default: 30
      selector:
        number:
          min: 10
          max: 200
          step: 5
          unit_of_measurement: W

    stop_duration:
      name: Charging end duration (minutes)
      default: 3
      selector:
        number:
          min: 1
          max: 10
          step: 1
          unit_of_measurement: min

    cooldown_hours:
      name: Cooldown after charging (hours)
      default: 12
      selector:
        number:
          min: 1
          max: 48
          step: 1
          unit_of_measurement: h

mode: single

trigger:
  - platform: time_pattern
    minutes: "/{{ probe_interval }}"

condition:
  - condition: template
    value_template: >
      {% set last = states(last_charge_datetime) %}
      {% if last in ['unknown','unavailable',''] %}
        true
      {% else %}
        {{ (now() - strptime(last, '%Y-%m-%d %H:%M:%S')).total_seconds() >
           (cooldown_hours | int * 3600) }}
      {% endif %}

action:
  # Probe: turn socket ON
  - service: switch.turn_on
    target:
      entity_id: !input charger_socket

  - delay:
      seconds: !input probe_delay

  - choose:
      # Charging detected
      - conditions:
          - condition: numeric_state
            entity_id: !input power_sensor
            above: !input start_power
        sequence:
          # Wait for end of charge
          - wait_for_trigger:
              - platform: numeric_state
                entity_id: !input power_sensor
                below: !input stop_power
                for:
                  minutes: !input stop_duration
            timeout: "14:00:00"
            continue_on_timeout: false

          # Turn socket OFF
          - service: switch.turn_off
            target:
              entity_id: !input charger_socket

          # Save end-of-charge timestamp
          - service: input_datetime.set_datetime
            target:
              entity_id: !input last_charge_datetime
            data:
              datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"

    default:
      # Not charging → turn OFF immediately
      - service: switch.turn_off
        target:
          entity_id: !input charger_socket

Hello AltarusMb,

Thanks for contributing to the community with a new Blueprint.
I have a suggestion for you. Many people who are not familiar with directory structures will have problems installing this without the Home Assistant MY tools.

Adding a MY link for this Blueprint to your top post would help them a lot.
Here is the link to make that.
Create a link – My Home Assistant