jonasbkarlsson / ev_smart_charging

Electric vehicle smart charging for Home Assistant.
MIT License
171 stars 25 forks source link

Easee integration #46

Open achmeed opened 1 year ago

achmeed commented 1 year ago

Hi, have not seen anything that describes this but when you connect your charge cable to your car the ev-robot will start to charge instantly, will ev smart charging stop this after x amount of time?

For now I rely on a schedule where the easee box will say the ev charge between 22-07:00 , but this will trigger my EVs to start charging at 22 when we really want it to start when esm decides to.

jonasbkarlsson commented 1 year ago

I don't have an Easee myself, so it's difficult to give a clear advice. I believe that there are people with Easee that is using this integration successfully.

My guess is that you should remove the schedules from the Easee, and let this integration get complete control of start and stop of charging. In the documentation I provide an example of automations that I thought where going to make it work. Can you try those?

You can use the "Manually start charging" and "Manually stop charging" buttons in the integration to verify that it works.

jonasbkarlsson commented 1 year ago

Now I saw that there is a switch in the Easee integration, "switch.exxxxxxx_is_enabled", that seems to be possible to use in this integration. So please configure this integration using that switch. No need to add any automations.

achmeed commented 1 year ago

I believe that switch doesnt do much, tried to enable smart charging with it but nothing happens,

Regarding your documentation the suggested command has changed I.e to start smart charging when schedule is enabled and it has to be overrided

action:

Without schedule use and it will toggle resume then if you run again it wil toggle pause action:

https://developer.easee.cloud/reference/post_api-chargers-id-commands-start-charging

jonasbkarlsson commented 1 year ago

I have seen people that successfully used the switch, but all schedules need to be removed from Easee (and the car). Can you try that?

achmeed commented 1 year ago

It will just trigger to deactive the charger when I toggle smart charging, and then when I enable it it actives the charger wihtout starting any charging

jonasbkarlsson commented 1 year ago

And you have removed the Easee schedules? In your orignal post you said the charging started instantly when connecting the car. Is that still the case?

If you

Note that none of the above involves this integration.

achmeed commented 1 year ago
**remove all schedules -** Done
**active Easee (using the Easee app or whatever) -**Done
**is the switch.exxxxxxx_is_enabled now onin the Easee integration?** Yes
**connect the car to Easee** Done
**did the charging start now?** Yes
**if you now toggle the switch.exxxxxxx_is_enabled to off, will the charging stop?** It disbales the charger robot, ie puts it in disbled mode
**if you then toggle the switch.exxxxxxx_is_enabled to on, will the charging start?** No, it just enables the robot again
jonasbkarlsson commented 1 year ago

Ok. So if just using the switch will not work, then you need to use automations to let this integration use the Easee integration.

I guess it should be the following. Can you try? And then let me know what worked?

I'm not sure how "start" and "override_schedule" is supposed to be used. Only one of them? Or first "override_schedule", and then "start"?

alias: EV Smart Charging - Start
description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - sensor.ev_smart_charging_charging
    from: "off"
    to: "on"
condition: []
action:
  - service: easee.action_command
    data:
      device_id: "b40f1f45d28b0891fe8d" (replace with your own device id)
      action_command: "start" (or "override_schedule")
alias: EV Smart Charging - Stop
description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - sensor.ev_smart_charging_charging
    from: "on"
    to: "off"
condition: []
action:
  - service: easee.action_command
    data:
      device_id: "b40f1f45d28b0891fe8d" (replace with your own device id)
      action_command: "stop"
achmeed commented 1 year ago

Hi,

yes that works and how I use the integration, override_schedule is only needed if charging happends outside the schedule, to stop charging toggle is working but not the stop command - this is how ever on the easee side not your integraiton - will play around more

I think the solution if you dont use a schedule is to set an automation to listen to the cable connected sensor and send action_command pause then wait for the integration to toggle a start besided on cheapest hours.

You can close this if you want or leave it open for others to chip in with information so you can update your documentation

jonasbkarlsson commented 1 year ago

I checked with the developers of the Easee integration, and their recommendation was to remove all schedules and then to use the following two actions in the automations to start and stop charging.

action:
  - service: easee.set_circuit_dynamic_limit
    data:
      device_id: "b40f1f45d28b0891fe8d" (replace with your own device id)
      currentP1: 16 (replace with your preferred charging current)
