sensor:

 - platform: command_line
   command: !secret citroen_status
   name: citroen_status
   json_attributes:
    - updatedAt
    - signals
    - location
   value_template: ' '
   scan_interval: 300

 - platform: template
   sensors:
     citroen_bateria:
       friendly_name: 'Citroen Batería'
       value_template: >-
        {% if states.sensor.citroen_status.attributes.signals is defined -%}
          {% for signals in states.sensor.citroen_status.attributes.signals -%}
            {% if signals.name == "BatteryVoltage" %}
              {{ signals.value }}
            {% endif %}
          {%- endfor -%}
        {% else %}
           Recargando.
        {% endif %}
       unit_of_measurement: 'V'     
     citroen_velocidad:
       friendly_name: 'Citroen Velocidad'
       value_template: >-
        {% if states.sensor.citroen_status.attributes.signals is defined -%}
          {% for signals in states.sensor.citroen_status.attributes.signals -%}
            {% if signals.name == "GpsSpeed" %}
              {{ signals.value }}
            {% endif %}
          {%- endfor -%}
        {% else %}
           Recargando.
        {% endif %}
       unit_of_measurement: 'Km/h'
     citroen_combustible:
       friendly_name: 'Citroen Gasolina'
       value_template: >-
        {% if states.sensor.citroen_status.attributes.signals is defined -%}
          {% for signals in states.sensor.citroen_status.attributes.signals -%}
            {% if signals.name == "FuelLevel" %}
              {{ signals.value }}
            {% endif %}
          {%- endfor -%}
        {% else %}
           Recargando.
        {% endif %}
       unit_of_measurement: 'L'
     citroen_kilometros:
       friendly_name: 'Citroen Total Km'
       value_template: >-
        {% if states.sensor.citroen_status.attributes.signals is defined -%}
          {% for signals in states.sensor.citroen_status.attributes.signals -%}
            {% if signals.name == "Odometer" %}
              {{ signals.value }}
            {% endif %}
          {%- endfor -%}
        {% else %}
           Recargando.
        {% endif %}
       unit_of_measurement: 'km'
     citroen_revoluciones:
       friendly_name: 'Citroen Revoluciones por Minuto'
       value_template:  >-
        {% if states.sensor.citroen_status.attributes.signals is defined -%}
          {% for signals in states.sensor.citroen_status.attributes.signals -%}
            {% if signals.name == "EngineSpeed" %}
              {{ signals.value }}
            {% endif %}
          {%- endfor -%}
        {% else %}
           Recargando.
        {% endif %}
       unit_of_measurement: 'tr/min'
     citroen_fecha_update:
       friendly_name: 'Citroen Actualización'
       value_template: "{{ as_timestamp(state_attr('sensor.citroen_status','updatedAt')) | timestamp_custom('%D %-I:%M %P') }}"
     citroen_latitud:
       friendly_name: 'Citroen Latitud'
       value_template: '{{ state_attr("sensor.citroen_status", "location").latitude}}'
     citroen_longitud:
       friendly_name: 'Citroen Longitud'
       value_template: '{{ state_attr("sensor.citroen_status", "location").longitude}}'

camera:
  - name: Posición Citroen
    platform: generic
    still_image_url: !secret camara_citroen
    limit_refetch_to_url_change: true


