Peugeot Citroen DS cars - Connected Car

There is no IP to configure. This is the IP the addin listens on and 0.0.0.0 means ALL IPs! You need the IP of the device you run that on. And before you tell next that the IP of your device and port 5000 does not work… Re read the last 30 posts here and check your addin settings. ^^

I read all post but i don’t understand … :frowning: , ok 0.0.0.0 it’s the loopback
The interface of PSA running, i can add my peugeot information but when i submit, either the module crash or i have errors :

Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/urllib3/connection.py", line 174

Yes ! With the last version (2.6.0), the add-on works ! Nice job !

Now i have another problem :frowning: , i wan’t to use in lovelace, i try this GitHub - Flodu31/HomeAssistant-PeugeotIntegration: Integration between Peugeot API and Home Assistant

But all is indisponible

When i send that command i need error : curl http://192.168.1.4:5000/get_vehicleinfo/XXX
XXX = my vin

Connection refused :frowning:

Did you set port 5000 in the addin settings?

No :confused:, sorry, it’s ok ! Thanks :hugs:

1 Like

So, after a while I added a few funny things to my integration:

Prequesites in HACS:
Install “Time Picker Card” and “Number Box” under Frontend for my tinkering to work.

Yes, all my names are german and NO I will not change that for you to english. Feel free to change it yourself though.
If you have any questions, tell me.

Lovelace:

      - type: entities
        entities:
          - entity: device_tracker.car
          - entity: sensor.e208_mileage
            secondary_info: last-updated
          - entity: sensor.e208_battery_level
            secondary_info: last-updated
          - entity: sensor.e208_battery_voltage
            secondary_info: last-updated
          - entity: sensor.e208_battery_autonomy
            secondary_info: last-updated
          - entity: sensor.e208_charging_status
            secondary_info: last-updated
          - entity: sensor.e208_charging_mode
            secondary_info: last-updated
          - entity: sensor.e208_charging_rate
            secondary_info: last-updated
          - entity: sensor.e208_charging_rate_kwh
            secondary_info: last-updated
          - entity: sensor.e208_charging_plugged
            secondary_info: last-updated
          - entity: sensor.e208_delay_start
            secondary_info: last-updated
          - entity: sensor.e208_remain_time
            secondary_info: last-updated
          - entity: sensor.e208_signal_quality
            secondary_info: last-updated
          - entity: input_number.charge_threshold
            type: custom:numberbox-card
            unit: '%'
            delay: 3000
            icon: mdi:battery
          - entity: sensor.e208_threshold
            secondary_info: last-updated
          - entity: input_datetime.charge_time
            type: custom:time-picker-card
            layout:
              name: inside
              align_controls: right
              embedded: true
          - entity: sensor.e208_stop_time
            secondary_info: last-updated
          - entity: switch.e208_clim
            name: Klima aktivieren
            secondary_info: last-triggered
          - entity: automation.wakeup_e208
            secondary_info: last-triggered
        title: Peugeot e208
        header:
          type: picture
          image: /local/208.png
          tap_action:
            action: none
          hold_action:
            action: none
        show_header_toggle: false
        state_color: false
      - type: gauge
        entity: sensor.e208_battery_level
        min: 0
        max: 100
        name: Peugeot e208 Batterie
        severity:
          green: 60
          yellow: 40
          red: 0
        needle: true

configuration.yaml

input_number:
  charge_threshold:
    name: 'Ladelimit'
    min: 50
    max: 100
    step: 1

input_datetime:
  charge_time:
    name: 'Ladestop'
    has_date: false
    has_time: true

