Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

charging not stopped by ev_smart_charging integration #161

Closed
ronajon opened this issue Mar 14, 2023 · 12 comments
Closed

charging not stopped by ev_smart_charging integration #161

ronajon opened this issue Mar 14, 2023 · 12 comments

Comments

@ronajon
Copy link

ronajon commented Mar 14, 2023

Version of the custom_component

Version 1.7.0

Configuration

Home Assistant Core
Tesla custom integration
electricity prices come from the Noordpool integration
EV SOC entity : sensor.mario_kart_battery
EV Target SOC entity: number.mario_kart_charge_limit (also tried with blank value)
Charger control switch: switch.mario_kart_charger

Describe the bug

when charging starts, the ev_smart_charging integration does not stop the charging and wait until the lowest prices.
when the charger cable is plugged in the car, it starts charging directly and only stops when the batteries are full.
Charging can be interrupted by clicking the button "manually stop charging", then the ev_smart_charging integration waits until the lowest price and starts charging.

Expected behaviour

when the cable is plugged in, the charging starts.
the ev_smart_charging integratoin notices that the current time does not have the lowest price and stops the charging.
charging is resumed after the lowest price is met.

Debug log

debug log can be found here https://controlc.com/7cc9dc9f
the cable was connected to the car at 2023-03-14 18:36:00 (line 2482 of the log file )


Add your logs here.

@jonasbkarlsson
Copy link
Owner

Thanks for providing the debug log. Very helpful!

At 2023-03-14 18:36, the state of this integration was "off"
2023-03-14 18:36:10.898 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] current_value = False

So if charging started when you connected the car, there was something else that was wrong. I noticed that the Tesla integration failed earlier when the charging was supposed to end when the car got fully charged at 04:55.

2023-03-14 04:54:51.409 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Before service call switch.turn_off: switch.mario_kart_charger
2023-03-14 04:55:11.150 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall switch.turn_off (c:01GVF43B4HCCZGRZ4XEQ2KVT75): entity_id=['switch.mario_kart_charger']>
  File "/srv/homeassistant/lib/python3.10/site-packages/teslajsonpy/connection.py", line 209, in __open
    raise TeslaException(resp.status_code, "vehicle_unavailable")
teslajsonpy.exceptions.TeslaException: vehicle_unavailable 

So my guess would be that your problem was due to the Tesla integration. Maybe you need to reload it, or restart Home Assistant to make it work again?

@jonasbkarlsson
Copy link
Owner

jonasbkarlsson commented Mar 15, 2023

Ah, now I realized that your Tesla integration controls the car, and not a charger. For this to work I think you need to make a few automations.

  • One automation that sets switch.ev_smart_charging_ev_connected when connected to your charger would probably be good to have.
  • And then you need an automation that stops the charging, if charging has started and sensor.ev_smart_charging_charging is off.

And these two automations needs be able to distinguish between charging at home and charging at other places.

BTW, I plan to activate the Wiki and collect various automations that people have made, so that one can reuse what others have done.

@jonasbkarlsson
Copy link
Owner

Hmm. I was thinking a little more about this, and I think I can modify the integration to do the second task, to turn off charging directly after the car has been connected to the charger.

However, the first one, to add an automation that sets switch.ev_smart_charging_ev_connected will be needed.

@WhippingBoy01
Copy link

I'm facing the same with my Tesla, it has a full API integrated into home assistant. so we can provide

binary_sensor.Tesla_charger PLUGGED IN| UNPLUGGED
binary_sensor.herbie_charging CHARGING|NOT CHARGING

https://github.com/alandtse/tesla

I also have a Tesla wall connector integrated to HA with
binary_sensor.tesla_wall_connector_vehicle_connected ON|OFF

I would use the above, to avoid the HA blocking the charging in the wild at a super charinger ;-)

Maybe it could make sense to add an optional field in the configuration window:
EV connected:
binary_sensor.tesla_wall_connector_vehicle_connected

Coffee your way ;-)

@WhippingBoy01
Copy link

WhippingBoy01 commented Mar 16, 2023

I use this automation as a temporary fix

alias: Disable_Tesla_Charging
description: ''
trigger:

  • platform: state
    entity_id:
    • binary_sensor.tesla_wall_connector_vehicle_connected
      from: 'off'
      to: 'on'
      condition:
  • condition: and
    conditions:
    • condition: state
      entity_id: device_tracker.Tesla_location_tracker
      state: home
    • condition: state
      entity_id: sensor.ev_smart_charging_charging
      state: 'off'
      action:
  • service: switch.turn_off
    data: {}
    target:
    entity_id: switch.Tesla_charger
    mode: single

