Peugeot Citroen DS cars - Connected Car

Hello,

Same problem :frowning:, the IP is 0.0.0.0, where can i configure that please ?
I change the port with 5000 but i have the same problem

Containerised psa_car_controller loading...
2021-11-29 11:01:36,382 :: WARNING :: Can't get language
2021-11-29 11:01:44,785 :: INFO :: update_data
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

I don’t know why :frowning:

Thanks for help

I’m running on RPI 3 with Home Assistant (lastest version, PSA 2.5.6)

Every time a new version is released, the update gives an error so I have to uninstall the old one and install the new one. this procedure causes all data to be lost. How can this be avoided?

No SMS is no error of the addin, but from PSA OR your in app used phone number.

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…