nordicopen / easee_hass

Custom component for Easee EV charger integration with Home Assistant
217 stars 37 forks source link

Car Charge Automation base on Solar production #122

Open adamrami opened 3 years ago

adamrami commented 3 years ago

I am trying to create an automation based on solar production and car Screenshot 2021-05-28 at 09 37 09 Screenshot 2021-05-28 at 09 35 27

But I don't get it to run based on my requirements. Same thing when I trying to run the service in the developer tool. Please see attached images. Is there anything else I should insert in the easee service beside the charger ID? Or anything else that I missed

Thanks in advance Adam

tmjo commented 3 years ago

Hi! First of all, do you get any error or debug messages or does things seem to work alright but nothing happens?

Also, it may be something simple like the car is not requesting charging or maybe you have schedule or smart charging activated in the charger? The start command itself kindof opens up for charging, but it is the car that actually decides when to charge or not.

adamrami commented 3 years ago

Hello, thanks for your response. I get the following error message when I run it in the developer tools. The car is ready to charge and I can start the charger using the Easee app. Please see attached message, assuming you speak Swedish :) Screenshot 2021-05-31 at 10 10 08

tmjo commented 3 years ago

Hmm, that seems odd, it seems that it doesn't find your charger id (none). Not sure why this should happen, it works on my end. I did get one error message, but it was a authorization error and while my car was disconnected. I'm not really using these commands actively, but I remember we were told by Easee that start/stop is for a new charging session and involves checking for authorizations (some people use RFID and stuff to authenticate in larger buildings etc) while the pause/resume should be enough if there is no authorization required (which is my case). Pausing is basically just setting the dynamic current limit to zero internally in the charger, so the same could be achieved with this function.

What is the state of your charger (the status sensor)? And perhaps you could give it a try with pause/resume functions instead, or even just setting the dynamic current limit to zero when you want to stop (or pause actually) charging?

Don't think it is related, but you could also check the value of the 'config_authorizationRequired' attribute in the status sensor.

adamrami commented 3 years ago

Thanks a lot for your comments. I tried: service: easee.resume charger_id: EH**** and got the same message again :( I do use RFID but, I have already "authorized" so the charging should be able to start. Meaning that I can start the charger with the Easee app on my Phone, similarly I should be able to run the command above and start/resume Easee charging. Sorry for being such a novice, but I am not sure what you mean with config_authorizationRequired attribut! Screenshot 2021-05-31 at 15 01 47

120196990-cbde0800-c220-11eb-9a25-8110da9ff80b

tmjo commented 3 years ago

Hmm, that's strange. There's a loop checking if the charger id is in the "found" chargers for your account, and it returns None if there is no match. I guess you have already doublechecked you charger id and that is ok.

It may be irrelevant, but there has been some changes in the developer tools in HA some time back. I see that in my instance it looks either like this (in ui-mode): image or like this (in yaml-mode): image

So looking at your screenshots, it seems you are in yaml-mode and it could be worth a try using this format:

service: easee.start
data:
  charger_id: EH123456

When I put it like your example I get a different error message though ("extra keys not allowed"), so it doesn't quite add up to me but could be worth testing. If it doesn't help, perhaps re-installing the integration could help. Worth a try anyway :)

adamrami commented 3 years ago

I reinstalled it and I think it made the trick :) I can now Run Services and I get the Charger to start charging. Thanks for the help. Now, I am trying to create an automation based on the current solar power electricity production, so I only charge the car when I have higher production than a certain limit as a trigger in my automation. But when I run the Automation it starts without taking hight for the current solar electricity production! Or Am I under the wrong impression, that when you "run" an automation, it does not care about meeting its requirements? Screenshot 2021-06-01 at 15 18 00 Screenshot 2021-06-01 at 15 17 40 Screenshot 2021-06-01 at 15 18 17

Thanks for all the help!

tmjo commented 3 years ago

Sounds good!

I'm not too experienced in the automation world of HA to be honest, but for sure there is a possibility. I always need to play around to achieve what I want since I don't always find the descriptions very intuitive. I believe you're better of asking on in the community since it is more of a generic issue with automations, and make sure you've studied the descriptions in detail. Could numeric trigger be what you are looking for?

adamrami commented 3 years ago

Thanks :) I have tried the Numeric trigger with the same result. Meaning it kicks off even if the requirements are not met.

nordan70 commented 3 years ago

Hi, when you push RUN on the automation you are the TRIGGER. And it dont care of the state value.

But you can make a copy of your trigger and put it under CONDITIONS as well, and that will stop trigger from happen.

adamrami commented 3 years ago

Thanks a lot Nordan70. I have done the changes but not tried the functionality yet. I will give it a shot and get back with results :)

adamrami commented 3 years ago

I added the Condition (beside the existing Trigger) like this but still same result, meaning it does not take hight for the current production. I am not sure if I have set the right parameters though!

Screenshot 2021-06-12 at 14 37 44

ankisch commented 3 years ago

