Unifi Protect - Enable/Disable Alarm

Hello,

Anyone know if it’s possible to turn on/off Unifi Protect Alarms (Notifications) from HA?

I’d like to get notifications from the UI Protect app, but only when HA has my alarm panel set to “Away” mode. I know I could do all the notifications from within HA, but I’d like to use the Protect app so that my wife can I can just tap on the notification and have the app launch, etc…

I wrote a thing…this does it, but it’s a bit hacky.

1 Like

Jeff your integration is awesome, it’s working perfectly… BUT Unify Protect seems to ignore the Enabled/Disabled status… Im getting notifications on disabled objects.

Anyone else seeing this ?, any other ways we could toggle the notification ?.

I’ll have to play around with this. Try toggling it on/off and see if it helps any? It’s possible Unifi busted this.

Jeff, thank you for this integration. It did exactly what I needed.

1 Like

I just set this up. Created an automation to do a refresh so everything matches protect, wait 30 secs then turn on or off the alarms I need changed. Would be great if could just arm/disarm but Unifi hasn’t added it yet to the api. There is a need for it. Nice job Jeff.

You can use this script to arm and disarm the alarm.
You just need to get the armProfileId from UniFi Protect using your browser’s developer tools and plug that into the script.

#!/bin/bash


BASE_URL="https://192.168.68.30"
LOGIN_URL="$BASE_URL/api/auth/login"
DISABLE_ARM_URL="$BASE_URL/proxy/protect/api/arm/disable"  #or enable

USERNAME="ha"   
PASSWORD="HA"
ARM_PROFILE_ID="6999e4c003698d03e435f100" 

COOKIE_JAR="/tmp/uiprotect_cookie.txt"
HEADER_FILE="/tmp/uiprotect_headers.txt"


curl -k -s -D $HEADER_FILE -c $COOKIE_JAR -X POST "$LOGIN_URL" \
  -H "Content-Type: application/json" \
  -d "{\"username\":\"$USERNAME\",\"password\":\"$PASSWORD\",\"token\":\"\",\"rememberMe\":true}" > /dev/null


CSRF_TOKEN=$(grep -i "x-csrf-token:" $HEADER_FILE | awk '{print $2}' | tr -d '\r')

if [ -z "$CSRF_TOKEN" ]; then
  echo "No: X-Csrf-Token!"
  exit 1
fi

curl -k -s -b $COOKIE_JAR \
  -H "X-Csrf-Token: $CSRF_TOKEN" \
  -H "Content-Type: application/json" \
  -X POST "$DISABLE_ARM_URL" \
  -d "{\"armProfileId\": \"$ARM_PROFILE_ID\"}"```

Any hints how to get this script to run from HA? And how to disarm :slight_smile: