Trigger Automation with timestamps from file

I have a static file that has timestamps in format “2024-03-23 18:32:00”.
I need to trigger an automation in home assistant on these timestamps.
I can code in python but I’m not sure what to do as I’m new to homeassistant.

No python needed, that is the exact use case for the File integration. Set up a sensor in YAML per the documentation below, and then you can create an automation which will trigger based on the value of that sensor.

You could even use the value_template option to give it a timezone-aware datetime

value_template: "{{ value | as_datetime | as_local }}"

I added the definition in configuration.yaml with a relative path to the file. But I cannot find it under devices when I try to create a new automation.

I tried with abolute path but it showed an error.

It won’t be a device, it’ll be a sensor.

If you want to use it as a trigger, you have to use a yaml time trigger.

- platform: time
  at: sensor.entity_id_of_your_file_integration_sensor

If you’re having trouble finding the entity, look at the pinned post at the top of the configuration section.

I tried to use platform time, the automation shows but it does not work. I used the name as id becauese the file sensor object does not have id attribute.
I looked in the states page, I couldn’t find the sensor as well.

You’re adding the sensor incorrectly then. Post any errors in your logs.

I get this error

2024-03-12 19:19:48.407 ERROR (MainThread) [homeassistant.components.file.sensor] 'AzanMarch.txt' is not an allowed directory

The file is in the same directory as the configuration.yaml file
I tried using absolute path like /root/ho…
I tried also /config/AzanMarch.txt

I’m not sure how put the path correctly

it should just be the filename then.

according to the docs it’s /config/<filename>

I tried /config/AzanMarch.txt i got the same error

and /root/config/AzanMarch.txt I got

2024-03-12 21:19:23.542 ERROR (MainThread) [homeassistant.config] Invalid config for 'sensor' from integration 'file' at configuration.yaml, line 19: not a file for dictionary value 'file_path', got '/root/config/AzanMarch.txt', please check the docs at

I fixed the error by adding the file subfolder and adding is to allow list

    - /config/a1

Now I have a warning that the update of that sensor is taking more than 10s

I created the automation as well in automation.yaml but it still does not run the acction on the time stamps

post the full config and the contents of the text file.

This the configuration I added in configuration.yaml

    - /config/a1

 - platform: file
   name: timestamps
   file_path: /config/a1/a2.txt
   value_template: "{{ value | as_datetime | as_local }}"

and I created the following automation in automation.yaml

- id: tsTest
  alias: tsTest
  description: ''
  - platform: time
    at: sensor.timestamps
  condition: []
  - service: media_player.play_media
      entity_id: media_player.living_room_speaker
      media_content_id: media-source://media_source/local/azan1.mp3
      media_content_type: audio/mpeg
      title: azan1.mp3
      media_class: music
      - {}
      - media_content_type: app
        media_content_id: media-source://media_source

and this is what inside my sample timestamps file

2024-03-13 15:45:00
2024-03-13 15:55:00
2024-03-13 16:35:00
2024-03-13 18:18:00
2024-03-13 19:48:00
2024-03-14 05:15:00
2024-03-14 06:28:00
2024-03-14 12:23:00
2024-03-14 15:36:00

i believe time just checks the timestamp on the file(entity) it doesn’t read your file
And as the file.integration only read the last entry, you might aswell use a template-sensor/counter, but if you want to use a “specific” timestamp(from an array) to “trigger/start something”, use input-select, anyhow maybe you need a template-sensor with timestamps as attributes

Not sure how and when this file become “static”, or whether it always will, maybe you could explain whether your automation in mend to play azan1.mp3 @ at fixed/static time 5 times a day ?

Ahh, is it scheduled “(P)rivate times” ?

If so, you could use the native “calendar-integration” , to trigger the automation

you may need to have a device_class: timestamp on your file sensor. You’d want to verify that value being used in value_template doesn’t contain the entire file as well.

my plane is to generate it once and that is it. it will be always static.
Yes, it is 5 times a day but it is not static, it changes every day.

Can you point out some documentation for the template sensor ?

How can I debug the file sensor to check what it reads ?

I also get an error device_class: timestamp when I use on the file senseor

Invalid config for 'sensor' from integration 'file' at configuration.yaml, line 23: 'device_class' is an invalid option for 'file.sensor', check: device_class, please check the docs at

Sorry, that “equation” is beyond my knowledge

I’m sorry if it is not clear. The file itself is static. it contains the 5 times for every calender day. the times for each day are not the same but all should be in the file.

in simple word, for a specific month I have 150 date_time stamps that are not simiaar

How, in which format is your source ? , are you writing these dates/time by hand, or you have a sensor providing these timedates ?
Have you looked at this