action:
  - service: easee.set_circuit_dynamic_limit
    data:
      device_id: "b40f1f45d28b0891fe8d" (replace with your own device id)
      currentP1: 0 (something below 6 to make the charging stop)
jstorgaard commented 1 year ago

I'm using the switch._is_enabled using my Easee charger. Seems to work. I can use the "Manually start charging" and "Manually stop charging" buttons in the integration. I it OK to do it this way or do you still recommend to use the actions above?

jonasbkarlsson commented 1 year ago

The developers of the Easee integration recommend to not use the switch._is_enabled. So it's recommended to use the above actions.

overas commented 1 year ago

Thank you @jonasbkarlsson for your contribution with ev_smartcharging. You can also make a easee switch with the switch template (https://www.home-assistant.io/integrations/switch.template/)

switch:
  - platform: template
    switches:
      easee:
        friendly_name: "Easee charge switch"
        value_template: "{{ is_state('sensor.easee_home_XXXXXX_status', 'charging') }}"
        turn_on:
          service: easee.set_circuit_dynamic_limit
          data:
            device_id: "b40f1f45d28b0891fe8d" (replace with your own device id)
            currentP1: 10
        turn_off:
          service: easee.set_circuit_dynamic_limit
          data:
            device_id: "b40f1f45d28b0891fe8d" (replace with your own device id)
            currentP1: 0

image

overas commented 1 year ago

@jonasbkarlsson, when I setup ev_smartcharging I get an error about "Charger control switch not found". I use switch.easee in the input setting for "Charger Control switch".

image

The switch state is "on" or "off" and the switch works. When I switch to off I get easee status "awaiting_start" and when I switch to on I get easee status "charging".

image

overas commented 1 year ago

when I setup ev_smartcharging I get an error about "Charger control switch not found"

I found out what was wrong with the switch.easee. I needed a unique_id: which Studio Code Server generated for me. Now the setup works. Thanks again.

switch:
  - platform: template
    switches:
      easee:
        friendly_name: "Easee charge switch"
        unique_id: 5789b94f-96d6-4bdb-b31d-78c4b6ca6285
        value_template: "{{ is_state('sensor.easee_home_XXXXX_status', 'charging') }}"
        turn_on:
          service: easee.set_circuit_dynamic_limit
          data:
            device_id: "b40f1f45d28b0891fe8d" (replace with your own device id)
            currentP1: 10
        turn_off:
          service: easee.set_circuit_dynamic_limit
          data:
            device_id: "b40f1f45d28b0891fe8d" (replace with your own device id)
            currentP1: 0
ress23 commented 1 year ago

Thanks @overas unique_id did the trick for me too.

Skeletorjus commented 1 year ago
switch:
[...]
        friendly_name: "Easee charge switch"
        value_template: "{{ is_state('sensor.easee_home_XXXXXX_status', 'charging') }}"
[...]

Hi! Nice work! I could be overlooking something obvious, but wouldn't it make more sense to use {{ states('sensor.easee_dynamic_circuit_limit') | int > 0 }} as a value template here? This would ensure that the state of the switch is on even if it's not actively charging.

overas commented 1 year ago

Thanks @Skeletorjus, you have right. The documentation for switch template says:

https://www.home-assistant.io/integrations/switch.template/

availability_template template (optional, default: true) Defines a template to get the available state of the entity. If the template either fails to render or returns True, "1", "true", "yes", "on", "enable", or a non-zero number, the entity will be available. If the template returns any other value, the entity will be unavailable. If not configured, the entity will always be available. Note that the string comparison not case sensitive; "TrUe" and "yEs" are allowed.

I made the availability_template from the example in the documentation, but your approch is better. It gives True if the attributt is bigger than 0 and False if it is 0.

Skeletorjus commented 1 year ago

@overas You mean value_template? The value_template will make the state of the switch whatever the template renders to, so in this example the switch will be on if sensor.easee_dynamic_circuit_limit i above zero. The availability_template dictates if the switch should be available at all. In that case it would make sense to use binary_sensor.easee_online, so when the charger goes offline the switch will be disabled as well. With this taken into consideration, the whole template switch can look something like this:

switch:
  - platform: template
    switches:
      easee:
        friendly_name: "Easee charge"
        unique_id: easee_charge_switch
        availability_template: "{{ states('binary_sensor.easee_online') }}"
        value_template: "{{ states('sensor.easee_dynamic_circuit_limit') | int > 0 }}"
        icon_template: mdi:ev-station
        turn_on:
          service: easee.set_circuit_dynamic_limit
          data:
            device_id: device_id_here
            currentP1: 16
        turn_off:
          service: easee.set_circuit_dynamic_limit
          data:
            device_id: device_id_here
            currentP1: 0
overas commented 1 year ago

Sorry @Skeletorjus, but I misunderstood the documentation. You are right and thanks for the clarification

ulfben commented 1 year ago

A lot of the examples here are using device_id to identify their charger. The device_id is not easily discoverable in HA. The only way I've been able to find out my device_id was to parse it from the URL of the easee integration, or create an automation with the charger to see what HA generated.

If I understand the Easee HASS docs correctly, you can instead use charger_id - this is the 7-8 character serial number of your charger and is much easier to discover in the HA UI, or in the Easee app (Charger Settings -> About -> Serial Number).

jonasbkarlsson commented 1 year ago

@ulfben Have you tried using charger_id? Does it work? I don't have an Easee charger so I can't test myself. When I read the source code for the Easee integration, I can only see support of device_id. If you use the GUI to create automations in HA, you should be able to find the device_id.

ulfben commented 1 year ago

Yes! My charger is "ehfhjymw" and my switch uses charger_id to identify it:

switch:
  - platform: template
    switches:
      easee:
        friendly_name: "Easee charge"
        unique_id: easee_charge_switch
        availability_template: "{{ states('binary_sensor.ehfhjymw_online') }}"
        value_template: "{{ states('sensor.ehfhjymw_dynamic_circuit_limit') | int > 0 }}"
        icon_template: mdi:ev-station
        turn_on:
          service: easee.set_circuit_dynamic_limit
          data:
            charger_id: "ehfhjymw"
            currentP1: 16
            currentP2: 16
            currentP3: 16
        turn_off:
          service: easee.set_circuit_dynamic_limit
          data:
            charger_id: "ehfhjymw"
            currentP1: 0
            currentP2: 0
            currentP3: 0

Regarding the setting of all phases: I double-checked and it is enough to set P1. The others will be assigned the same value. But I find implicit APIs like that less clear, so I opted to write them all out explicitly.

jonasbkarlsson commented 1 year ago

Thanks for the confirmation! I will change the example in the documentation to use charger_id instead.

Flight777 commented 1 year ago

Yes! My charger is "ehfhjymw" and my switch uses charger_id to identify it:

switch:
  - platform: template
    switches:
      easee:
        friendly_name: "Easee charge"
        unique_id: easee_charge_switch
        availability_template: "{{ states('binary_sensor.ehfhjymw_online') }}"
        value_template: "{{ states('sensor.ehfhjymw_dynamic_circuit_limit') | int > 0 }}"
        icon_template: mdi:ev-station
        turn_on:
          service: easee.set_circuit_dynamic_limit
          data:
            charger_id: "ehfhjymw"
            currentP1: 16
            currentP2: 16
            currentP3: 16
        turn_off:
          service: easee.set_circuit_dynamic_limit
          data:
            charger_id: "ehfhjymw"
            currentP1: 0
            currentP2: 0
            currentP3: 0

Regarding the setting of all phases: I double-checked and it is enough to set P1. The others will be assigned the same value. But I find implicit APIs like that less clear, so I opted to write them all out explicitly.

I think this method does not work if I also use a Equalizer. It is then instantly overwritten by Easee Equalizer itself :(

liudger commented 1 year ago

Can't you just use the pause and resume action form the Easee charger? I have an automation that turns the charger on (still on pause) when my car gets connected to the charger. (it checks if the car is connected) When the chargers is on the car can use power for example to use the preheat.

What I am missing is the this integration only support on/off. It would be nice to have it directly connect to the Easee charge so it can use the pause/resume action easee.action_command resume/pause. I now need to use another automation that get triggered by the on/of state form sensor.ev_smart_charging_charging

jonasbkarlsson commented 1 year ago

What I am missing is the this integration only support on/off. It would be nice to have it directly connect to the Easee charge so it can use the pause/resume action easee.action_command resume/pause. I now need to use another automation that get triggered by the on/of state form sensor.ev_smart_charging_charging

Yes, I'm aware of this. Intitially I have focused on the charging control, and I have a few more things I would like to improve. I have some ideas on how to handle your request, but I will need some time to find a good solution that make sense to implement considering that there are quite many different chargers.

liudger commented 1 year ago

Yeah the logic is quite nice.

A bit off topic

Maybe this ev-smart-charging could be upgraded to be a module inside homeassistant that can for example also control headpump and other high energy devices.

I know in the Netherlands there is a project starting that has the goal to enable device control that will results in more stable electric network. They want to create open standard for this. Maybe this is interesting so the module can be used also from outsiders de by the electric network provider. (I guess you earn a bit of money by stabilizing the network)

https://elaad.nl/ is one of the companies that is working on this platform. They also helped the standaard for ev charging. Mostly for public charging stations.

https://elaad.nl/energiemanagement-in-en-om-de-woning-biedt-grote-kansen/

This is the link for the project. It's in Dutch :(

There is also an English pdf https://elaad.nl/wp-content/uploads/downloads/Energy-Management-Opportunities-for-The-Home_ElaadNL-FAN_Dec2022_V1.2.pdf

jonasbkarlsson commented 1 year ago

I know that there are users of this intergration that already now use it to control other high energy devices, and I have added some controlling means to better support that. Also, I have plans to eventually add a discharging function so that it can be used with home batteries and V2H capable chargers/cars.

enoch85 commented 11 months ago

Yes! My charger is "ehfhjymw" and my switch uses charger_id to identify it:

switch:
  - platform: template
    switches:
      easee:
        friendly_name: "Easee charge"
        unique_id: easee_charge_switch
        availability_template: "{{ states('binary_sensor.ehfhjymw_online') }}"
        value_template: "{{ states('sensor.ehfhjymw_dynamic_circuit_limit') | int > 0 }}"
        icon_template: mdi:ev-station
        turn_on:
          service: easee.set_circuit_dynamic_limit
          data:
            charger_id: "ehfhjymw"
            currentP1: 16
            currentP2: 16
            currentP3: 16
        turn_off:
          service: easee.set_circuit_dynamic_limit
          data:
            charger_id: "ehfhjymw"
            currentP1: 0
            currentP2: 0
            currentP3: 0

Regarding the setting of all phases: I double-checked and it is enough to set P1. The others will be assigned the same value. But I find implicit APIs like that less clear, so I opted to write them all out explicitly.

I think this method does not work if I also use a Equalizer. It is then instantly overwritten by Easee Equalizer itself :(

Did you find a solution for this @Flight777?

I have two Easee (22kW) chargers + one Equalizer, and no matter if I start one or the other charger, both starts charging. Maybe there's a way around this?

jonasbkarlsson commented 11 months ago

@enoch85, how does it work with two Easee? Do you have two instances of the Easee integration or can one instance handle two Easee?

For the ev_smart_charging integration, you will need two instances. One controlling one Easee each.

enoch85 commented 11 months ago

@enoch85, how does it work with two Easee? Do you have two instances of the Easee integration or can one instance handle two Easee?

For the ev_smart_charging integration, you will need two instances. One controlling one Easee each.

@jonasbkarlsson

I use the easee_hass integration and it controls all three devices, charger 1, charger 2, and the Equalizer. The sensors and switches have different names of course, and are named by the name of the charger. In my case; "garage" and "uppfart garage".

image

So the EV Smart integration is already using 2 separate "devices". Or do you mean I need one Easee integration controlling one charger, and another integration controlling the other charger? I mean, I can only have one integration, but multiple devices, right?

Here's the recommended Automation for "Uppfart Garage":

image

And here's for "Garage:"

image

It's also separated in your integration:

image

As you can see, it's for different cars, and different chargers. Shouldn't that be enough? Also tried with charger_id but it was the same result.

enoch85 commented 11 months ago

2 X Easee Home + 1 X Equalizer - solved it! :heavy_check_mark:

I posted the full solution here: https://github.com/fondberg/easee_hass/issues/256#issuecomment-1774129683

cc @jonasbkarlsson FYI.

zlakes01 commented 4 months ago

How did you get second Easee in to the integration? image