Created
April 30, 2025 13:21
-
-
Save developerfromjokela/827c33ca4c3bc283f33a5d4f0ab91a9b to your computer and use it in GitHub Desktop.
OpenCARWINGS Home Assistant template, add this to yoru configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template: | |
- binary_sensor: | |
- name: "EV Charging" | |
unique_id: ev_charging | |
device_class: battery_charging | |
state: > | |
{{ state_attr('sensor.ev_raw_data', 'ev_info').charging }} | |
- name: "EV Quick Charging" | |
unique_id: ev_qc_charging | |
device_class: battery_charging | |
state: > | |
{{ state_attr('sensor.ev_raw_data', 'ev_info').quick_charging }} | |
- name: "EV A/C" | |
unique_id: ev_ac | |
state: > | |
{{ state_attr('sensor.ev_raw_data', 'ev_info').ac_status }} | |
- name: "Leaf EV Car Running" | |
unique_id: leaf_ev_car_running | |
state: > | |
{{ state_attr('sensor.ev_raw_data', 'ev_info').car_running }} | |
- name: "Leaf EV Car Driving" | |
unique_id: leaf_ev_car_driving | |
state: > | |
{{ state_attr('sensor.ev_raw_data', 'ev_info').car_gear != 0 }} | |
- binary_sensor: | |
- name: "EV Plugged In" | |
unique_id: leaf_ev_plugged_in | |
device_class: plug | |
state: > | |
{{ state_attr('sensor.ev_raw_data', 'ev_info').plugged_in }} | |
sensor: | |
- platform: template | |
sensors: | |
ev_full_charge_time: | |
friendly_name: "EV 240V/3.6kW charging time" | |
value_template: > | |
{% set minutes = state_attr('sensor.ev_raw_data', 'ev_info').full_chg_time | int %} | |
{% if minutes in [2047, 4095] %} | |
unknown | |
{% else %} | |
{{ (minutes / 60) | round(1) }} | |
{% endif %} | |
unit_of_measurement: "h" | |
device_class: duration | |
# Limit Charge Time | |
ev_limit_charge_time: | |
friendly_name: "EV 120V charging time" | |
value_template: > | |
{% set minutes = state_attr('sensor.ev_raw_data', 'ev_info').limit_chg_time | int %} | |
{% if minutes in [2047, 4095] %} | |
unknown | |
{% else %} | |
{{ (minutes / 60) | round(1) }} | |
{% endif %} | |
unit_of_measurement: "h" | |
device_class: duration | |
# OBC 6kW (On-Board Charger) | |
ev_obc_6kw: | |
friendly_name: "EV 6kW Charge Time" | |
value_template: > | |
{% set minutes = state_attr('sensor.ev_raw_data', 'ev_info').obc_6kw | int %} | |
{% if minutes in [2047, 4095] %} | |
unknown | |
{% else %} | |
{{ (minutes / 60) | round(1) }} | |
{% endif %} | |
unit_of_measurement: "h" | |
device_class: duration | |
leaf_ev_soc: | |
friendly_name: "EV State of Charge" | |
value_template: "{{ state_attr('sensor.ev_raw_data', 'ev_info').soc | float | round(1) }}" | |
unit_of_measurement: "%" | |
device_class: battery | |
# SoC Display (alternative SoC value) | |
leaf_ev_soc_display: | |
friendly_name: "EV SoC Display" | |
value_template: "{{ state_attr('sensor.ev_raw_data', 'ev_info').soc_display | float | round(1) }}" | |
unit_of_measurement: "%" | |
device_class: battery | |
# Range with A/C On | |
leaf_ev_range_acon: | |
friendly_name: "EV Range (A/C On)" | |
value_template: "{{ state_attr('sensor.ev_raw_data', 'ev_info').range_acon | int }}" | |
unit_of_measurement: "km" | |
device_class: distance | |
# Range with A/C Off | |
leaf_ev_range_acoff: | |
friendly_name: "EV Range (A/C Off)" | |
value_template: "{{ state_attr('sensor.ev_raw_data', 'ev_info').range_acoff | int }}" | |
unit_of_measurement: "km" | |
device_class: distance | |
# State of Health (SoH) | |
leaf_ev_soh: | |
friendly_name: "EV State of Health" | |
value_template: "{{ state_attr('sensor.ev_raw_data', 'ev_info').soh | int }}" | |
unit_of_measurement: "%" | |
device_class: battery | |
# Battery Capacity (Wh Content) | |
leaf_ev_battery_capacity: | |
friendly_name: "EV Battery Capacity" | |
value_template: "{{ state_attr('sensor.ev_raw_data', 'ev_info').wh_content | float | round(0) }}" | |
unit_of_measurement: "Wh" | |
device_class: energy | |
# Charge Bars | |
leaf_ev_charge_bars: | |
friendly_name: "EV Charge Bars" | |
value_template: "{{ state_attr('sensor.ev_raw_data', 'ev_info').charge_bars | int }}" | |
unit_of_measurement: "bars" | |
# Charge Bars | |
leaf_ev_cap_bars: | |
friendly_name: "EV Capacity Bars" | |
value_template: "{{ state_attr('sensor.ev_raw_data', 'ev_info').cap_bars | int }}" | |
unit_of_measurement: "bars" | |
leaf_ev_gids: | |
friendly_name: "EV GIDs" | |
value_template: "{{ state_attr('sensor.ev_raw_data', 'ev_info').gids | int }}" | |
device_class: energy | |
unit_of_measurement: "GID" | |
rest: | |
- resource: "https://opencarwings.viaaq.eu/api/car/<vin>/" # Replace with your actual VIN and server | |
scan_interval: 30 | |
method: GET | |
headers: | |
Authorization: "Token <token>" | |
sensor: | |
- name: "EV Raw Data" | |
value_template: "1" | |
json_attributes: | |
- ev_info | |
- location | |
- vin | |
- nickname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment