Is there any way to increase File Sensor update rate?

I’ve searched the forums but can’t find any matches as to changing the update rate of a file sensor.

I’ve recently changed the calculation of my power script to update a json format file at the rate of the device I read the power from, which is 6 to 7s. (I used to do a 60s average, written to the file). In HA the File sensor seems to read the file at a rate of every 30s.

Does anyone know if it is possible to increase the rate at which the file sensor reads?


2 ways:

change the scan_interval:… This may or may not work. You’ll know immediately if it will work as the yaml will not validate.

  - platform: file
    file_path: /home/user/.homeassistant/sensor-data.txt
    # 5 seconds
    scan_interval: 5 

if that doesn’t work, make an automation with homeassistant.update_entity.

- alias: Update every 5 seconds
  - platform: time_pattern
    seconds: '/5'
  - service: homeassistant.update_entity
      entity_id: sensor.whatever_your_file_sensor_is

@petro Thank you so much. The scan_interval method worked.

how can I configure scan_interval option through the UI? because if I use the yaml it warns me that the file yaml is being removed

Disable polling on the integration and make an automation that uses the homeassistant.update_entity service.