Dahua [Alarm Out] integration with Blue Iris

vdics1601

n3wb
Jan 17, 2024
3
1
California
Hello all, I'm in need of some assistance. I apologize in advance if this has been asked/answered.

I have a Dahua fixed camera with "Alarm Out" wires on the pigtail. I have the cam connected and running on Blue Iris and the two-way audio works well. Does anybody know how to activate the "Alarm-Out" wires via Blue Iris and the Alert settings? Is it a command that is sent to the camera itself that allow the wires to activate. I'm trying to figure this out so I can connect an external relay to the camera itself and have it perform other functions once the "Alarm Out" is activated. I hope this makes sense...

Thank you all!

-Rob
 
The camera's "alarm out" function is configured completely within the camera, Blue Iris has no role in that.

If you wanted BI to detect and utilize that alarm out condition you could connect the camera's relay to the input of a Shelly 1-UL Wi-Fi switch and have the Shelly send a HTTP command to alert Blue iris. The HTTP command can have BI record, move a PTZ to a preset, play an audio file, display a text overlay, send a push notification, make a snapshot and a lot more. See BI's built-in "Help" and look under "Administration" => "HTTP Interface" for a list of commands.

Read more here:


shelly1_input.jpg
 
Last edited:
As an Amazon Associate IPCamTalk earns from qualifying purchases.
Actually you can use BI to trigger the alarm out on another camera.

I use one camera to trigger the alarm out on another camera to turn a light on:

Under Alert use DIO 1 On to send power to the device.

1725620703042.png


And then DIO 1 Off to shut power to the device.

1725620792919.png


Now obviously it depends on the device you are connecting to and for some situations, additional power or another type of relay may need to be placed at the end of the wires first.
 
  • Like
Reactions: vdics1601
Under Alert use DIO 1 On to send power to the device.

And then DIO 1 Off to shut power to the device.

Geez...I guess I need to update my BI...it has some DIO but nowhere near what yours shows. :)
 
  • Like
Reactions: vdics1601
Actually you can use BI to trigger the alarm out on another camera.

I use one camera to trigger the alarm out on another camera to turn a light on:

Under Alert use DIO 1 On to send power to the device.

View attachment 202622


And then DIO 1 Off to shut power to the device.

View attachment 202623


Now obviously it depends on the device you are connecting to and for some situations, additional power or another type of relay may need to be placed at the end of the wires first.
This is exactly what I'm trying to accomplish, however DIO1 and DIO2 are not working. I used ChatGPT to help and it suggested putting in a HTTP command, but those aren't working. Using your method, I tried doing a couple of other commands, which DID work from the CGI in BI. I just can't get the Alarm out to work...
If I'm in the camera's UI and hit the alarm icon, the Alarm out wires are "closed" (Testing with Multimeter). As soon as I deactivate the alarm icon, the Alarm out wires are "open" again, so I know they work. I'm just confused on how to make that happen through BI.
 
Thank you both for helping out in this. Long story short, I created a python script and pointed BI to that script when the camera is alerted. I have it set to activate for 10 seconds then it automatically deactivates. The script is as follows if anybody wants it:

from onvif import ONVIFCamera
import zeep
import sys
import time
import logging

# Configure logging
logging.basicConfig(filename='alarm_control.log', level=logging.INFO, format='%(asctime)s %(message)s')

def zeep_pythonvalue(self, xmlvalue):
return xmlvalue

# Replace with your camera's IP address and ONVIF port
CAMERA_IP = 'Insert IP Address'
CAMERA_PORT = 80 # Common ONVIF ports: 80, 8899, 8080
USERNAME = 'insert username'
PASSWORD = 'insert password'

try:
# Initialize the ONVIF camera object
mycam = ONVIFCamera(CAMERA_IP, CAMERA_PORT, USERNAME, PASSWORD)

# Fix for namespace issues in zeep
zeep.xsd.simple.AnySimpleType.pythonvalue = zeep_pythonvalue

# Create the device management service
devicemgmt_service = mycam.create_devicemgmt_service()

# Get the relay outputs (this retrieves the available alarm outputs on the camera)
relay_outputs = devicemgmt_service.GetRelayOutputs()

if not relay_outputs:
logging.error("No relay outputs found on this device.")
sys.exit(1)

# Use the first relay output token
relay_token = relay_outputs[0].token

# Function to set the relay state
def set_relay_state(state):
relay_service = devicemgmt_service # Device management is used for controlling relays
relay_service.SetRelayOutputState({'RelayOutputToken': relay_token, 'LogicalState': state})

# Check for the command-line argument
if len(sys.argv) != 2:
logging.error("Usage: python alarm_control.py [activate|deactivate]")
sys.exit(1)

action = sys.argv[1].lower()

if action == 'activate':
set_relay_state('active')
logging.info("Alarm activated.")
# Auto-deactivate after 10 seconds
time.sleep(10)
set_relay_state('inactive')
logging.info("Alarm deactivated after delay.")
elif action == 'deactivate':
set_relay_state('inactive')
logging.info("Alarm deactivated.")
else:
logging.error("Invalid argument. Use 'activate' or 'deactivate'.")
sys.exit(1)

except Exception as e:
logging.error(f"An error occurred: {e}")
sys.exit(1)
 
  • Like
Reactions: TonyR