@jonasbkarlsson
Copy link
Owner

I also have a Tesla wall connector integrated to HA with binary_sensor.tesla_wall_connector_vehicle_connected ON|OFF

I would use the above, to avoid the HA blocking the charging in the wild at a super charinger ;-)

Maybe it could make sense to add an optional field in the configuration window: EV connected: binary_sensor.tesla_wall_connector_vehicle_connected

My current thinking is to add a configuration option for the user to be able to state that control of charging is done via an EV integration. And only if this option is selected, the integration will turn off chariging when the EV is connected to the charger.

The reason for this is to make sure that there are no users that today have fully functional configuration will experience "the HA blocking the charging in the wild at a super charinger" due to poorly configured automation for the switch.ev_smart_charging_ev_connected .

As for making the integration using binary_sensor.tesla_wall_connector_vehicle_connected as input to "EV connected", in general I have so far avoided making the integration too specific. There are many EVs and many chargers that might make it unreasonable to handle each of them. However, I do have some ideas about making the integration directly interact with more chargers, and maybe similar ideas could be used to also handle EV Connected.

@WhippingBoy01
Copy link

above should only have been mentioned as an example "Maybe it could make sense to add an optional field in the configuration window: EV connected: binary_sensor.tesla_wall_connector_vehicle_connected".

Tesla's have a location tracker as well.
device_tracker.Tesla_location_tracker

It could be used as a workaround, I did update the script above with it.

keeping the integration as vanilla/generic sounds like a very good idea ;-)

@ronajon
Copy link
Author

ronajon commented Mar 16, 2023

Ah, now I realized that your Tesla integration controls the car, and not a charger. For this to work I think you need to make a few automations.

* One automation that sets `switch.ev_smart_charging_ev_connected` when connected to your charger would probably be good to have.

* And then you need an automation that stops the charging, if charging has started and `sensor.ev_smart_charging_charging` is off.

And these two automations needs be able to distinguish between charging at home and charging at other places.

the switch.ev_smart_charging_ev_connected is always on. i have not yet found how or why it would tutn off (except the one time i manually tuned it off) found its purpose

creating the automations myself is not an issue. is there info available about the flow of the integration? meaning how the integration determines when to start charging or not ?

ps. i don't have a Tesla wall connector, and agree that keeping the integration should be kept as generic as possible

@pbsiim
Copy link

pbsiim commented Apr 15, 2023

I have an VW ID.3. The API seems a little byggy/skow. The manuel press Start/stop does not always work. The same goes for the planned charging start/stop.
When using a call service for stop/start buttons it works like a charm every time. Im not sure why?

action: call-service
      service: volkswagen_we_connect_id.volkswagen_id_start_stop_charging
      data:
        vin: WVWZZZxxxxxxx
        start_stop: start

My question is if there are any good way to use the same method for the planned start/stop?

@jonasbkarlsson
Copy link
Owner

You can use a service in this way for starting a planned charging:

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: volkswagen_we_connect_id.volkswagen_id_start_stop_charging
    data:
      vin: WVWZZZxxxxxxx
      start_stop: start

But what is it that doesn't work with your current confguration? How have you configured the integration to start/stop charging?

@pbsiim
Copy link

pbsiim commented Apr 15, 2023

You can use a service in this way for starting a planned charging:

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: volkswagen_we_connect_id.volkswagen_id_start_stop_charging
    data:
      vin: WVWZZZxxxxxxx
      start_stop: start

But what is it that doesn't work with your current confguration? How have you configured the integration to start/stop charging?

Thanks for the fast response. I will not go into detail in how i did the automation, but will follow your example as it's much more clean and simple. I was not aware of the "correct" method.
I'm pretty sure I’m all good now, the only “issue” I have is the button from the example does not always work.

entity: button.ev_smart_charging_manually_stop_charging

However im using mushroom cards and it works just fine like this.

tap_action:
      action: call-service
      service: volkswagen_we_connect_id.volkswagen_id_start_stop_charging
      target: {}
      data:
        vin: WVWZZZxxxx
        start_stop: start

@ghost ghost mentioned this issue Aug 6, 2023
@jonasbkarlsson
Copy link
Owner

At least partly fixed in release v1.9.0. If there still are issues, please create a new issue.

Note that there now is a configuration item that will tell the integratation that it is an EV integration as the Tesla custom integration (and not a charger integration) that controls charging. Please update this in your configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants