Energy Dashboard Add Electric Car consumption

Well, in general a battery charged as well as discharged, so this is why you have to add both values to the configuration I guess. As the discharge process of the car happens to the car not being attached to the wallbox, I gave it the “0” value in order to be able to add the car as a battery.
On your second point: I’m not sure if the configuration is difficult at all, you just add a second battery (besides the car) an it monitors what goes an comes…
As you can tell by my post, I have only little knowledge about all this. maybe someone else can elaborate on this topic.
Hopefully we get the Car integration for the powerpanel soon…
You all have a nice day!

I would also love to see this functionality added to the HA energy dashboard. I intend to purchase the Shelly 3EM but would love to know if this is actually considered on the roadmap

Know this is an old thread but has anyone figured out how to add car and get the costs

Here I use the Export in the energy dashboard, and I get the price from the NordPool plugin.

I get the total consumption from an HA Glow (don’t got an smart meter with P1/HAN port) and for the car, I have an LK PowerTag on the relay for the charger.

This way works quite well for me, as I pay flat-rate for the power I’m using at home for my car.

So I get something like this

yes, the “basic” measurement is pretty simple - since EV charging is either grid import - or it comes from your solar power.

This is how I have it done atm:

EV Charging - mostly from Solar production…

EV Charger listed in single devices:

But: I think, it would be great if the Car could be added as a specific device - like a house battery.
The major difference here is, that you can load your house-battery - and later unload it…
That will be shown different in the charge…

It might be a bit difficult to implement it in the chart itself, because somehow the system would require to know, if the energy came from your solar - or from the grid.
If it does not know this, it would show the consumption from your solar (or the grid import) + the charging itself (added on top)

I guess, that could be hard to differenciate and will cause major complains from the community - even more, if the charging will be done by SOLAR + IMPORT

BUT:
having a dedicated information in this area, as already requested somewhere (I don’t remember, if it was in this topic, or another FR)
grafik

That would be nice… at least, it could be shown how much energy you have put in your car - but it could probably not show from what source it was…

1 Like

Is there anything we can do to get this properly done in the Energy Dashboard? I tried a WTH and another tried this but it doesn’t seem to get any traction. My feeling is that with a little development on the HA side this could be a great feature, especially in managing the optimum time for charging and getting a grip on your costs. Any thoughts?

2 Likes

You can also create a dummy value with a template sensor:

- template:
  - sensor:
    - name: "Battery unload dummy"
      unique_id: battery_unload_dummy
      unit_of_measurement: "kWh"
      device_class: energy
      state_class: total
      state: "{{0.0|float}}"
2 Likes

hm… I had another thought about this topic…

I think, there are different approaches and cases that should be considered when discussing the integration of an EV into the energy dashboard, because there are some edge-cases that can happen compared to a house-battery…

Housebattery:
most probably a single device (or two) bind to the household that can be charged - and discharged.

EV:

  • Amount of “n” Cars possible.
  • Battery charging → by solar or grid import
  • Battery discharging → by driving, not used for HouseConsumption
  • Battery discharging → by HouseConsumption if “vehicle to grid” will be available (depending on your location, etc.)
  • Measurements can come from the EV or from the Charging-Station or from a Shelly…
  • EV can be charged everywhere else ( → can be difficult to measure in combination with vehicle to grid, for example)

Also, in addition to that:
Since charging your EV is already part of your house consumption (total) it is already included within the graph.
The only way to get “proper” information is to add the device (charging station) as single device…

But then, it will not be possible to configure when vehicle to grid" will be available…

