frigate-hass-integration icon indicating copy to clipboard operation
frigate-hass-integration copied to clipboard

Migrate Home Assistant camera to image integration

Open TyzzyT opened this issue 1 year ago • 23 comments

Describe the problem you are having

In the past, I used the camera.cameraname_person entity, to snapshot it with a Home Assistant service and make a capture of a specific moment. For example when the mailbox has been opened, I would snapshot the person camera entity 1 minute later. I used it like this, but this is obviously not working anymore and there is no image.snapshot replacement service in HA

service: camera.snapshot
data:
  filename: /config/www/frontdoor_mailbox_randomtext.jpg
target:
  entity_id: image.frontdoor_person

Right now, the camera entity has been replaced by the image entity. This totally makes sense, because it is an image instead of a camera. How can I snapshot/capture this image in Home Assistant?

TyzzyT avatar Jan 31 '24 13:01 TyzzyT

maybe this can help you .. use this image image

kiloptero avatar Jan 31 '24 20:01 kiloptero

That is only showing the current image, but if a new person walks through the garden the image gets updated and the image of when the mailbox has been opened is not visible anymore. So I'm looking for a way to manually snapshot/copy the image at a specified moment.

TyzzyT avatar Feb 01 '24 08:02 TyzzyT

I have the same problem. Is there another way to send an image entity picture with Pushover?

mifricke avatar Feb 01 '24 12:02 mifricke

I have a related problem, I used iOS notifications for person detection on the different cameras, with the notification data payload being:

url: /lovelace/cam-entrada
push:
  sound: jbl_no_match.caf
  critical: 1
  volume: 1
entity_id: camera.entrada_person

Now of course this doesn't work, changing the entity to image.entrada_person, doesn't work either. Tried replacing the entity_id: with image: still no luck. When checking the image.entrada_person entity, I do see an image of the last person detected on that camera. What am I doing wrong? How can I get back the snapshot on the notifications?

babelhoo avatar Feb 01 '24 13:02 babelhoo

A downgrade to 4.0.1 solved my problem for now, but it is no solution…

mifricke avatar Feb 01 '24 14:02 mifricke

Same problème I downgrade to 4.01 Thanks

samidcs2 avatar Feb 03 '24 10:02 samidcs2

Just reposting what I posted in the frigate issues board. Create a shell command in your config.yaml in HA to emulate snapshot and call this service in place of snapshot.

shell_command: save_snapshot: wget -O /media/"{{ filename }}" http://homeassistant.local:8123"{{ image }}"

filename would be whatever you want, i use the entity id. image is the entity_picture attribute of the image entity in question. Obviously change the url to whatever your environment is. I just use the default.

By using the image entity, we actually regressed in the flexibility we had before but really HA need to add some functionality to the image entity since right now it's next to useless.

kirashogun avatar Feb 03 '24 10:02 kirashogun

I think the Frigate integration should continue to use a camera entity until the image entity has appropriate features. This is really disappointing.

mifricke avatar Feb 03 '24 11:02 mifricke

Yeah the image entity is just missing too many functionality. In the meantime, use my workaround :).

kirashogun avatar Feb 03 '24 13:02 kirashogun

Just reposting what I posted in the frigate issues board. Create a shell command in your config.yaml in HA to emulate snapshot and call this service in place of snapshot.

shell_command: save_snapshot: wget -O /media/"{{ filename }}" http://homeassistant.local:8123"{{ image }}"

filename would be whatever you want, i use the entity id. image is the entity_picture attribute of the image entity in question. Obviously change the url to whatever your environment is. I just use the default.

By using the image entity, we actually regressed in the flexibility we had before but really HA need to add some functionality to the image entity since right now it's next to useless.

Maybe, i am stupid today, but can you post an example line wich is working in your environment? I don't understand how to format the wget command.

mifricke avatar Feb 04 '24 11:02 mifricke

Screenshot 2024-02-04 230518

Sorry Github seems to have butchered the format. Please enter exactly as it appears. There is a tab on line 148. Yaml is tab based, get tabs wrong, the whole thing falls apart.

Once you've done that, restart HA and now under dev tools -> services, search for save_snapshot and it should appear there requiring the 2 variables filename and image. You can now incorporate it into your automation.

I use Node Red so I use the call Service node, under shell_command domain, save_snapshot appears there.

kirashogun avatar Feb 04 '24 12:02 kirashogun

Just reposting what I posted in the frigate issues board. Create a shell command in your config.yaml in HA to emulate snapshot and call this service in place of snapshot.

shell_command: save_snapshot: wget -O /media/"{{ filename }}" http://homeassistant.local:8123"{{ image }}"

filename would be whatever you want, i use the entity id. image is the entity_picture attribute of the image entity in question. Obviously change the url to whatever your environment is. I just use the default.

