imhotep / hass-unifi-access

Unifi Access Integration for Home Assistant
Apache License 2.0
68 stars 16 forks source link

Doorbell event with REN #32

Closed vtracsd closed 4 months ago

vtracsd commented 6 months ago

I have a physical button connected to REN set to doorbell mode. Pressing the button doesn’t trigger the doorbell event. Is it possible to trigger the event with the physical button? Using the swipe doorbell triggers the event.

imhotep commented 6 months ago

Possibly? We'd have to look at what kind of message the hub is sending with this kind of set up. I don't have this kind of set up so I can't test it myself sadly. None of these events are actually documented.

vtracsd commented 6 months ago

I believe the below event is sent from the UA-Hub on REN doorbell press. Let me know if you need more info.

{
  "event": "access.logs.add",
  "receiver_id": "",
  "event_object_id": "7483c27737fb",
  "save_to_history": false,
  "data": {
    "_id": "",
    "@timestamp": "",
    "_source": {
      "actor": {
        "id": "",
        "type": "user",
        "display_name": "N/A",
        "alternate_id": "",
        "alternate_name": "",
        "avatar": "",
        "sso_picture": ""
      },
      "event": {
        "type": "access.door.unlock",
        "display_message": "Incoming Call",
        "result": "ACCESS",
        "reason": "",
        "published": 1714620154000
      },
      "authentication": {
        "credential_provider": "BUTTON_DOOR_BELL",
        "issuer": ""
      },
      "target": [
        {
          "type": "UAH",
          "id": "7483c27737fb",
          "display_name": "UA-HUB-37FB",
          "alternate_id": "",
          "alternate_name": ""
        },
        {
          "type": "device_config",
          "id": "door_entry_method",
          "display_name": "entry",
          "alternate_id": "",
          "alternate_name": ""
        },
        {
          "type": "activities_resource",
          "id": "fa5c0ea3-3773-4fce-ba8d-76969ab895f2",
          "display_name": "Resource",
          "alternate_id": "",
          "alternate_name": ""
        },
        {
          "type": "door",
          "id": "f79e09f6-411c-424b-a364-061c13299d1b",
          "display_name": "PF Frontdoor",
          "alternate_id": "",
          "alternate_name": ""
        },
        {
          "type": "camera event",
          "id": "3ba1517f-738e-4f6a-b45e-b0e9b215c851",
          "display_name": "Frontdoor",
          "alternate_id": "661b638100a55503e40b9c34",
          "alternate_name": ""
        },
        {
          "type": "floor",
          "id": "2d383140-09ad-4eb3-a5eb-ba4cefd97e54",
          "display_name": "1F",
          "alternate_id": "",
          "alternate_name": ""
        },
        {
          "type": "building",
          "id": "54d23195-12b8-49d0-9881-ab9ccadfe12b",
          "display_name": "PF-UNVR",
          "alternate_id": "",
          "alternate_name": ""
        }
      ]
    },
    "tag": "access"
  }
}

Event from with regular doorbell swipe below.

{
  "event": "access.remote_view",
  "receiver_id": "",
  "event_object_id": "0667d296-ad2b-4640-bb83-9fc7fe176c0b",
  "save_to_history": false,
  "data": {
    "channel": "ac0efd6f-f58b-4610-ac8c-131126dedbb7",
    "token": "75db212a-7998-4d92-a2ae-3a5dd52e0bf2",
    "device_id": "f4e2c6bab30f",
    "device_type": "UA-G2-PRO",
    "device_name": "UA G2 PRO Black b30f",
    "door_name": "PF Frontdoor",
    "controller_id": "60223227858f",
    "floor_name": "1F",
    "request_id": "IJmnP7gg9UGrZ1EEUCQ81HDDc5R7hNed",
    "clear_request_id": "",
    "in_or_out": "in",
    "create_time": 1714621166,
    "reason_code": 0,
    "connected_uah_id": "7483c27737fb",
    "room_id": "WR-f4e2c6bab30f-rXExHaQgfCViWxw8vCVrdVNCMg9MMiOv",
    "host_device_mac": "60223227858E",
    "support_feature": [
      "doorbell_bind",
      "doorbell_timeout"
    ],
    "connected_uah_type": "UAH"
  }
}
imhotep commented 6 months ago

I guess we could rely on:

"authentication": {
  "credential_provider": "BUTTON_DOOR_BELL",
  "issuer": ""
},

Although, it does look a little flimsy…

Is there a similar event that is sent when the doorbell is no longer active? Say timeout or user response? We'd need that as well.