Try this Screenshot_2021-06-16_12-33-08

adamrami commented 3 years ago

Hello ankisch, Thanks for the response. Do you mean on Triggers or Condition (or both) ;)

ankisch commented 3 years ago

Use it as a trigger. Or even better if you have a power meter to take into account your other appliances that are using power.

I use a sensor that measures how much power I am exporting to the grid as a trigger. Whenever i export more than my charger uses it triggers. If conditions are met (charger connected, car battery not full) it will start to charge. I then use the same sensor as a trigger to watch if I stop exporting and then pause the charger, if conditions are met (charger is charging).

I have done this in Node-RED so can't provide any code to use in HA directly.

adamrami commented 3 years ago

Thanks again. I tried the Trigger with Numeric state, but when I click Run on the automation it runs and the car starts charging even though I set the variables so high to not match the conditions. I have also something called Grid power, and I guess this indicates how much is sent to the grid. I should be able to click on Run and based on the logic, it either starts charging or not, right? Screenshot 2021-06-16 at 15 20 28 Screenshot 2021-06-16 at 15 20 41

Since these conditions are not valid, the charger should not start!

ankisch commented 3 years ago

Since I don't use HA automations I'm not sure about this, but doesn't the conditions get overridden when you press run?

Maybe you could try something like this, try paste in yaml mode

alias: Test
description: ''
mode: single
trigger:
  - platform: numeric_state
    entity_id: sensor.solaredge_current_power
    above: '9000'
condition: []
action:
  - choose:
      - conditions:
          - condition: numeric_state
            entity_id: sensor.solaredge_current_power
            above: '12000'
        sequence:
          - service: notify.persistent_notification
            data:
              message: "Above 12 kW"
    default:
      - service: notify.persistent_notification
        data:
          message: "Above 9 kW, below 12 kW"
olalid commented 3 years ago

Yes, clicking run will override the trigger and conditions, so that is not a good way to test...

I also want to point out that it is not really necessary to call the stop, start, pause or resume service. What you can do instead is control it by setting the circuit dynamic current. If that value is set to less than 6A, the charger will stop charging, if again set to 6A or above charging will resume. This works in my experience a lot better than trying to start/stop charging by any other means.

danielolsson100 commented 3 years ago

I have done this with ferroamp solar solution in theory as an example to work with. (I got my Easee installed today but I don't have an electric car yet so I can't really be sure that it works as expected.)

I'll dynamic define the Easee "dynamic charger limit" with the data from ferroamp with the data regards exported energy to the grid as @olalid suggested

When the export to grid current exceeds 6A the "dynamic charger limit" with be updated with the new threshold. I am using ferroamp as solution with Adaptive Current Equalization (ACE) so I don't need to worry on the different loads on the phases because it's automatically balanced 24/7.

configuration.yaml

automation.yaml

doabigcheese commented 3 years ago

thnx for the yaml code to this - i got mine also installed today and i have a electric car, so i need to figure out how to control it dynamicaly to squeeze the most out of the sun :) i will give it a try with your yaml :) thnx!

danielolsson100 commented 3 years ago

Did you managed to get the code running @doabigcheese ?

I think it would be nice if the integration has support for a (dynamic ) sensor value as input for the dynamic charger limit or dynamic circuit limit as mentioned by @olalid

This input can then limit the charger based upon the house max available energy limit for the moment for those of us that is measuring the grid load of the house. This can also be used for those people that has solar panels to limit the changer to the overflow of energy from the solar panels like I described in the earlier post with some automation but I think its better to have this logic in this sensor as native functionality. This may also be used when combining solar energy overflow and available grid energy to combine the to sources to one sensor. In my case I can in theory charge with 16Ax3 from the grid + 16Ax3 from my solar panels to be able to utilize the max current for the easee charger that is available for the moment. This could be added as a configuration setting for the sensor in the integration. [Dynamic charger limit] or something like that image

Edited: I have now seen the post from @olalid post https://github.com/fondberg/easee_hass/issues/120#issuecomment-840644741 related how to handle this better by defining charge level per phase and I think that is the way to go in this matter but it would be nice to let the integration handle it without the need for a automation flow for it. `- id: charging_current alias: Set dynamic charging current trigger:

olalid commented 3 years ago

Well, the Easee integration mostly just reflects the functionality of the API that Easee provides. There is really no extensive logic built on top of that and I think it is best to keep it that way.

That said, we have had discussions about writing a separate general module for house power handling, such as charging with solar, turning loads on/off depending on factors like time of day, electricity price, total load and so on. So that way it would not be exclusively for Easee, but general for any charger. Not sure what the roadmap for this kind of thing within the core HA is though, given that they have started adding some energy statistics stuff, perhaps this kind of things will be part of the HA core in the not so distant future.

danielolsson100 commented 3 years ago

Thanx for the feedback @olalid in this matter. I agree that the integration should be as clean as possible.

And thanx for your git regarding RG20 for NIBE ;)