Unreliable InfluxDB size sensor

I am seeing this error occasionally:

Logger: homeassistant.components.file.sensor
Source: components/file/sensor.py:85
Integration: file (documentation, issues)
First occurred: 17 February 2021, 13:42:25 (2 occurrences)
Last logged: 17 February 2021, 13:57:26

File or data not present at the moment: ha_influx_db_size.txt

Possibly because the file is being written to when home assistant is trying to access it.

As an alternative I’m looking to push the update directly from the command using the Home Assistant rest API, see this example:

curl -X POST -H "Authorization: Bearer ABCDEFGH" \
  -H "Content-Type: application/json" \
  -d '{"state": "25", "attributes": {"unit_of_measurement": "°C"}}' \
  http://localhost:8123/api/states/sensor.kitchen_temperature