Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 102648

Date convert format from sensor file

$
0
0

@menarcarlos wrote:

Hello, this is the first time I publish desperate, i’m could not get it to work, the correct date format from a sensor.file that extracts the date from a json string, this is my configuration.yaml:

sensor 4:
  - platform: file
    name: batch_file_inicio
    file_path: Batch.json
    value_template: "{{ value_json.Depuracion_Rollbacks.Date_debut.Fecha | timestamp_custom('%d/%m/%Y') }}"
sensor 5:
  - platform: file
    name: batch_file_fin
    file_path: Batch.json
    value_template: >
        {% set date = states('sensor.batch_file_inicio') %}
        {{ as_timestamp(strptime(date, '%d/%m/%Y')) | timestamp_custom('%d/%m/%Y') }}
        {% if date == states('sensor.date') %} Batch 1
        {% else %} Batch 2
        {% endif %}

I have used other methods, but still have not succeeded. What is the most practical way to solve it?

The result of the above code gives me always: Batch 2

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 102648

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>