Multiple sensors based on local file?

Trying something new.

The idea is to run a local python script that fetches local bus times from an open API (that data needs a bit of processing to be useful, so I can’t use the REST platform native in HA). This lands as a JSON file which is made available to HA. HA reads data from the file periodically to help me not miss the bus. Whee!

I was chuffed when I found out there was a file sensor, but it’s not terribly flexible, appearing to have only enough facilities for a single value_template.

Any ideas on how I might be able to do this? I was hoping I could spin multiple sensors off the data – as one does with the template platform – but it the file sensor doesn’t seem up to the task.

Am I missing other possible avenues of attack?

Thanks!
-J

If the file sensor lets you set attributes, then just set the state as “OK” and put the JSON in to the attributes of the sensor. Then use template sensors to set the state from the attributes.

1 Like

Unfortunately, the file sensor errors out when I add an attribute line. You did get me thinking a bit more though, and it does appear like the REST platform can access data from a local file.

Git a new direction!

Hello @Rattykins , can you post your solution here, reading a local file with rest? I’m standing on the same point here und must read 300 values from a file and really do not want to create 300 file platform sensors … thanks

1 Like

Am also wondering about a solution with rest platform as the file sensor can not create two sensors from one file.