vtracsd commented 6 months ago

The previous log I had no attendant assigned to the door. With an attendant, I get this plus the "access.logs.add" event posted earlier.

{
  "event": "access.hw.door_bell",
  "receiver_id": "",
  "event_object_id": "0beeda75-664d-4aee-a7ec-09f42f5eb933",
  "save_to_history": false,
  "data": {
    "door_id": "f79e09f6-411c-424b-a364-061c13299d1b",
    "door_name": "Pf Frontdoor",
    "host_device_mac": "60223227858E",
    "request_id": "c257605d-7a88-4ddf-804d-72451f907346",
    "create_time": 1714758768,
    "device_groups": [
      {
        "unique_id": "7483c27737fb",
        "name": "UA-HUB-37FB",
        "device_type": "UAH",
        "mac": "ff:ff:ff:ff:ff:ff",
        "guid": "4a5e238f-4bae-48d5-84d7-dd2b0e919ab5",
        "is_connected": true,
        "capabilities": [
          "pin_code",
          "dps_alarm",
          "input_mode_switch",
          "aux_alarm",
          "aux_delay_time",
          "hold_time_0.1s",
          "lock_relay_report",
          "ssh_change",
          "door_bell",
          "multi_unlock_schedule",
          "support_ui_account",
          "aux_option_change",
          "unlock_time_period",
          "incremental_update_setting",
          "mqtt_topic_update_setting"
        ],
        "firmware": "v4.4.5.0",
        "configs": [
          {
            "device_id": "7483c27737fb",
            "key": "alias",
            "value": "Pf Frontdoor",
            "tag": "device_extra",
            "source": ""
          }
        ]
      },
      {
        "unique_id": "f4e2c6bab30f",
        "name": "UA G2 PRO Black b30f",
        "device_type": "UA-G2-PRO",
        "mac": "ff:ff:ff:ff:ff:ff",
        "guid": "2f41f611-ae06-4e33-b0b3-76d5bb269984",
        "is_connected": true,
        "capabilities": [
          "pin_code",
          "pin_code_length",
          "change_setting",
          "remote_view",
          "remote_call",
          "ssh_change",
          "support_register_card",
          "support_ui_account",
          "support_webrtc",
          "support_uid_webrtc",
          "support_record_extra",
          "support_face",
          "doorbell_timeout",
          "doorbell_bind",
          "post_capture",
          "hold_to_call"
        ],
        "firmware": "v1.4.8",
        "configs": [
          {
            "device_id": "f4e2c6bab30f",
            "key": "alias",
            "value": "",
            "tag": "device_extra",
            "source": ""
          }
        ]
      }
    ],
    "device_resources": [
      {
        "unique_id": "0c4de0d0-05db-4986-aa12-10cc08f791fb",
        "target_id": "f79e09f6-411c-424b-a364-061c13299d1b",
        "target_type": "door",
        "resource_mac": "0418D6A290A9",
        "resource_type": "camera",
        "created_at": 1714103260,
        "updated_at": 1714103260
      }
    ],
    "door_guard_ids": [
      "f915c828-03a2-46c2-80ce-59e873754b89"
    ],
    "port_name": ""
  }
}

No response if I let the doorbell ring timeout. If I answer the call, I get the below. There isn't anything specific to doorbell stop.

