Octopus agile - turn on/off car charging

I am on Octopus Agile and an electric car, I have got so far with automating the car to start charging when the half hourly rate is below a certain amount, I am after a bit of guidance to get me over the finishing line.

I have setup the octopus integration

I have a helper set with a number that I want to trigger a charge if it goes below = input_number.input_number_kwh_charge_range.

The current agile rate is = sensor.current_kwh_price

I also have the car integration and the correct service for stop/start charging.

I want the end result to be when i plug in the charger, if my set threshold is below the current rate then a command to stop the service is sent or nothing happens.

If my threshold is above the current rate then a command to charge is sent to the service.

Also, as I am doing this via the car, when I plug in the charger, it starts charging automatically, I want this to stop if the current rate is over the threshold.

Here is the yaml I have so far, I am a beginner at this and getting myself in a muddle, any help will be appreciated

alias: Charge
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.current_kwh_price
    above: input_number.input_number_kwh_charge_range
  - platform: numeric_state
    entity_id:
      - sensor.current_kwh_price
    below: input_number.input_number_kwh_charge_range
  - platform: state
    entity_id:
      - input_number.input_number_kwh_charge_range
condition:
  - condition: state
    entity_id: binary_sensor.ioniq_5_ev_battery_charge
    state: "on"
action:
  - if:
      - condition: numeric_state
        entity_id: sensor.current_kwh_price
        below: input_number.input_number_kwh_charge_range
    then:
      - service: kia_uvo.start_charge
        data:
          device_id: 78690a63a4f5e932517df05353e3b539
  - if:
      - condition: numeric_state
        entity_id: sensor.current_kwh_price
        above: input_number.input_number_kwh_charge_range
    then:
      - service: kia_uvo.stop_charge
        data:
          device_id: 78690a63a4f5e932517df05353e3b539
mode: single

Hey, did you get anywhere with this?

I’m also on Agile and have a similar set up, however I don’t like touching Yaml stuff so I set up a helper which is an input number which I then just update from my car control dashboard in HA.

I set up an automation which sates if the agile rate entity is below my helper number then turn car charger on, otherwise turn it off.

Would this help?

I actually came here to see if anybody had written code for if the vehicle is under 20% charge then charge when the agile rate is below 20p

If the vehicle is under 50% charge then turn on only under 10p

If the rate goes 5p or less then charge to 100% etc but that’ll take me some time to get right in my head let alone in an automation lol

Hey there, I will be setting this up for myself tomorrow when I pick up my Tesla.

In order to do this you will 3 things:

  1. Car SOC sensor
  2. Current kWh price
  3. Charger Toggle

Optionally, a sensor that says if the car is connected or not, to save API hits.

I had my Easee charger installed today, and I am picking my Tesla up tomorrow. I will come back here once I’ve set it up and share my config for you to replicate :slight_smile:

I will be setting up the following logic:

When energy_rate_change
If Car_SOC < 30% then Charger_ON()
else if Car_SOC < 60% & rate < 0.15 then Charger_ON()
else if Car_SOC < 80% & rate < 0.05 then Charger_ON()

The idea is to keep the car at 30% minimum, regulaly charge to 50% when the rate is below 15p /kWh and if its below 5p (or even free) then charge to 80%