blakeblackshear / frigate-hass-integration

Frigate integration for Home Assistant
MIT License
660 stars 110 forks source link

Migrate Home Assistant camera to image integration #608

Closed TyzzyT closed 1 month ago

TyzzyT commented 5 months ago

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?

kiloptero commented 5 months ago

maybe this can help you .. use this image image

TyzzyT commented 5 months ago

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.

mifricke commented 5 months ago

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

babelhoo commented 5 months ago

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?

mifricke commented 5 months ago

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

samidcs2 commented 5 months ago

Same problème I downgrade to 4.01 Thanks

kirashogun commented 5 months ago

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.

mifricke commented 5 months ago

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

kirashogun commented 5 months ago

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

mifricke commented 5 months ago

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.

kirashogun commented 5 months ago

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.

samidcs2 commented 5 months ago

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

Elkropac commented 5 months ago

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

babelhoo commented 5 months ago

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.

mifricke commented 5 months ago

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?

NickM-27 commented 5 months ago

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

anttitane commented 5 months ago

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.

TyzzyT commented 5 months ago

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

babelhoo commented 4 months ago

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.

github-actions[bot] commented 3 months ago

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.

kladderadeng commented 3 months ago

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 👍

Elkropac commented 3 months ago

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

mifricke commented 2 months ago

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

github-actions[bot] commented 1 month ago

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.