I think, since there are so many different options this is something that won’t be possible as a general
implementation… The solution with powercalc or whatever might work in some (maybe most) cases as of today… but I really see a high risk of implementing such things today - when there are certain things that are yet unknown… and might be change drastically in the next 2 years maybe?`

2 Likes

Another vote. Would be nice to have it separately on the energy dashboard.

2 Likes

Another consideration with electric cars: Has anyone found a good way to only report charging (ie energy consumption) when the car is “home”? I haven’t figured out how to accomplish this yet: When i charge my car somewhere other than at home, that energy usage still shows up on the Energy Dashboard, which incorrectly implies I consumed that energy from my home, rather than elsewhere (public charger, work charger, friends house, etc).

Perhaps there’s a way to use a Helper or Template to say something to the effect of “if vehicleLocation !=‘home’ ignore energy usage”. Or, even better, put that usage in a different bucket, where one could track both charging usage at home, vs “other”.

Not what you asked for but I use a shelly 3em. This way also the charging losses are monitored. My car only shows “power added”…

It seems you use the car integration to measure this. If you use a separate meter mounted before your charging point (i used one like this: Energy meter Conrad and connected the pulse line to my Youless P1 sensor. Now I can see how much I use for the car and substract is from my total usage to see what my home energy usage will be. The result looks like this:

ha-car

Hi, yes that’s correct, I’m using the car integration. So the challenge is, the integration reports the charge activity regardless of the cars’ physical location. Any tricks to scope in some logic to that, or is that just a limitation at the moment?

That would be possible by constructing some kind of template sensor that gets updated when your car reports charging at the home location. As far as I know, HA does not offer service calls to update template sensor values and attributes. That is why I use the variable custom integration.

Here is an example of the definition of such a variable sensor (to be added to configuration.yaml)

var:
  car_power_consumption:
    unique_id: a8509780-d26c-45ca-971c-ab0b3fabf501
    friendly_name: Car Power Consumption
    unit_of_measurement: 'kWh'
    icon: mdi:car-electric
    restore: true
    initial_value: 0
    attributes:
      version: "1.0"
      cycle_active: false           # cycle still active true/false
      cycle_started: 01-01-2022 00:00  # date-time this cycle started    
      cycle_charged: 0              # amount charged this cycle
      cycle_start_value: 0          # used to calculate more precise 
      cycle_start_capacity: 0       # battery capacity at start of cycle
      battery_total_capacity: 40    # max battery capacity in kWh  (set this according to your car)

I made an example automation that can be used to make this roll as shown below. As I don’t know your cars sensors, it is based on the assumption that you have these sensors available (replace them with yours). You can then use that as an imput sensor for your energy dashboard as described in this topic.

  • binary_sensor.mycar_chargestate (‘on’ when the car is charging)
  • sensor.mycar_battery (percentage battery full)
  • tracker.mycar (car location and returns ‘home’ when car is at home )

example automation:

- id: '1acf296d-5024-46c4-9e02-71b2208f04f5'
  alias: car_power_update
  mode: restart
  trigger:
  - platform: time_pattern
    minutes: /1                     # update once a minute when charging
  - platform: state
    entity_id: binary_sensor.mycar_chargestate
    id: charging

  # Only actions when neccessary
  condition: 
  - condition: template
    value_template: >-
      {{ states("tracker.mycar") == "home" or
         state_attr("var.car_power_consumption","cycle_active") == true }}

  action:
  - if:
      # start or stop charing cycle
      - condition: trigger
        id: charging
    then:
      - if:
          # New charge cycle
          - condition: template
            value_template: >-
              {{ states("binary_sensor.mycar_chargestate") == "on" and
                 state_attr("var.car_power_consumption","cycle_active") == false }}
        then:
          - service: var.set
            data:
              entity_id: var.car_power_consumption
              attributes:
                cycle_active: true
                cycle_started: >-
                  {{ now() }}
                cycle_start_value: >-
                  {{ states("var.car_power_consumption") | int(0) }}
                cycle_charged: 0
                cycle_start_capacity: >-
                  {{ states("sensor.mycar_battery") | int(0) }}
        else:           
          # Stop charge cycle
          - service: var.set
            data:
              entity_id: var.car_power_consumption
              attributes:
                cycle_active: false

  # update power usage value
  - condition: template
      value_template: >-
        {{ state_attr("var.car_power_consumption","cycle_active") == true }}
  - service: var.set
    data:
      entity_id: var.car_power_consumption
      value: >-
          {%  set charged = states("sensor.mycar_battery") |float(0) -
                state_attr("var.car_power_consumption","cycle_start_capacity") |float(0) *
                (state_attr("var.car_power_consumption","battery_total_capacity") |float(0) /100) 
           %}
          {{ state_attr("var.car_power_consumption","cycle_start_value") |float(0) + charged }}  

Another bump, very interesting since I have added my ev also to ha. Can we get this to the dev attention?

Bumpy Bump!

I’d really be interested in this as well.

Bumpidibump … it is 2023, so everyone is having PV and a battery and an EV :laughing:

Aren’t you using evcc to control your wallbox? I added some MQTT sensors to get detailed charging information back from evcc:

mqtt:
  sensor:
    - name: Vehicle Charge Power
      icon: mdi:ev-station
      state_topic: "evcc/loadpoints/1/chargePower"
      unit_of_measurement: W

Doing a lil bit of archeology by bringing this up but i’d really appreciate if this feature was implemented with EV specific calculations.

Meanwhile, the workaround to put the car in the battery section seems to work fine.

About EV considerations, if you have a smart charging station at home, the work is easier as you get all the entities needed. I have a Wallbox Pulsar (integrated with the wallbox integration) which gives me added and discharged energy.
So with such a charging station, integrating as a battery system can be reliable, even if you vehicle has V2L, V2H or V2G capability.

nice to see I am not the only one with that wish! My EV charging is destroying the whole purpose of that Energy dashboard. All bars look really small in comparisson to when the EV was plugged in