{
  "event": "access.data.device.remote_view",
  "receiver_id": "",
  "event_object_id": "f4e2c6bab30f",
  "save_to_history": false,
  "data": {
    "unique_id": "f4e2c6bab30f",
    "name": "UA G2 PRO Black b30f",
    "alias": "",
    "device_type": "UA-G2-PRO",
    "connected_uah_id": "7483c27737fb",
    "location_id": "f79e09f6-411c-424b-a364-061c13299d1b",
    "firmware": "v1.4.8",
    "version": "v1.4.38",
    "ip": "1.1.1.1",
    "mac": "ff:ff:ff:ff:ff:ff",
    "hw_type": "GA",
    "start_time": 1714702343,
    "security_check": true,
    "source": "",
    "bom_rev": "12",
    "guid": "2f41f611-ae06-4e33-b0b3-76d5bb269984",
    "need_advisory": false,
    "resource_name": "PF-UNVR - 1F - PF Frontdoor - in - UA G2 PRO Black b30f",
    "revision": "1714724304865421767",
    "revision_update_time": 1714724307,
    "version_update_time": -62135596800,
    "firmware_update_time": -62135596800,
    "adopt_time": 1714100618,
    "location": {
      "unique_id": "f79e09f6-411c-424b-a364-061c13299d1b",
      "name": "PF Frontdoor",
      "up_id": "2d383140-09ad-4eb3-a5eb-ba4cefd97e54",
      "timezone": "",
      "location_type": "door",
      "extra_type": "",
      "full_name": "PF-UNVR - 1F - PF Frontdoor",
      "level": 0,
      "work_time": "[]",
      "work_time_id": "",
      "extras": {
        "door_thumbnail": "/preview/reader_f4e2c6bab30f_f79e09f6-411c-424b-a364-061c13299d1b_1714756770.jpg",
        "door_thumbnail_last_update": 1714756770,
        "uah-input_state_dps": "on",
        "uah-wiring_state_dps-neg": "off",
        "uah-wiring_state_dps-pos": "off"
      }
    },
    "configs": [
      {
        "device_id": "f4e2c6bab30f",
        "key": "pin_code_shuffle",
        "value": "no",
        "tag": "device_setting",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "ibeacon_uuid",
        "value": "a541c67f-d23f-4061-9450-0aed13f68b28",
        "tag": "device_setting",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "face",
        "value": "no",
        "tag": "open_door_mode",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "brightness",
        "value": "36",
        "tag": "device_setting",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "cert_fingerprint",
        "value": "C410E26289F145194F4B05BA6032FF530B8D751F",
        "tag": "credential",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "capture_record_extra_after",
        "value": "5",
        "tag": "device_setting",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "ibeacon_major",
        "value": "0",
        "tag": "device_setting",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "ssh_password",
        "value": "hSRnRjyiOnqaiXHiLPZH",
        "tag": "credential",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "nacl_public_key",
        "value": "d+WSnmSLY8jcG3f0OQNRi8ZsBwV5OFycfohcfwMiW1I=",
        "tag": "credential",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "capture_record_extra_before",
        "value": "5",
        "tag": "device_setting",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "volume",
        "value": "36",
        "tag": "device_setting",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "status_led",
        "value": "no",
        "tag": "device_setting",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "alias",
        "value": "",
        "tag": "device_extra",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "greeting_text",
        "value": "welcome",
        "tag": "device_setting",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "ssh_user",
        "value": "ui",
        "tag": "credential",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "pin_code",
        "value": "yes",
        "tag": "open_door_mode",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "door_bell_trigger_type",
        "value": "off",
        "tag": "device_setting",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "pin_code_disable",
        "value": "no",
        "tag": "device_setting",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "door_bell_trigger_interface",
        "value": "default",
        "tag": "device_setting",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "door_entry_method",
        "value": "in",
        "tag": "door_entry_method",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "tof_distance",
        "value": "2000",
        "tag": "device_setting",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "greeting_broadcast_name",
        "value": "none",
        "tag": "device_setting",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "bt_button",
        "value": "yes",
        "tag": "open_door_mode",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "nfc",
        "value": "yes",
        "tag": "open_door_mode",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "ibeacon_minor",
        "value": "1",
        "tag": "device_setting",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "preview",
        "value": "/preview/1714756770_f513c111-abcb-4ae8-96e6-f06f7abdb811.jpg",
        "tag": "device_extra",
        "source": ""
      },
      {
        "device_id": "f4e2c6bab30f",
        "key": "bt",
        "value": "yes",
        "tag": "open_door_mode",
        "source": ""
      }
    ],
    "is_connected": true,
    "is_online": true,
    "is_revision_up_to_date": true,
    "is_adopted": true,
    "is_managed": true,
    "update": null,
    "capabilities": [
      "pin_code",
      "pin_code_length",
      "change_setting",
      "remote_view",
      "remote_call",
      "ssh_change",
      "support_register_card",
      "support_ui_account",
      "support_webrtc",
      "support_uid_webrtc",
      "support_record_extra",
      "support_face",
      "doorbell_timeout",
      "doorbell_bind",
      "post_capture",
      "hold_to_call"
    ]
  }
}
imhotep commented 6 months ago

Oh I like that extra access.hw.door_bell message! Given that we can't tell when the doorbell is effectively active, I suggest that we toggle the doorbell_press binary_sensor whenever we receive that message. That should be good enough for automations etc…Would that work for you? Otherwise, we run the risk of keeping it "on" indefinitely.

vtracsd commented 6 months ago

Yes, that works. Appreciate your work on this!

imhotep commented 5 months ago

@vtracsd https://github.com/imhotep/hass-unifi-access/releases/tag/v1.1.5-beta

I don't have a doorbell to test but tried to add support for it in this release. Let me know if it works and share some logs if you can please.