SgtBatten / HA_blueprints

Somewhere to store automation blueprints
154 stars 58 forks source link

[Feature Request]: Double-Take Integration #55

Closed AriaGen closed 11 months ago

AriaGen commented 1 year ago

Describe what you are trying to accomplish and why in non technical terms Update the notification once double-take has finished potentially identifying any persons in the image.

Describe the solution you'd like Option to include and update the notification title/message as necessary, but only if there is a match.

Describe alternatives you've considered I have an idea on what I need to do to make it work, I just don't have enough of an understanding how to grab the data required.

SgtBatten commented 1 year ago

Does your double take not identify people before the event ends? Are the events really short?

AriaGen commented 1 year ago

To be honest, I've only just set it up, and I'm currently away so testing is very limited right now.. Looking into it, Double take is suppose to update the frigate event with a new sub_label with the match data. and from the Double Take UI it seems to be running as expected. I did however encounter an error when first set it up, and I ended up using another fork of it. Turns out the original developer has stopped maintaining the app, and the one that I'm using isn't the official fork of the others that have taken over. So currently, I have no set point of how it's actually originally designed to work and I may have to hold fire on working this out just yet until I'm back and have time to delve a bit further.

SgtBatten commented 1 year ago

I didn't know it was abandoned. Ims till using the official one.

In any case, there is a setting in the double take config necessary to add the sublabels to the frigate mqtt messages. If frigate is saying person and not the name of the matched face on the events page, this is what you are missing.

AriaGen commented 1 year ago

Okay, thank you, that's interesting to know. I do have it enabled, so It may be the fork I was using. May I ask if you're using the HA Addon of Double-Take or Docker? I've switched to another fork, to see how it goes, one that's running in Docker rather than the HA Addon this time. I'm back home tomorrow so I'll be able to test more. If you're running the original in Docker, then I'll try that one out as well.

SgtBatten commented 1 year ago

I use the double take addon within HA but frigate, compreface and deepstack are all on a seperate machine using docker.

this is the bit you need in the DT config

frigate:
  url: http://192.168.1.3:5000

  update_sub_labels: true
  stop_on_match: true
AriaGen commented 1 year ago

Thank you, I have updated my config file to include both them lines. Do you not yet the Cannot read properties of undefined (reading 'id') error?

SgtBatten commented 1 year ago

Think I saw something like that. Honestly have had no time to do anything focused with ha for months. Seems to be working still

AriaGen commented 1 year ago

So after some playing, trying different configurations and different forks of Double-Take, It just doesn't seem to be updating the sub_label. I've even tried a manual curl POST command that's suppose to work. May I ask what version of frigate you're using? I'm currently using 0.12.1-367D724 via Unraid docker.

SgtBatten commented 1 year ago

I had not updated anything on unraid for a while but just did to 0.12.1-367D724 also. It's still working.

Share your dt config?

AriaGen commented 1 year ago

Sorry bud, I missed your request to see my dt config. I have been also checking out frigates and double takes support and been asking questions there. I didn't get very far on frigates, but the guys on DT seems to think it's a bug.

I have managed to manually trigger with a command to test its functionality which seemed to work:

curl --header "Content-Type: application/json" -X POST http://192.168.1.250:5000/api/events/1689355672.691961-jy3kys/sub_label -d '{"subLabel": "test_name"}'

Anyway, here is my whole dt config:


mqtt:
  host: 192.168.1.250
  username: mqtt
  password: ***

frigate:
  url: http://192.168.1.250:5000
  update_sub_labels: true
  stop_on_match: true
  labels:
    - person

  attempts:
    mqtt: true

  image:
    height: 500

detectors:
  compreface:
    url: http://192.168.1.250:8800
    key: 9a9****b8-**6a-4**d-a**1-e****34***99
    timeout: 15
    det_prob_threshold: 0.8
    opencv_face_required: false
    cameras:
     - front_door_frigate

detect:
  match:
    confidence: 70

  unknown:
    confidence: 69
SgtBatten commented 1 year ago

