Hi,
I have a Node-red flow that sends me a picture from a local file when movement is detected on a sensor. (a camera creates the picture and first saves it to that local file) Then NodeRed sends it via Telegram. This has served me well for several years. Recently it stopped working after I updated NR
The NR log file shows the following error: Unhandled rejection Error: ETELEGRAM: 400 Bad Request: invalid file HTTP URL specified: URL host is empty
Add On Version:
You are running the latest version of this add-on.
System: Raspbian GNU/Linux 11 (bullseye) (armv7 / raspberrypi4)
Home Assistant Core: 2024.1.2
Home Assistant Supervisor: 2023.12.1
I don’t know why it complains about a HTTP URL . I have always been sending a filepath, but after the upgrade from NR version 3.0.2, it seems to complain about an HTTP URL.
In recent updates to Node-RED addon package, the file structure has changed. Node-RED (addon) now has its own top level /addon_configs/a0d7b954_nodered/ folder where all the NR configuration lives.
From within NR, file nodes reading and writing to /config/ now actually refer to the new addon_config folder and not the main HA config folder.
From within NR, to read into the HA config folder /config/ you need to call it /homeassistant/ (it is still /config, just known as /homeassistant within addons).
The write access to folders has also changed, with the intention that addon programmes can no longer make changes to the main HA configuration files and directory.
You may well have to experiment with this as you appear to have two flows, one writing and one reading. Clearly they need to point to the same place, wherever that may now be.
sorry the editor prevents me from posting… Unformatted Code Warning
now, on to the solution
what is this… I keeps giving me Unformatted Code Warning and prevents me from posting my text… just typing some random text here to test
trying to continue
I made a subdirectory called cam_captures under /addon_configs/a0d7b954_nodered. I then changed the path where the node saves the cam_captures, but then I run into another problem
msg : error
"HomeAssistantError: Cannot write /addon_configs/a0d7b954_nodered/cam_captures/camera.westcam1_20240120_150213.jpg, no access to path; allowlist_external_dirs may need to be adjusted in configuration.yaml"
Invalid config for 'homeassistant' at configuration.yaml, line 42: Not a directory 'allowlist_external_dirs->0', got '/usr/share/hassio/addon_configs/a0d7b954_nodered/cam_captures/'
I also tried different substrings of that directory
like
/addon_configs/...
a0d7b954_nodered
I DID check the documentation, but could not find a good explanation on what is expected for allowlist_external_dirs and what is the chroot of it
HomeAssistant… sigh… you have to be a genius… or rely on the goodwill of genius-es in this community… RESPECT !
ok… the " Unformatted Code Warning seems to be triggered by any string with an underscore that is not formatted as code
I finally got posted what I wanted to post…
Now, let’s hope somebody can provide some insights on the allowlist_external_dirs
NodeRed is still able to write my camcaptures to/usr/share/hassio/homeassistant/www/cam_captures/ …even after the upgrade… which should not be possible anymore… When I go to that directory, I do see the jpg files
e.g.: /usr/share/hassio/homeassistant/www/cam_captures/camera.westcam1_20240120_164805.jpg
I can also get to that picture from my browser by going to: http://http://192.168.0.60:8123/local/cam_captures/camera.westcam1_20240120_164805.jpg
As explained by @joeTT Thank you for that tip !
But:
If I ask Node-Red to send an image, either from filePath, or from the URL, to Telegram, it fails with Unhandled rejection Error: ETELEGRAM: 400 Bad Request: wrong HTTP URL specified
So,
My best way-out seems to be that I change the path where the cam_captures are written to the /addon_configs/a0d7b954_nodered/ folder as @Biscuit mentioned
However:
Then I get stuck by not being able to add that new folder as allowlist_external_dirs
I don’t do anything as complex as writing images and then using them. However, if I understand correctly the new direction being taken, then we should not have general write access to the HA configuration folders from within an addon program (and probably not have access to the addon configuration either).
The folders with assured write access (both HA and Node-RED) are therefore now limited, and the two main ‘user’ ones are /media and /share. I have moved all my Node-RED ‘user’ data files (text files that I write and read) to /share, and I can both write and read from them without issue.
Very good
That all makes sense.
I’m all for following standards and (new) directions… trying to remain compatible
Let me try writing to /media (and reading from it again)
In case anyone else is struggling with this:
in NodeRed write and read media files to /media/ e.g. /media/myfile.jpg
For me, those files get stored at: e.g. /usr/share/hassio/media/myfile.jpg
no need to add any exceptions (like allowlist_external_dirs) to configuration.yaml
this is all following the (new) H.A. standard
The world makes sense again
Smooth sailing,
Happy Days
big thank you @Biscuit for your patience
(BTW, long shot, but I know a Geoff Bas… in Ottawa, Canada… we used to work at the same company… it’s probably a different Geoff)