Custom Component: Unifi Protect

I can confirm the same, if using Safari Live does not work, but it works on Chrome and the Home Assistant App on a Macbook. Btw, this is not related to this integration. If you set up a Camera using the Camera Template (so going directly to the camera), you will get the same result.

1 Like

Using the G4 Doorbell, is it possible to do two way communication using this project? For example, via Google Home Mini or some other device other than using UniFi Protect on Android.

Hi Bris and all,
Awesome work on this integration.

I have been setting up my automations to send me a snapshot of motion is detected when I am not home. Everything works ok with my automations when testing at home, and the automation works automatically when I am away. The issue is that as I am away from my wireless network, my home assistant is not able to find the snapshot. Any suggestions as to how to get around this?
Thanks
Gareth


alias: Motion back of house - not home
description: ''
trigger:
  - entity_id: binary_sensor.motion_back_of_house
    platform: state
    to: 'on'
condition:
  - condition: or
    conditions:
      - condition: state
        entity_id: device_tracker.gareth_s_x
        state: not_home
      - condition: or
        conditions:
          - condition: state
            entity_id: device_tracker.Rebecca.phone
            state: not_home
action:
  - data:
      filename: /config/www/snapshot.jpg
    entity_id: camera.back_of_house
    service: camera.snapshot
  - delay: '00:00:01'
  - data:
      data:
        attachment:
          url: 'http://homeassistant:8123/local/snapshot.jpg'
        url: /lovelace/6
      message: There is motion on the driveway.
      title: Motion Detected
    service: notify.mobile_app_gareth_s_x
mode: single

1 Like

You need to use your external url in the attachment url

Release 0.8.1

This is a minor update with only two bug fixes.

  • FIXED: The service unifiprotect.set_status_light did not function, as it was renamed in the IO module. This has now been fixed so that both the service and the Switch work again.
  • FIXED: Issue #181, Add a retry if the first update request fails on load of the Integration.
1 Like

Hi new to the home assistant but not new to coding and other automation systems. Ran through everything and tested it out but I could not get the doorbell to trigger any events when the doorbell was pressed. I may be missing something here or maybe need some sleep. Automation is below:

alias: Doorbell Chime
trigger:
  - entity_id: binary_sensor.doorbell_uvc_g4_doorbell
    platform: state
    to: 'on'
condition: []
action:
  - service: media_player.volume_set
    entity_id: media_player.surround_sound
    data:
      volume_level: 0
  - service: media_player.turn_on
    entity_id: media_player.surround_sound
  - service: media_player.volume_set
    entity_id: media_player.surround_sound
    data:
      volume_level: 0.9
  - service: media_player.play_media
    data:
      entity_id: media_player.surround_sound
      media_content_id: 'hidden for a reason'
      media_content_type: music
  - delay:
      seconds: 5
  - service: media_player.volume_set
    entity_id: media_player.surround_sound
    data:
      volume_level: 0.3
  - service: media_player.turn_off
    entity_id: media_player.surround_sound
mode: single

I see no other entity ID for entity_id: binary_sensor.doorbell_uvc_g4_doorbell so I am assuming this is the doorbell press trigger but I could be wrong. Any help appreciated

Just wanted to follow up and say after a couple of restarts the bindary_sensor started working.

Love it so far and cant wait to do more automation!

1 Like

Maybe this has nothing to do with the custom component, but is there a way to mute the stream on the dashboard?

Yes this is not specific to this Integration. The stream always start with audio on, and I have not found a way to revert this to off, but maybe it exist? You can press the Loudspeaker icon to turn it off.

First off thanks for creating this integration! It led me to Home Assistant which looks like a much more complete and easier to maintain solution than randomly hacking some scripts together :slight_smile:

Iā€™m probably missing something obvious but Iā€™m not able to get the Unifi protect add-on configured as no configuration panel appears. 0.8.1 is installed via HACS, stream: added to the configuration.yml, Home Assistant (running on a Raspberry Pi) restarted. With both a hard refresh or logging in via Incognito Unifi Protect doesnā€™t appear under Configuration > Integrations, and thereā€™s no settings panel that I can see under HACS > Integrations where Unifi Protect Integration does appear?

Happy to open a Github issue if needed!

Just to clarify - you installed the integration through HACs and restarted HA.
Unifi Protect shows under HACS > Integrations
When you use the Add Integration button in HA under Configuration > Integrations you cannot see the Unifi Protect as an option?

Was just about to add an update to my question but you beat me to it :slight_smile:

At first I didnā€™t realize you also had to add it as an integration, but I had tried adding it before under Configuration > Integrations, Add Integration and it wasnā€™t appearing. Tried again this morning and now it is! Was able to configure and the camera events all seem to be working as expected.

Glad to hear you have resolved it.

2 Likes

Release 0.8.2

@bdraco did some tweaking to the pyunifiprotect IO module, to implement testing and adding more stability. This has resulted in the following changes:

  • FIXED: Use the UniFi Servers MAc address as unique ID to ensure that it never changes. Previously we used the name, and that can be changed by the user. This will help with stability and prevent integrations from suddenly stop working if the name of the UDMP, UNVR4 or CKP was changed.
  • FIXED: Further enhance the fix applied in 0.8.1 to ensure the Integration loads even if the first update fails.
  • FIXED: Sometimes we would be missing event_on or event_ring_on if the websocket connected before the integration setup the binary sensor. We now always return the full processed data, eliminating this error.
1 Like

For some reason I canā€™t get an automation to generate the thumbnail, but when I call the service under Developer Tools it works. Any idea what might cause this?

Logger: homeassistant.components.automation.kamera
Source: custom_components/unifiprotect/camera.py:201
Integration: Automation (documentation, issues)
First occurred: 17:58:21 (70 occurrences)
Last logged: 19:37:38

  • KAMERA: Error executing script. Unexpected error for call_service at pos 1: Thumbnail Request failed: 404 - Reason: Not Found
  • While executing automation automation.kamera
  • KAMERA: Error executing script. Unexpected error for call_service at pos 2: Thumbnail Request failed: 404 - Reason: Not Found
- id: '1612542905430'
  alias: KAMERA
  description: Notis med bild
  trigger:
  - entity_id: binary_sensor.motion_g3_hallen
    platform: state
    to: 'on'
  condition: []
  action:
  - service: unifiprotect.save_thumbnail_image
    data:
      entity_id: camera.g3_hallen
      filename: /config/www/camera_g3_hallen.png
      image_width: 1080
  - service: notify.mobile_app_pixel_5
    data:
      message: Movement detected!
      data:
        image: https://xxx.duckdns.org/local/camera_g3_hallen.png
  mode: single

Any ideas where I should start with this issue?

In my experience thumbnails are generated based on the completed motion event. For my Cloud Key with 3 cameras I also allow a delay of 5 seconds after motion has finished.
If you need an image when motion is first detected you need to use camera.snapshot.

1 Like

Correct what @TazUk is saying. The thumbnail is only created after the event has finished. So if you want to use that, you should put in a delay in your action before executing the save_thumbnail_image. How long exactly can vary, but 5 seconds is a good start.

1 Like

Hi. Thanks a lot for all the work you guys have been doing. Iā€™ve only used it for a bit so far but itā€™s been working great.

My only issue has been that the integration appears to stop when I lose connection (due to network hardware reboot or temporal AC loss. Is there a way to detect this and restart it?

I donā€™t have this issue. Just last night I updated my UDMP to 1.9.0-10, which basically reboots the whole system, and once it was back up, the Integration just picked up again - which it is also designed to do. Yes I do get some errors in the Log file, but that is understandable as there is no connection to the UDMP.
I am curious to know if other people have the same issue as @areks?

I do not have thus issue.