By using the image entity, we actually regressed in the flexibility we had before but really HA need to add some functionality to the image entity since right now it's next to useless.

Thank your for response

i try 2 variables save_snapshot: wget -O /media/"{{filename}}" https://xxxxx.duckdns.org:8123{{state_attr('image.cam_garage_person', 'entity_picture')}}

filename is first variable and test ok

and i want second variable with image.cam_garage_person i try save_snapshot: wget -O /media/"{{filename}}" https://xxxxxx.duckdns.org:8123{{state_attr('"{{image_name}}"', 'entity_picture')}} but it don't work

do you have a idea ? Thanks for your response Sam

samidcs2 avatar Feb 06 '24 16:02 samidcs2

Ah, so this is why same person kept showing at my doorway since upgrading to newest version. It would be great, if the entities could be cameras again, so i can save snapshots of them

Elkropac avatar Feb 08 '24 17:02 Elkropac

Thanks to kirashogun's suggestion, I have set 3 shell commands (1 for each camera I want a notification for) on configuration.yaml: Captura de pantalla 2024-02-08 a la(s) 14 36 47

Each of these shell commands takes the last image for the correct camera (by searching for the latest image with the name criteria) and copies it to the www public dir.

Then on the notification I just set the image attribute to my public url's www/snapshot image.

url: /lovelace/cam-entrada
push:
  sound: jbl_no_match.caf
  critical: 1
  volume: 1
image: https://ha.xxxxx.net.ar/local/img/entrada.jpg

The only thing which is not great and I realized after doing some testing, is that the new snapshot image does not appear immediately on the clips folder, it takes a few second after the person detect has fired for the actual image to be there, so I had to introduce a wait before calling the shell command, otherwise the new image is still not there (and I get the previous snapshot on my notification). Still looks too complicated for not so great results.

babelhoo avatar Feb 08 '24 17:02 babelhoo

It is very unfortunate that the image entity is still unusable. As long as you can't use the image properly, we should still be able to use the camera entity. Or both...

Is it not possible to make the image and camera entity available at the same time?

mifricke avatar Feb 08 '24 18:02 mifricke

I have created a PR on home assistant to add a service for saving the image for image entities. Assuming they accept it then this will be built in in the next release of HA core

NickM-27 avatar Feb 08 '24 23:02 NickM-27

I have created a PR on home assistant to add a service for saving the image for image entities. Assuming they accept it then this will be built in in the next release of HA core

Great news! I was also strugling with this. I solved the problem by using the suggested shell_command but possibilty for saving image entity to file is a better solution.

anttitane avatar Feb 09 '24 08:02 anttitane

Link for future reference: https://github.com/home-assistant/core/pull/110057

TyzzyT avatar Feb 09 '24 08:02 TyzzyT

Thanks to kirashogun's suggestion, I have set 3 shell commands (1 for each camera I want a notification for) on configuration.yaml: Captura de pantalla 2024-02-08 a la(s) 14 36 47

Each of these shell commands takes the last image for the correct camera (by searching for the latest image with the name criteria) and copies it to the www public dir.

Then on the notification I just set the image attribute to my public url's www/snapshot image.

url: /lovelace/cam-entrada
push:
  sound: jbl_no_match.caf
  critical: 1
  volume: 1
image: https://ha.xxxxx.net.ar/local/img/entrada.jpg

The only thing which is not great and I realized after doing some testing, is that the new snapshot image does not appear immediately on the clips folder, it takes a few second after the person detect has fired for the actual image to be there, so I had to introduce a wait before calling the shell command, otherwise the new image is still not there (and I get the previous snapshot on my notification). Still looks too complicated for not so great results.

I see that using Frigate's api call: http://HA-IP:5000/api/camera-name/any/snapshot.jpg The latest snapshot is available immediately.

So the shell command (one for each camera, replace HA's IP and camera name to suite yours): entrada_snapshot: 'wget -q 192.168.0.7:5000/api/entrada/any/snapshot.jpg -O /config/www/img/entrada.jpg'

Using this, there's no need to introduce a delay in the automation, as the image is immediately available.

babelhoo avatar Feb 22 '24 14:02 babelhoo

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Mar 24 '24 04:03 github-actions[bot]

I have created a PR on home assistant to add a service for saving the image for image entities. Assuming they accept it then this will be built in in the next release of HA core

Thank you very much @NickM-27! I see that it only requires a review now and all the other checks have been passed. I am really looking forward to your change. Thanks for doing this 👍

kladderadeng avatar Mar 24 '24 06:03 kladderadeng

Hi, will it get merged into HA for next release? My wife is asking me, why is the same guy still visiting our doorway ;)

Elkropac avatar Apr 11 '24 12:04 Elkropac

Will it be merged someday after month of waiting? Still using v4 to keep my automations working.

mifricke avatar Apr 30 '24 07:04 mifricke

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar May 31 '24 04:05 github-actions[bot]