#EV Charging Automation

1 messages · Page 1 of 1 (latest)

fleet lily
#

I have a dum charger and a smart relay, im trying to automate the car to charge at specfic times based on my energy tariff prices to meet the target goal and time sent from telegram. It however is not running. Would anyone be willing to help a newbie with his first complex automation?

swift cosmos
# fleet lily

holy shit we have a complicated operation going on here

fleet lily
#

indeed should i just spend a grand on a proper charger might be less hassle

#

i was hearing about node red but that caused a headache in trying to work out

swift cosmos
#

my inital thought is that this is super complicated and you have somehow written yourself into a corner

fleet lily
#

ahhh ok, do you have another better way to do what im looking for?

swift cosmos
#

so you have something telling you when you should charge by telegram?

fleet lily
#

so at the moment im switching the relay on and off manually based on the energy rates and the maximum charge i want on the vehicle as i heard its not sensible to max out the charge on it.

i thought in my lack on knowledge on ha i wonder if i could "automate" this by telling HA i want 90% charge for 9am tomorrow and it look at the rates and switch the relay on and off accordingly

swift cosmos
#

i am sure it can be done

#

so your working out how much charge you need, which is how many slots, then you work out the cheapest slots between now and deadline. then switch on for them

#

this btw is a "long running automation" which in general is not recommended. in case something goes wrong and it gets stuck or HA restarts or something.

fleet lily
#

yes so my prices change every 30 mins and its a 2kwh charger so every 30 mins it should be giving 1kwh into the car
so if i wanted to add 3kwh to the car it would find 30 mins at the cheapest level and start and stop on each one unitl its charge target is reached

fleet lily
swift cosmos
fleet lily
#

90%/95% somewhere round there

#

oh apparently lower than that 83-92%

swift cosmos
#

yeah that seems more right

#

so, a suggestion for a simple solution whilst working on a better one would be to just switch the charger on when its below X threshold and off when its above y threshold (or z hours to deadline)

fleet lily
#

i had that through bottlecapdave the issue is the percentages

#

it would charge to 100% everyday which i dont always want or need

swift cosmos
#

can you see the cars battery state?

fleet lily
swift cosmos
#

if you can see your car battery state then just dont switch on when its above a threshold

#

can add a condition that the switch on needs car to be <80% for example

fleet lily
#

but is their a way to simply vary that threshold? as an example mon-fri im driving around town that sort of thing just want 40/50% charge and then if im going for a road trip on a saturday friday evening i want it to charge to 100%. thats why i was looking at the telegram side of things

swift cosmos
#

yeah you could make it a helper then just add that as a slider on your dashboard

fleet lily
swift cosmos
#

alot of cars have the ability to set a limit too?

fleet lily
#

it does but its awful and unreliable, they have already had a few customers return vehicles due to its buggyness

swift cosmos
#

something like this to make and set

fleet lily
#

Yes!!!!

swift cosmos
#

then you can make a condition with template something like this

{{ states('sensor.car_current_battery')|float < states('input_number.car_charging_limit')|flaot }}

#

so if battery is less than limit the condition returns true

fleet lily
#

got that, how do i get it onto dashboard?

swift cosmos
#
entity: input_number.ev_charge_limit
features_position: bottom
vertical: true
hide_state: false
show_entity_picture: false
features:
  - style: slider
    type: numeric-input
grid_options:
  columns: 12
  rows: 3
#

make a custom card and paste that in

#

you can adjust as needed but it gives you a starting point

fleet lily
#

thank you so much, ok so one step closer

i now have my current script:

alias: EV-Charge
description: ""
triggers:

  • trigger: state
    entity_id:
    • binary_sensor.octopus_energy_target_ev_charge
      from: "off"
      to: "on"
      conditions:
  • condition: numeric_state
    entity_id: sensor.octopus_energy_electricity_18k0173475_2400000037705_current_rate
    below: 0.3
    actions:
  • action: switch.turn_on
    metadata: {}
    data: {}
    target:
    entity_id: switch.driveway_power_switch
  • wait_for_trigger:
    • trigger: state
      entity_id:
      • binary_sensor.octopus_energy_target_ev_charge
        from: "on"
        to: "off"
  • action: switch.turn_off
    metadata: {}
    data: {}
    target:
    entity_id: switch.driveway_power_switch
    mode: single