sensor:
  - platform: rest
    name: 'peugeot_e208'
    resource: http://192.168.181.42:5000/get_vehicleinfo/YOURVINGOESHERE?from_cache=1
    scan_interval: 60
    timeout: 30
    value_template: 'OK'
    json_attributes:
     - energy
     - timed_odometer
     - battery
     - last_position
  - platform: rest
    name: 'peugeot_e208_charge_control'
    resource: http://192.168.181.42:5000/charge_control?vin=YOURVINGOESHERE&?always_check=true
    scan_interval: 60
    timeout: 30
    value_template: 'OK'
    json_attributes:
     - _next_stop_hour
     - percentage_threshold
  - platform: template
    sensors:
      e208_battery_voltage:
        friendly_name: "Batterie Spannung"
        device_class: "voltage"
        unit_of_measurement: "V"
        value_template: "{{ state_attr('sensor.peugeot_e208', 'battery')['voltage'] * 4 }}"
      e208_battery_level:
        friendly_name: "Batterie"
        device_class: "battery"
        unit_of_measurement: "%"
        value_template: "{{ state_attr('sensor.peugeot_e208', 'energy')[0]['level'] }}"
      e208_battery_autonomy:
        friendly_name: "Autonomie"
        icon_template: "mdi:road-variant"
        unit_of_measurement: "km"
        value_template: "{{ state_attr('sensor.peugeot_e208', 'energy')[0]['autonomy'] }}"
      e208_charging_mode:
        friendly_name: "Lademodus"
        icon_template: "mdi:ev-station"
        value_template: "{{ state_attr('sensor.peugeot_e208', 'energy')[0]['charging']['charging_mode'] }}"
      e208_charging_rate:
        friendly_name: "Laderate"
        icon_template: "mdi:lightning-bolt"
        unit_of_measurement: "km/h"
        value_template: "{{ state_attr('sensor.peugeot_e208', 'energy')[0]['charging']['charging_rate'] }}"
      e208_charging_rate_kwh:
        friendly_name: "Laderate"
        unit_of_measurement: "kWh"
        device_class: "energy"
        value_template: "{{ state_attr('sensor.peugeot_e208', 'energy')[0]['charging']['charging_rate'] * 0.163 }}"
      e208_charging_plugged:
        friendly_name: "Ladegerät Eingesteckt"
        icon_template: "mdi:ev-plug-type2"
        value_template: "{{ state_attr('sensor.peugeot_e208', 'energy')[0]['charging']['plugged'] }}"
      e208_charging_status:
        friendly_name: "Ladestatus"
        icon_template: "mdi:battery-charging"
        value_template: "{{ state_attr('sensor.peugeot_e208', 'energy')[0]['charging']['status'] }}"
      e208_mileage:
        friendly_name: "Kilometerstand"
        icon_template: "mdi:speedometer"
        unit_of_measurement: "km"
        value_template: "{{ state_attr('sensor.peugeot_e208', 'timed_odometer')['mileage'] }}"
      e208_mapdata:
        friendly_name: "Koordinaten"
        icon_template: "mdi:map-marker"
        value_template: "{{ state_attr('sensor.peugeot_e208', 'last_position')['geometry']['coordinates'] }}"
      e208_signal_quality:
        friendly_name: "Signalstärke"
        icon_template: "mdi:signal-variant"
        value_template: "{{ state_attr('sensor.peugeot_e208', 'last_position')['properties']['signal_quality'] }}"
      e208_stop_time:
        friendly_name: "Ladestop"
        value_template: "{{ state_attr('sensor.peugeot_e208_charge_control', '_next_stop_hour') }}"
      e208_threshold:
        friendly_name: "Ladelimit"
        unit_of_measurement: "%"
        value_template: "{{ state_attr('sensor.peugeot_e208_charge_control', 'percentage_threshold') }}"
      e208_delay_start:
        friendly_name: "Nächster Ladestart"
        icon_template: "mdi:timer"
        value_template: >
          {% set dt = states.sensor.peugeot_e208.attributes["energy"][0]["charging"]["next_delayed_time"] %}
          {% if dt.find("H") > 0 %}
            {% set hr = dt[dt.find("T")+1:dt.find("T")+ 3] %}
            {% if hr[1:2] == "H"  %}
              {% set hr = "0" + hr[0] %}
            {% endif %}
          {% else %}
            {% set hr = "00" %}
          {% endif %}
          {% if dt.find("M") > 0 %}
            {% set mn = dt[dt.find("M")-2:dt.find("M")] %}
            {% if mn[0:1] == "H" or mn[0:1] == "T" %}
              {% set mn = "0" + mn[1] %}
          {% endif %}
          {% else %}
            {% set mn = "00" %}
          {% endif %}
          {% set tm = hr + ":" + mn %}
          {{tm}}
      e208_remain_time:
        friendly_name: "Restladezeit"
        icon_template: "mdi:timer-outline"
        value_template: >
          {% set dt = states.sensor.peugeot_e208.attributes["energy"][0]["charging"]["remaining_time"] %}
          {% if dt.find("H") > 0 %}
            {% set hr = dt[dt.find("T")+1:dt.find("T")+ 3] %}
            {% if hr[1:2] == "H"  %}
              {% set hr = "0" + hr[0] %}
            {% endif %}
          {% else %}
            {% set hr = "00" %}
          {% endif %}
          {% if dt.find("M") > 0 %}
            {% set mn = dt[dt.find("M")-2:dt.find("M")] %}
            {% if mn[0:1] == "H" or mn[0:1] == "T" %}
              {% set mn = "0" + mn[1] %}
          {% endif %}
          {% else %}
            {% set mn = "00" %}
          {% endif %}
          {% set tm = hr + ":" + mn %}
          {{tm}}

switch:
  - platform: command_line
    switches:
      e208_clim:
        command_on: curl -s "http://192.168.181.42:5000/preconditioning/YOURVINGOESHERE/1"
        command_off: curl -s "http://192.168.181.42:5000/preconditioning/YOURVINGOESHERE/0"

