using Dev Tools/Services tab, i have:
service: camera.snapshot
entity: camera.armcrest_camera
data: entity_id: camera.amcrest_camera
filename: ‘/tmp/armcrest_camera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg’
i was expecting to see the file here: /home/tung/.homeassistant/tmp
BUT error log shows: Can’t write /tmp/armcrest_camera_20200117-142600.jpg, no access to path!
i put this in config yaml as well but it did not help:
whitelist_external_dirs:
- /tmp/
this is on ubuntu with HA installed via Python venv. all the tutorials i saw was for HassIO
I agree with @tmjpugh. This is probably a file permissions issue at the OS level.
How are you running HA? As a unique user? If so, you have to make sure that user can write files to that location.
I can tell you the camera.snapshot service works with the amcrest integration. I use it myself. And, FYI, I just submitted a PR to significantly improve the robustness of the amcrest integration. One issue I’ve had for a while is sometimes the snapshot would fail with communication errors. That should be eliminated by the PR.
From that it looks like you’re running HA as user tung. So if you can write to that directory while logged in as tung, then HA should be able to write to it, too. And since you’ve added the folder to the whitelist…
Wait. Why is the filename /tmp/... in the service call, but you said the folder is /home/tung/.homeassistant/tmp? You should use /home/tung/.homeassistant/tmp/... in the service call.
i use the full path as you advised but HA refuses to work:
filename: ‘/home/tung/.homeassistant/tmp/armcrest_camera_{{ now().strftime(“%Y%m%d-%H%M%S”) }}.jpg’
filename: ‘/home/tung/.homeassistant/www/armcrest_camera_{{ now().strftime(“%Y%m%d-%H%M%S”) }}.jpg’
It worked just fine. The only thing I changed from your last attempt was to use proper quotes and I changed tung to homeassistant because in my case HA is run as that user.
BUT using my Amcrest code with telegram results in error: Can’t send file with kwargs
another suggested using telegram bot send message with this format:
message: “door Snapshot”
but i got error: Error sending message: Forbidden: bot can’t send messages to bots.
I have not used Telegram and I really don’t know anything about it.
You should not try to access the camera directly using its HTTP API from another source when it is being controlled by the amcrest integration in HA. You’re asking for trouble, especially if you do this with the snapshot command. That command takes longer than most, and does not allow more than one simultaneously. If the HA amcrest integration happens to try and get a snapshot while you’re doing the same from another system with the same camera, you’re likely to see errors.
I don’t know what that means. Can you clarify / provide more details?
Are you saying that you tried to use that URL somehow directly with telegram, but it resulted in errors when it tried to use that URL? If so, maybe telegram doesn’t support Digest Authentication (like your browser, and the HA amcrest integration, do.) AFAIK, all Amcrest cameras now require Digest Authentication, and maybe your Hikvision camera can use Basic Authentication.
Regarding your automation, that will work, unless…
It takes longer than one second for the snapshot to complete. I’ve had to use a 3 second delay to make sure it’s always done before trying to use the file.
It doesn’t just happen to take the picture right before the minute changes, otherwise the filenames used to take the picture, and to retrieve the picture, won’t match. (E.g., 20200122-14:48 & 20200122-14:49).
you are right. i finally got it working via URL. someone posted his sample of Digest Authentication but his syntax was wrong and i couldnt figure it out myself till now. this working code is much cleaner and efficient: