File Sensor - can't set unique id or icon

I’m running HA in a virtualbox VM on MacOS host. The regular speedtest integration as well as speedtest-cli is too slow on my 300Mbit line from within the VM. Therefore I’ve set up a cron job to run speedtest-cli on the host and append the results to a text file that I can access from HA.

I’ve created a couple of file sensors to read the results like this:

- platform: file
    name: Speedtest Download file
    file_path: /config/shell_commands/speedtest.txt
    value_template: >
      {{ value.split(',')[1] | round(2) }}
    unit_of_measurement: "Mbit/s"

However, there is now now way to configure the appearance of the result. For example, I can’t change the icon from the default “File” icon to a speed icon, neither can I set a unique-id. Is there a way around this?

Neither can I set json attributes, so I only need to access the file sensor once (like for the commandline-sensor).

1 Like

The integration docs don’t show any support for a unique_id or an icon, so it’s not going to be possible that way (and in general you can’t add a unique_id).

You can add an icon by customising in YAML or just define the icon in the card you use.