Skip to content

Commit

Permalink
Merge pull request #94 from imhotep/hubs-thumbnails
Browse files Browse the repository at this point in the history
adding thumbnails and support for more hubs
  • Loading branch information
imhotep authored Feb 5, 2025
2 parents e1161d6 + fdb1115 commit 435b4da
Show file tree
Hide file tree
Showing 16 changed files with 234 additions and 292 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
# Supported hardware
- Unifi Access Hub (UAH) :white_check_mark:
- Unifi Access Hub (UAH-DOOR) :white_check_mark:
- Unifi Access Intercom (UA-Intercom) :x: (partial/experimental support)
- Unifi Access Hub Enterprise (UAH-Ent) :x: (partial/experimental support)
- Unifi Gate Hub (UGT) :x: (partial/experimental support)
- Unifi Access Ultra (UA-Ultra) :x: (partial/experimental support)
- Unifi Access Door Mini (UA-Hub-Door-Mini) :x: (unsupported - use polling)
- Unifi Access Intercom (UA-Intercom) :white_check_mark:
- Unifi Access Hub Enterprise (UAH-Ent) :white_check_mark:
- Unifi Gate Hub (UGT) :white_check_mark:
- Unifi Access Ultra (UA-Ultra) :white_check_mark:
- Unifi Access Door Mini (UA-Hub-Door-Mini) :white_check_mark:

# Getting Unifi Access API Token
- Log in to Unifi Access and Click on Security -> Advanced -> API Token
Expand Down Expand Up @@ -71,6 +71,9 @@ An entity will get created for each door. Every time a door is accessed (entry,
### Evacuation/Lockdown
The evacuation (unlock all doors) and lockdown (lock all doors) switches apply to all doors and gates and **will sound the alarm** no matter which configuration you currently have in your terminal settings. The status will not update currently (known issue).

### Thumbnail
A thumbnail of when the door is last accessed/locked/unlocked.

### Door lock rules (only applies to UAH)
The following entities will be created: `input_select`, `input_number` and 2 `sensor` entities (end time and current rule).
You are able to select one of the following rules via the `input_select`:
Expand Down
1 change: 1 addition & 0 deletions custom_components/unifi_access/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
PLATFORMS: list[Platform] = [
Platform.BINARY_SENSOR,
Platform.EVENT,
Platform.IMAGE,
Platform.LOCK,
Platform.NUMBER,
Platform.SELECT,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/unifi_access/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def async_setup_entry(
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Add Binary Sensor for passed config entry."""
"""Add binary_sensor entity for passed config entry."""
hub: UnifiAccessHub = hass.data[DOMAIN][config_entry.entry_id]

coordinator = hass.data[DOMAIN]["coordinator"]
Expand Down
1 change: 1 addition & 0 deletions custom_components/unifi_access/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
DOOR_LOCK_RULE_URL = "/api/v1/developer/doors/{door_id}/lock_rule"
DEVICE_NOTIFICATIONS_URL = "/api/v1/developer/devices/notifications"
DOORS_EMERGENCY_URL = "/api/v1/developer/doors/settings/emergency"
STATIC_URL = "/api/v1/developer/system/static"

DOORBELL_EVENT = "doorbell_press"
DOORBELL_START_EVENT = "unifi_access_doorbell_start"
Expand Down
10 changes: 10 additions & 0 deletions custom_components/unifi_access/door.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ def __init__(
self.lock_rule = door_lock_rule
self.lock_rule_interval = 10
self.lock_rule_ended_time = door_lock_rule_ended_time
self.thumbnail = (
b"\x89PNG\r\n\x1a\n"
b"\x00\x00\x00\rIHDR\x00\x00\x00\x01"
b"\x00\x00\x00\x01\x08\x06\x00\x00\x00"
b"\x1f\x15\xc4\x89"
b"\x00\x00\x00\nIDATx\xdac\xf8\x0f\x00\x01\x05\x01\x02"
b"\x0a\x15\xbd"
b"\x00\x00\x00\x00IEND\xaeB`\x82"
)
self.thumbnail_last_updated = None

@property
def doorbell_pressed(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/unifi_access/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def async_setup_entry(
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Add Binary Sensor for passed config entry."""
"""Add event entity for passed config entry."""

coordinator = hass.data[DOMAIN]["coordinator"]

Expand Down
Loading

0 comments on commit 435b4da

Please sign in to comment.