Hi All,
I want to run a python script daily which calculates a value to supply as an input number into home assistant.
Is it possible to read a value from a csv (or txt) file written to a location on my PC.
Thanks in advance,
Will
Hi All,
I want to run a python script daily which calculates a value to supply as an input number into home assistant.
Is it possible to read a value from a csv (or txt) file written to a location on my PC.
Thanks in advance,
Will
Would this work
Take a look at the file integration:
File - Home Assistant
Has to be set up via the GUI once you installed it - and you’re looking for the File Sensor option once you trying to set it up:
Doesn’t this require the file to be in the home assistant environment though?
Mine is on my desktop. Outside the VM I’m running HA on.
That’s where mine is, correct.
I use the Samba Add-On if I need to manipulate/store the file there from my PC, though.
Never even thought about storing it anywhere else, because the HA system is the only user of this file.
So I’m trying write a file to my C drive and automate the import and subsequent assignment of the file contents to an input number…
Why are you not writing it to the HA Samba location directly?
Or set up, e.g. Syncthing between your HA instance and your PC.
Hadn’t heard of Syncthing before now, looks ideal. Thanks. I’ll give it a go and report back.
I’d started looking at pyscript to run the code inside HA but that got very fiddly. So I just googled importing a file in HA which lead me to the File integration.
Just a hint:
One thing I experienced when setting up Syncthing was strange.
I didn’t want the option ‘Global Discovery’ to be enabled on my HA machine or on my NAS, so I unchecked the box in the settings:
Seemed like it prevented the two devices to connect, so I enabled it in both places, waited for the sync to start and disabled it again. Seems to be working fine now.
Failed at the first hurdle. I installed syncthing on my PC but the HA integration is not accepting the API Key…
Guess, I should have been more specific:
You need to install the Syncthing add-on on your HA machine to have the files synced.
The integration that you need the API key for is only monitoring an existing installation on either your HA machine or another place.
Just curious: Did you get it to work?
Samba share did the trick, I can now write a file to the config folder.
So hopefully I can use the File integration to update a sensor based on the content of the file and schedule a job to to create the file on the network drive that is mapped to the Samba share.
I need to have another read on the Syncthing set up, I assumed the add-on installed Syncthing onto HA.
Good to hear you got it sorted out.
Got to keep in mind:
You only need an API Key for 2), so that’s why I thought you had the integration installed, instead of the add-on.