mqtt:
  lock:
    - name: jaffa_locked
      unique_id: uniqueid__jaffa_locked
      state_topic: "weconnect/0/vehicles/WVGZZZE2ZPE051949/domains/access/accessStatus/doorLockStatus"
      command_topic: "weconnect/0/vehicles/WVGZZZE2ZPE051949/controls/access"
      payload_lock: "locked"
      payload_unlock: "unlocked"
      device:
        identifiers: jaffa

  sensor:
    - name: jaffa_long
      unique_id: uniqueid__jaffa_long
      state_topic: "weconnect/0/vehicles/WVGZZZE2ZPE051949/parking/parkingPosition/longitude"
      unit_of_measurement: °
      entity_category: diagnostic
      device:
        identifiers: jaffa

    - name: jaffa_lat
      unique_id: uniqueid__jaffa_lat
      state_topic: "weconnect/0/vehicles/WVGZZZE2ZPE051949/parking/parkingPosition/latitude"
      unit_of_measurement: °
      entity_category: diagnostic
      device:
        identifiers: jaffa

    - name: jaffa_parikingtime
      unique_id: uniqueid__jaffa_parikingtime
      state_topic: "weconnect/0/vehicles/WVGZZZE2ZPE051949/parking/parkingPosition/carCapturedTimestamp"
      value_template: "{{ as_datetime(value) }}"
      device_class: "timestamp"
      entity_category: diagnostic
      device:
        identifiers: jaffa

    - name: jaffa_battery_soc
      unique_id: uniqueid__jaffa_battery_soc
      state_topic: "weconnect/0/vehicles/WVGZZZE2ZPE051949/domains/charging/batteryStatus/currentSOC_pct"
      unit_of_measurement: "%"
      device_class: battery
      device:
        identifiers: jaffa

    - name: jaffa_battery_target_soc
      unique_id: uniqueid_jjaffa_battery_target_soc
      state_topic: "weconnect/0/vehicles/WVGZZZE2ZPE051949/domains/charging/chargingSettings/targetSOC_pct"
      unit_of_measurement: "%"
      device_class: battery
      device:
        identifiers: jaffa
        
    - name: jaffa_rated_battery_range_km
      unique_id: jaffa_rated_battery_range_km
      state_topic: "weconnect/0/vehicles/WVGZZZE2ZPE051949/domains/charging/batteryStatus/cruisingRangeElectric_km"
      unit_of_measurement: km
      device_class: distance
      device:
        identifiers: jaffa

    - name: jaffa_odometer
      unique_id: jaffa_odometer
      state_topic: "weconnect/0/vehicles/WVGZZZE2ZPE051949/domains/measurements/odometerStatus/odometer"
      unit_of_measurement: km
      device_class: distance
      device:
        identifiers: jaffa

    - name: jaffa_charge_mode
      unique_id: jaffa_charge_mode
      state_topic: "weconnect/0/vehicles/WVGZZZE2ZPE051949/domains/charging/chargingStatus/chargeMode"
      device_class: enum
      value_template: >
        {% set mapper = {
          '0': 'manual',
          '1': 'timer',
          '2': 'onlyOwnCurrent',
          '3': 'preferredChargingTimes',
          '4': 'timerChargingWithClimatisation',
          '5': 'invalid'
        } %}
        {{ mapper.get(value, 'Unknown') }}
      device:
        identifiers: jaffa