#

need to modify that i guess

swift cosmos
#

use triple grave around code

unkempt remnantBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

swift cosmos
#

for long stuff that becomes a file its fine but for shorter stuff we need formatting as code to be readable in discord

fleet lily
#
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.octopus_energy_target_ev_charge
    from: "off"
    to: "on"
conditions:
  - condition: numeric_state
    entity_id: sensor.octopus_energy_electricity_18k0173475_2400000037705_current_rate
    below: 0.3
actions:
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.driveway_power_switch
  - wait_for_trigger:
      - trigger: state
        entity_id:
          - binary_sensor.octopus_energy_target_ev_charge
        from: "on"
        to: "off"
  - action: switch.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: switch.driveway_power_switch
mode: single
#

so sorry!

swift cosmos
#

no worries

#

ok so we want to make 2 changes

#

first you want to add the condition so this doesnt run when its above the charge limit

#

as demonstated above but with the right entity names

fleet lily
#

would that be within my wait for trigger?

swift cosmos
#

no on the main automation

#

we need to add stuff to the wait for too

#

but 1 thing at a time

#

the change to the main automation condition means that if the car is above the limit this automation does not run therefore it doesnt turn on the switch

fleet lily
#

sensor.battery is under the renault integration and under the car name Baby Blue

swift cosmos
#

cool doesnt matter what integration its under as long as you have the right entity name

#

once you have that condition in then within the wait for trigger you want to add a 2nd trigger that turns it off once its hit the limit
so would be numeric entity change and entity x is above entity y (the limit entity)

#

this means if its over the limit the switch doesnt come on and if it hits the limit whilst its switched on then it switches off

#

hopefully that makes sense?

fleet lily
#

sounds good sort of makes sense 🙂

#

so under and if numeric state {{ states('sensor.battery')|float < states('input_number.EV_Charge_Limit')|flaot }}

swift cosmos
#

moment

#
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.octopus_energy_target_ev_charge
    from: "off"
    to: "on"
conditions:
  - condition: numeric_state
    entity_id: sensor.octopus_energy_electricity_18k0173475_2400000037705_current_rate
    below: 0.3
  - condition: template
    value_template: " {{ states('sensor.battery')|float < states('input_number.EV_Charge_Limit')|flaot }}"
actions:
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.driveway_power_switch
  - wait_for_trigger:
      - trigger: state
        entity_id:
          - binary_sensor.octopus_energy_target_ev_charge
        from: "on"
        to: "off"
      - trigger: numeric_state
        entity_id:
          - sensor.battery
        above: input_number.EV_Charge_Limit
  - action: switch.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: switch.driveway_power_switch
mode: single
#

like this

fleet lily
#

wow thank you so much! 🙂 ok so last little thing, could i set the percentage slider from a QR code or NFC tag, thinking of wife approval factor

swift cosmos
#

have you used tag automations before?

#

make an automation that triggers off the tag then use the input_number.set_value action to set

fleet lily
#

nope, as its a helper how do i choose it?

swift cosmos
#

thats number.set

#

you want input_number.set

#

yaml of the action would be

action: input_number.set_value
metadata: {}
data:
  value: 80
target:
  entity_id: input_number.EV_Charge_Limit
fleet lily
#

thank you! you got paypal happy to pay for your time this evening its been most helpful!

swift cosmos
#

no thank you, consider subbbing to ha cloud to support the project though

fleet lily
#

thank you again! i think i need to find the idiots guide to ha

swift cosmos
#

once you learn how things work and what all the tools are and how they fit together it will get easier

#

if you do decide to get a smarter charger i recomend looking at hypervolt btw. theres a HACS integration that works nicely and it works very well with plenty of options. it also supports some of the smart tarrif stuff.

fleet lily
#

wicked great advise thank you! my problem is its a cheap car and used for local journeys trying to see if i can survive with the granny charger atm