I use Norwegian company Tibber as my electricity provider, which gives me realtime information about power usage, but also the current electricity price.
I want to make a template sensor that shows me the following:
Current charging expenses while my Tesla is charging
Amount of electricity used during current current charge
Accumulated charging expenses for all charges
Accumulated electricity used for all charges
I want to have a dashboard that shows me the price of last charge as well as amount of electricity (kWh) that was consumed.
The counters for charge price and consumed electricity should reset each time the car charges. (There is a switch for this).
I didnât manage to solve it in Home Assistant directly, as I discovered a system called TeslaMate.
TeslaMate runs as a docker container, connected to a PostgreSQL database and Grafana to show the statistics. It also has MQTT client implemented, so it can send MQTT messages to Home Assistant, letting me show the data in Home Assistant.
Iâve put together something similar. I want to track how much Iâm paying for charging at home. I use Tesla Custom Integration and the Energy tracker in the HASS. The kwh data comes from âŚ
Get the charger rate in W.
Convert to kWh.
Use the HASS energy tracker, where you can reference a cost
sensor:
- platform: template
sensors:
tesla_charging_power_home:
device_class: power
friendly_name: Tesla Charging Power at Home
unit_of_measurement: 'W'
value_template: >
{% if is_state('device_tracker.<car_name>_location_tracker', 'home') and is_state('binary_sensor.<car_name>_ischarging', 'on') %}
{{ state_attr('sensor.<car_name>_charging_rate_sensor', 'charger_power') |float *1000}}
{% else %}
0
{% endif %}
#Tesla Charging Energy kWh (added at Home)
- platform: integration
source: sensor.tesla_charging_power_home
name: tesla_charging_home_kWh
unit_prefix: k
unit_time: h
method: left
round: 2
Youâre correct, if youâre using the binary_sensor entity directly from the integration.
I found that it becomes true even, if car is just plugged in - no power or scheduled to charge later, etc. Doesnât affect it. So I templated the âischargingâ binary_sensor, reading the âchargingâ state from the attripute of the chargerâŚ
i think the issue is that the charging rate sensor : state_attr(âsensor.<car_name>_charging_rate_sensorâ, âcharger_powerâ) do not have a attribute charger_power.â
I use âsensor.hamster_charger_powerâ isstead. But not yet testet.