Hm okay, if the DT guys think it's a bug i really don't know. What's unique about your setup vs mine, hard to tell. I don't know if there is much i can do here.

Can DT and frigate talk to eachother? check the network bridging etc.

AriaGen commented 1 year ago

It does seem odd that I seem to be the only one that seems to be having issues. The only thing that I seem to have concluded maybe is that when I don't include the --header "Content-Type: application/json" in the command, it doesn't work saying its not specified, then looking at the subLabel function within DT code it's not their ether. Sadly, if that's the issue then why only me...

I can't see any issues with comms really, DT seems to be getting the screen shots from frigate and passing them through to CompareFace and getting the data back okay. I also have ring-mqtt running where frigate seems to be getting the streams from that okay (I shouldn't really, but I do). Unless ring-mqtt is the issue, the stream stops every 10 mins or so then resets.

Screenshot 2023-07-15 114220

SgtBatten commented 1 year ago

I just noticed I actually run DT as a HA add-on.

Frigate, compreface, deepstack are on unraid however mqtt and DT are on HA.

AriaGen commented 1 year ago

Tried and unfortunately, No change 👎 I may have to make my own automation with the command at this rate, or just not bother, I don't really need my phone to tell me who's at the door when their is a screen shot :')

SgtBatten commented 11 months ago

My whole config in case it helps.

# Double Take
# Learn more at https://github.com/jakowenko/double-take/#configuration

# enable mqtt subscribing and publishing (default: shown below)
mqtt:
  host: 192.168.1.25
  username: doubletakeuser
  password: doubletakepassword

  topics:
    # mqtt topic for frigate message subscription
    frigate: frigate/events
    #  mqtt topic for home assistant discovery subscription
    homeassistant: homeassistant
    # mqtt topic where matches are published by name
    matches: double-take/matches
    # mqtt topic where matches are published by camera name
    cameras: double-take/cameras

# global detect settings (default: shown below)
detect:
  match:
    # save match images
    save: true
    # include base64 encoded string in api results and mqtt messages
    # options: true, false, box
    base64: false
    # minimum confidence needed to consider a result a match
    confidence: 80
    # hours to keep match images until they are deleted
    purge: 168
    # minimum area in pixels to consider a result a match
    min_area: 3000

  unknown:
    # save unknown images
    save: true
    # include base64 encoded string in api results and mqtt messages
    # options: true, false, box
    base64: false
    # minimum confidence needed before classifying a name as unknown
    confidence: 60
    # hours to keep unknown images until they are deleted
    purge: 48
    # minimum area in pixels to keep an unknown result
    min_area: 200

frigate:
  url: http://192.168.1.3:5000

  update_sub_labels: true
  stop_on_match: true

  # object labels that are allowed for facial recognition
  labels:
    - person

  attempts:
    # number of times double take will request a frigate latest.jpg for facial recognition
    latest: 10
    # number of times double take will request a frigate snapshot.jpg for facial recognition
    snapshot: 10
    # process frigate images from frigate/+/person/snapshot topics
    mqtt: true
    # add a delay expressed in seconds between each detection loop
    delay: 0

  image:
    # height of frigate image passed for facial recognition
    height: 500

  # only process images from specific cameras
  cameras:
     - entry
     - doorbell

# detector settings (default: shown below)
detectors:

  deepstack:
    url: http://192.168.1.3:5001
    #key:
    # number of seconds before the request times out and is aborted
    timeout: 30

  compreface:
    url: http://192.168.1.3:8000
    # recognition api key
    key: !secret compreface_api_key
    timeout: 15
    det_prob_threshold: 0.8
AriaGen commented 11 months ago

Cheers bud, I'll have another look over the weekend hopefully if I get a chance. This kinda got put to the back of the pile of stuff to get working tbh.

AriaGen commented 11 months ago

I woke up stupidly early and couldn't get back to sleep so naturally, I decided to have a look. Only gone and fixed the thing. The problem turned out to be my camera names.... having a underscore causes issues apparently.

Thanks for all your help man and good night :)

SgtBatten commented 11 months ago

That seems like an unexpected solution. but glad it is working in any case.