rest_command:
  e208_wakeup:
    url: "http://192.168.181.42:5000/wakeup/YOURVINGOESHERE"
  e208_change_threshold:
    url: "http://192.168.181.42:5000/charge_control?vin=YOURVINGOESHERE&percentage={{ states('input_number.charge_threshold') | int }}"
  e208_change_charge_time:
    url: "http://192.168.181.42:5000/charge_control?vin=YOURVINGOESHERE&hour={{ state_attr('input_datetime.charge_time','timestamp') | timestamp_custom('%H', False) }}&minute={{ state_attr('input_datetime.charge_time','timestamp') | timestamp_custom('%M', False) }}"

automations.yaml

- id: car_track
  alias: Tracker Car
  trigger:
  - entity_id: sensor.e208_mapdata
    platform: state
  - event: start
    platform: homeassistant
  action:
  - data:
      dev_id: car
      battery: '{{states.sensor.e208_battery_level.state}}'
      gps_accuracy: '25'
      gps:
      - '{{ (state_attr("sensor.peugeot_e208", "last_position")["geometry"]["coordinates"][1]) }}'
      - '{{ (state_attr("sensor.peugeot_e208", "last_position")["geometry"]["coordinates"][0]) }}'
    service: device_tracker.see
  mode: single
- id: e208_wakeup
  alias: Auto WakeUp e-208
  description: ''
  trigger:
    - platform: time_pattern
      hours: '/1'
  condition: []
  action:
  - service: rest_command.e208_wakeup
  mode: single
- id: car_threshold_change
  alias: Car threshold change
  trigger:
  - platform: state
    entity_id: input_number.charge_threshold
  condition: []
  action:
  - service: rest_command.e208_change_threshold
  mode: single
- id: car_chargetime_change
  alias: Car chargetime change
  trigger:
  - platform: state
    entity_id: input_datetime.charge_time
  condition: []
  action:
  - delay:
      seconds: 3
  - service: rest_command.e208_change_charge_time
  mode: single

known_devices.yaml

car:
  name: Mein 208e
  icon: mdi:car-hatchback
  picture: /local/peugeot.png
  track: true

P.S. YES, my car tracking works again. Why? I registered on PSA/Stellantis’ own non-free Free2Charge service and three days later the feature worked again. No this was not found out by me, but I verified it works that way. The real gods can be found here: "kinetic" and "last_position" fields are empty · Issue #50 · flobz/psa_car_controller · GitHub

P.P.S. Yes, I have a charge rate sensor with kwh and not kmh. How? I used some approximation as I know the real kwh from my wallbox. This 0.163 factor is right for me and my car. Maybe not for yours though.

3 Likes

Hello. I am amazed by your work. i tried to replicate your config but i always get errors. can we get in touch? sorry for my english but i am italian

Hello @Daniel_Reimer . I am amazed by your work. i tried to replicate your config but i always get errors. can we get in touch? sorry for my english but i am italian

Well. “Work” ^^ I just threw together some stuff from here and some stuff I already tinkered with for some other integrations. What error? Chatting via Telegram/Whatsapp is possible of course, just write me a PM where I can contact you.

Hello. Thanks for the reply. I’m new but I don’t think I can send any new private messages. Maybe because I registered a few days ago. Can you try to send me a private message?

Hello. First of all I want to thank you for the work you have done putting this together, it has been really helpful. I copied the above and it works perfectly in my environment.

The only thing I am confused about is the charge stop time & charge limit.

When I set these, are they automatically activated by changing the time or slider, or do I need another switch to make these active?

Below is how I have currently set up my dashboard, everything works (activate climate, all dials work) but I previously set the charge limit slider to 75% & the car continued to charge after this value.

1 Like

can you share config an sensor without you personal info? i try daniel set uop but not working. i curiosly

