Hello. This is mine :
Where :
“e208_clim” can turn on or off if you heat the car with appli.
“Alimentation” icon show if it’s slow or fast, and charge icon show status (play, stop, pause/delay etc)
“Fin de charge estimée” show an ETA of charge (need to try)
“Risque de gel” must be a part of a futur automation to heat the car in case of night frost.
And i try to make a two-way graphical history with autonomy and reality (just finish, so need to try too).
Configuration :
Basic sensor
sensor PSA:
- platform: rest
resource_template: http://[IP]:5000/get_vehicleinfo/[VIN]?from_cache=1
scan_interval: 60
timeout: 30
verify_ssl: false
name: PSA
device_class: timestamp
value_template: "{{ value_json.energy[0].updated_at }}"
json_attributes:
- energy
- kinetic
- timed_odometer
- last_position
- preconditionning
Sensor, switch, automation...
template:
binary_sensor:
- name: e208 Alimentation
unique_id: c5f46109-4cda-49b2-8c11-2a6b5d233aae
state: >-
{{ state_attr('sensor.psa', 'energy')[0].charging.plugged }}
device_class: connectivity
icon: >-
{% if state_attr('sensor.psa', 'energy')[0].charging.plugged %}
{% if state_attr('sensor.psa', 'energy')[0].charging.charging_mode == 'Slow' %}
mdi:ev-plug-type2
{% elif state_attr('sensor.psa', 'energy')[0].charging.charging_mode == 'Quick' %}
mdi:ev-plug-ccs2
{% endif %}
{% else %}
mdi:power-plug-off-outline
{% endif %}
- name: e208 Déplacement
unique_id: dc7f3ff8-ad77-42d4-8523-ddec9dc821e0
state: >-
{{ state_attr('sensor.psa', 'kinetic').moving }}
device_class: moving
attributes:
latitude: "{{ state_attr('sensor.psa', 'last_position').geometry.coordinates[1] }}"
longitude: "{{ state_attr('sensor.psa', 'last_position').geometry.coordinates[0] }}"
sensor:
- name: e208 Charge
unique_id: 8fbe0b19-447e-4e0b-b1c9-2d855437e63f
state: >-
{% set value = state_attr('sensor.psa', 'energy')[0].charging.status %}
{% if value == 'Failure' %}
Defaut
{% elif value == 'InProgress' %}
En charge
{% elif value == 'Stopped' %}
Pause
{% elif value == 'Finished' %}
Terminé
{% elif value == 'Disconnected' %}
Déconnecté
{% else %}
Inconnu
{% endif %}
icon: >-
{% set value = state_attr('sensor.psa', 'energy')[0].charging.status %}
{% if value == 'Failure' %}
mdi:alert
{% elif value == 'InProgress' %}
mdi:play
{% elif value == 'Stopped' %}
mdi:pause
{% elif value == 'Finished' %}
mdi:stop
{% else %}
mdi:power-plug-off-outline
{% endif %}
- name: e208 Batterie
unique_id: acf1f4f5-4180-43ba-9d1c-feb978f6b1eb
state: >-
{{ state_attr('sensor.psa', 'energy')[0].level }}
unit_of_measurement: "%"
device_class: battery
- name: e208 Kilometrage
unique_id: 4fe63f50-67f8-45f7-b148-e1f5554a85c9
state: >-
{{ state_attr('sensor.psa', 'timed_odometer').mileage }}
unit_of_measurement: "Km"
icon: 'mdi:road-variant'
- name: e208 Autonomie
unique_id: 0016a6a1-fed5-4a41-abb3-b1d6ca54bbab
state: >-
{{ state_attr('sensor.psa', 'energy')[0].autonomy }}
unit_of_measurement: "Km"
icon: 'mdi:map-marker-distance'
- name: e208 Pré-conditionnement Defaut
unique_id: a78793bf-1c13-4281-bf9f-d4abaed72d2f
state: >-
{% set value = state_attr('sensor.psa', 'preconditionning').failure_cause %}
{% if value == 'Defect' %}
Defectueux
{% elif value == 'DoorOpened' %}
Porte ouverte
{% elif value == 'LowBattery' %}
Batterie faible
{% elif value == 'LowFuelLevel' %}
Plus d'essence
{% elif value == 'TooManyUnusedProg' %}
Erreur de programmation
{% else %}
Inconnu
{% endif %}
icon: >-
{% set value = state_attr('sensor.psa', 'preconditionning').failure_cause %}
{% if value == 'Defect' %}
mdi:information
{% elif value == 'DoorOpened' %}
mdi:information
{% elif value == 'LowBattery' %}
mdi:information
{% elif value == 'LowFuelLevel' %}
mdi:information
{% elif value == 'TooManyUnusedProg' %}
mdi:information
{% else %}
mdi:information-off
{% endif %}
- name: e208 Pré-conditionnement
unique_id: b7c7350c-32ba-495a-aff0-7b88c2a134d5
state: >-
{{ state_attr('sensor.psa', 'preconditionning').air_conditioning.status }}
- name: e208 Puissance de charge
unique_id: e30a2bf6-3211-4859-abf1-17aa5f132ba6
state: >-
{{ state_attr('sensor.psa', 'energy')[0].charging.charging_rate * 0.163 }}
unit_of_measurement: "kWh"
icon: mdi:speedometer
############################################################################################################
- name: e208 Parcouru
unique_id: 7348f2e2-851f-4dc3-890f-4c73f571fb7e
state: >-
{% if is_state('binary_sensor.e208_alimentation', 'on') %}
{{ states('sensor.e208_autonomie') }}
{% else %}
{{ (states('sensor.e208_parcouru')) - (states('sensor.e208_kilometrage') - state_attr('sensor.beta_test_timestamp', 'km')) }}
{% endif %}
attributes:
km: >
{% if is_state('binary_sensor.e208_alimentation', 'on') %}
{{ states('sensor.e208_kilometrage') }}
{% else %}
{{ state_attr('sensor.e208_parcouru', 'km') }}
{% endif %}
unit_of_measurement: "Km"
icon: 'mdi:map-marker-right'
############################################################################################################
- name: e208 Fin de charge estimée
unique_id: c249f813-62dc-474d-bb9f-f94220636f87
state: >-
{% set value = state_attr('sensor.psa', 'energy')[0].charging.status %}
{% if value == 'InProgress' %}
{% set value = state_attr('sensor.psa', 'energy')[0].charging.remaining_time %}
{% if value.find("H") > 0 %}
{% set hr = value[value.find("T")+1:value.find("T")+ 3] %}
{% if hr[1:2] == "H" %}
{% set hr = "0" + hr[0] %}
{% endif %}
{% else %}
{% set hr = "00" %}
{% endif %}
{% if value.find("M") > 0 %}
{% set mn = value[value.find("M")-2:value.find("M")] %}
{% if mn[0:1] == "H" or mn[0:1] == "T" %}
{% set mn = "0" + mn[1] %}
{% endif %}
{% else %}
{% set mn = "00" %}
{% endif %}
{% set result = hr + ":" + mn %}
{% if result == "00:00" %}
{{ result }}
{% else %}
{{ as_datetime((now() + timedelta( hours = int(hr), minutes = int(mn) )).isoformat()).strftime("%H:%M") }}
{% endif %}
{% else %}
Déconnecté
{% endif %}
icon: "mdi:timer-outline"
automation:
- id: "63a2f136-91ad-4fb7-8f75-0644db525be5"
alias: "e208 GPS Tracking"
trigger:
- platform: state
entity_id: binary_sensor.e208_deplacement
attribute: latitude
- platform: state
entity_id: binary_sensor.e208_deplacement
attribute: longitude
condition: []
action:
- service: device_tracker.see
data:
dev_id: "e208"
battery: "{{ state_attr('sensor.psa', 'energy')[0].level }}"
gps:
- "{{ state_attr('sensor.psa', 'last_position').geometry.coordinates[1] }}"
- "{{ state_attr('sensor.psa', 'last_position').geometry.coordinates[0] }}"
switch:
- platform: command_line
switches:
e208_clim:
command_on: curl -s "http://[IP]:5000/preconditioning/[VIN]/1"
command_off: curl -s "http://[IP]:5000/preconditioning/[VIN]/0"
command_state: 'curl -k --silent "http://[IP]:5000/get_vehicleinfo/[VIN]?from_cache=1"'
value_template: >
{{ value_json.preconditionning.air_conditioning.status == 'Enabled' }}
icon_template: >-
{% set value = value_json.preconditionning.air_conditioning.status %}
{% set switch = states('switch.e208_clim') %}
{% if value == 'Enabled' %}
mdi:car-defrost-front
{% elif value == 'Disabled' or value == 'Finished' %}
mdi:air-conditioner
{% else %}
mdi:alert
{% endif %}
command_timeout: 180
rest_command:
maj:
url: http://[IP]:5000/wakeup/[VIN]
script:
e208_maj:
alias: e208 Rafraichir
sequence:
- data: {}
service: rest_command.maj
Lovelace
- title: '208'
path: '208'
icon: mdi:car-sports
badges: []
cards:
- type: vertical-stack
cards:
- type: picture
image: /local/images/e208.png
tap_action:
action: none
hold_action:
action: none
- type: glance
entities:
- entity: sensor.e208_kilometrage
- entity: binary_sensor.e208_deplacement
- entity: sensor.e208_autonomie
show_name: true
state_color: true
- type: entities
entities:
- entity: sensor.entree_frostrisk
- entity: switch.e208_clim
secondary_info: last-updated
- entity: sensor.e208_pre_conditionnement_defaut
- entity: script.e208_maj
- entity: sensor.release_psa
- type: map
entities:
- entity: zone.home
- entity: zone.travail_benjamin
- entity: zone.travail_celine
- entity: device_tracker.e208
hours_to_show: 18
- type: vertical-stack
cards:
- type: gauge
entity: sensor.e208_batterie
min: 0
max: 100
- type: glance
entities:
- entity: binary_sensor.e208_alimentation
- entity: sensor.e208_charge
- entity: sensor.e208_puissance_de_charge
state_color: true
show_name: true
- type: entities
entities:
- entity: sensor.e208_temps_restant_de_charge
- type: history-graph
entities:
- entity: sensor.e208_parcouru
- entity: sensor.e208_autonomie
hours_to_show: 24
refresh_interval: 0