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.
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.
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.
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.
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.
The Syncthing Add-On installs the Syncthing application onto your HA machine.
The Syncthing Integration allows you to monitor a Syncthing installation from HA, no matter if that installation is on the same HA machine or e.g. your PC or NAS.
You only need an API Key for 2), so thatās why I thought you had the integration installed, instead of the add-on.
Value template: ā{{ value.split(ā,ā)[1] }}ā
Unit of measurement: āGBP/kwhā
However when I try to add this to my config
and do a yaml restart I get this error
Integration error: allowlist_external_dirs - Integration 'allowlist_external_dirs' not found.
So I clearly have a syntax error in referencing the config folder. Can anyone shed any light on how to reference in both the allow_external_dirs entry in my config and the File sensor set up if they differ.
Unless you actually need a file, sending the data using a rest call to a webhook right from the python script might be easier. HA would get the information instantly instead of needing to poll the file (which the python script might be writing simultaneously).
Webhook is an alternative solution which Iāll definitely look at, but I feel like Iām just the right syntax on the file path away from automating what I want.
I donāt think youād need the allowlist at all - I think I have it in my configuration.yaml for another purpose (but donāt remember at the moment what it is ).
But if you do need it, it needs to be under a āhomeassitant:ā topic like this so itās identified as a configuration setting, not an integration as your error indicates:
Literally 3 lines of code and a webhook payload to trigger an automation did the job.
Step 1 Define a webhook string in an automation, with āWebhook payload has been receivedā as the trigger. Add "{{ trigger.json.**boost_rate** }}" to the value of the input number I wish to amend.
Use the webhook string from step 1 to formulate a url, define a key:value pair using the same key used in Step 1, pass these as arguments into requests.post. The value āboostā is calculated earlier in my script.
webhookurl='http://my_homeassistant_ipaddress/api/webhook/webhook_string_from_step1'
data = { '**boost_rate**':boost}
r = requests.post(webhookurl, data=json.dumps(data), headers={'Content-Type': 'application:/json'})