views:
  - title: E208
    badges: []
    cards:
      - type: picture
        tap_action:
          action: call-service
          service: rest_command.e208_wakeup
          service_data: {}
          target: {}
        hold_action:
          action: call-service
          service: hassio.addon_restart
          service_data:
            addon: 0f87cda8_psacc
          target: {}
        image: https://www.evspecifications.com/images/news/640172/additional_0.jpg
      - header:
          type: picture
          image: https://www.evspecifications.com/images/news/640172/main.jpg
          tap_action:
            action: none
          hold_action:
            action: none
        type: entities
        entities:
          - entity: sensor.e208_updated_at
            icon: mdi:update
          - entity: sensor.e208_battery_autonomy
            secondary_info: last-updated
            icon: mdi:car-cruise-control
          - entity: sensor.e208_battery_level
            icon: mdi:battery-charging-wireless
            secondary_info: last-changed
          - entity: sensor.e208_battery_voltage
            icon: mdi:lightning-bolt
          - entity: sensor.e208_charging_plugged
            icon: mdi:power-plug-outline
          - entity: sensor.e208_charging_status
            icon: mdi:car-electric
          - entity: sensor.e208_charging_mode
            icon: mdi:transmission-tower-export
          - entity: sensor.e208_mileage
            icon: mdi:routes
          - entity: switch.e208_clima
            icon: mdi:air-conditioner
            name: 'Aria Condizionata '
          - entity: switch.e208_change_threshold
            name: 'Limita a 79 '
            icon: mdi:car-electric
          - entity: switch.e208_wakeup_switch
      - type: gauge
        entity: sensor.e208_battery_level
        min: 0
        max: 100
        severity:
          green: 60
          yellow: 40
          red: 0
        needle: true
      - type: button
        tap_action:
          action: call-service
          service: hassio.addon_stop
          service_data:
            addon: 0f87cda8_psacc
          target: {}
        icon: mdi:cast-off
        name: Stop Controller
        icon_height: 20px
      - type: button
        tap_action:
          action: call-service
          service: hassio.addon_start
          service_data:
            addon: 0f87cda8_psacc
          target: {}
        icon: mdi:cast-connected
        name: Start Controller
        icon_height: 20px
      - type: glance
        entities:
          - sensor.e208_charging_time
          - sensor.e208_charging_power
          - sensor.e208_threshold
  - badges: []
    cards:
      - type: entities
        entities:
          - switch.e208_change_charge_hour
          - sensor.peugeot_e208
          - sensor.peugeot_e208_charge_control
title: E 208
1 Like

My code is identical to Daniel’s, I have only changed the friendly names into English.

Everything else was just a copy & paste and then it all worked.

The charge limit is more luck than really working. My car for example falls to deep sleep after I start charging and sometimes by luck wakes up in time to stop. This works with a chance of 1:15 if not less… Problem here is that the API does not support that. The addin needs recent information to add the feature by itself.

If you used what I used it should be set active as soon as you change anything on the slider as the two automation track the values and trigger the rest command as soon as there is a change (3 seconds delay is in there if you change it a few times before hitting the spot you want it to be). To disable it you just set the charge limit to 100% or the time to 0:00. If it does not work then I maybe have a lil bug in my mess ^^

Like some of you (@Daniel_Reimer for instance) I’m using a command_line switch to activate/inactivate preconditioning:

switch:
  - platform: command_line
    switches:
      grandland_clim:
        command_on: curl -s "http://IP:5000/preconditioning/VIN/1"
        command_off: curl -s "http://IP:5000/preconditioning/VIN/0"

…which works. It would be great though if the switch could reflect the actual state of the preconditioning, since it always takes a while for the command to be executed. I’ve read about value_template, which i think could solve this. In that case, one could look at the state of the preconditioning “sensor” and set value_template accordingly.

However, I don’t know how to do it. Does anyone else know? I tried this, but it didn’t work…

switch:
  - platform: command_line
    switches:
      grandland_clim:
        command_on: curl -s "http://IP:5000/preconditioning/VIN/1"
        command_off: curl -s "http://IP:5000/preconditioning/VIN/0"
        value_template: >
          {% if states.sensor.opel_grandland_x.attributes["preconditionning"]["air_conditioning"]["status"] == "Enabled" %}
          true
          {% endif %}

Hello. Switch command line work with command line…

I do this :

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 -s "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 %}
          {% if value == 'Enabled' %}
            mdi:play
          {% elif value == 'Disabled' or value == 'Finished' %}
            mdi:air-conditioner
          {% else %}
            mdi:alert
          {% endif %}
        command_timeout: 180

because of time of refresh on primary sensor, switch can turn on, and off, and on before sensor’s update…

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

2 Likes

@limabravo , that worked great for me as well.

Regarding the following

because of time of refresh on primary sensor, switch can turn on, and off, and on before sensor’s update…

…it would be great if the icon_template would be able to show “switch is turned on, but the preconditioning hasn’t started yet”, so that one could see that state as well. Any idea on how to do it? I had a thought that I could add a helper that is controlled by the switch, so that I could use the following conditions (replace the result text with a fitting icon).

if (helper is on AND preconditioning is off)
“started but not running”
else if (helper is on AND preconditioning is on)
“running”
else if (helper is off AND preconditioning is on)
“running from other application” (for example, the preconditioning
is trigged from the app, since the helper isn’t turned on).

Or to be clear, I want to visualize the difference between “switch is pressed but preconditioning isn’t started” and “switch is pressed and preconditioning is started”.

It’s already the case. Icon’s state is different only if préconditionning is enabled or not (whatever switch state).

However, I can’t find a solution to display the switch’s “request” status in addition to the preconditioning status without 3 another entity and automation :frowning: