Get started with rules for events

How do rules for events work?

Your surveillance system can detect different types of events, such as motion in a video stream, the push of a button or sound.

You can make events automatically trigger certain actions. For instance, the system can automatically play an audio clip when a camera detects motion. To do this, you set up a rule, which consists of a condition and an action.

This is how an event triggers an action:

  1. Event — A device in your surveillance system detects an event.

  2. Condition — The system analyzes if the event meets certain conditions.

  3. Action — If the conditions are met, the system triggers an action.

You can add multiple conditions to a single rule. With multiple conditions, the rule will only trigger the action if all the conditions are met.

For more information about specific conditions and actions, see Conditions and actions.

Example

You have installed a speaker and a camera to prevent trespassing. When the camera detects motion in the forbidden area, the speaker automatically plays a pre-recorded message that tells the intruder to leave the area.

  1. Event — The camera detects motion when someone walks in the camera view.

  2. Condition — The system analyzes if there was movement in the forbidden area. Since this is the case, the system triggers the action.

  3. Action — The speaker plays the audio clip.

You can add a schedule to the condition so that the rule only triggers the action during certain hours. If the rule is active only outside office hours, then your staff can walk in the area during office hours without triggering the audio message.

Set up rules for events

To help you understand how to configure events, we have created a set of video tutorials for common use cases. The tutorials use the device webpage for configuration. You access the device webpage by entering the IP address of your device in a browser.

Record video when the camera detects motion

This example explains how to set up the camera to start recording to the SD card five seconds before it detects motion and to stop one minute after.

How to record a video stream when the camera detects motion
  1. Make sure that AXIS Video Motion Detection is running:
  2. Go to Settings > Apps > AXIS Video Motion Detection.

  3. Start the application if it is not already running.

  4. Make sure you have set up the application according to your needs. If you need help, see the user manual for AXIS Video Motion Detection 4.

  1. Create a rule:
  2. Go to Settings > System > Events and add a rule.

  3. Type a name for the rule.

  4. In the list of conditions, under Application, select AXIS Video Motion Detection (VMD).

  5. In the list of actions, under Recordings, select Record video while the rule is active.

  6. Select an existing stream profile or create a new one.

  7. Set the prebuffer time to 5 seconds.

  8. Set the postbuffer time to 60 seconds.

  9. In the list of storage options, select SD card.

  10. Click Save.

Direct the camera to a preset position when the camera detects motion

This example explains how to set up the camera to go to a preset position when it detects motion in the image.

  1. Make sure that AXIS Video Motion Detection is running:
  2. Go to Settings > Apps > AXIS Video Motion Detection.

  3. Start the application if it is not already running.

  4. Make sure you have set up the application according to your needs. If you need help, see the user manual for AXIS Video Motion Detection 4.

Add a preset position:

Go to Settings > PTZ and set where you want the camera to be directed by creating a preset position.

  1. Create a rule:
  2. Go to Settings > System > Events > Rules and add a rule.

  3. Type a name for the rule.

  4. In the list of conditions, select a video motion detection condition under Application.

  5. From the list of actions, select Go to preset position.

  6. Select the preset position you want the camera to go to.

  7. Click Save.

Use audio to deter intruders

This example explains how to connect a speaker to the camera and set it up to play a warning message when the camera detects motion in a restricted area.

  • Required hardware:
  • Active speaker with built-in amplifier and connecting wires

NOTICE

Make sure the camera is disconnected from power before making the connections. Reconnect to power after connecting the wires.

  1. Add audio clip to the camera:
  2. Go to Settings > Audio > Output and click .

  3. Click Upload new clip.

  4. Browse to locate your audio clip and click Done.

Create a rule:

  1. Open the device webpage for the camera.

  2. Go to Settings > System > Events.

  3. Go to Recipients and add a recipient.

    1. Go to the device webpage of the speaker that has the audio clip stored on its SD card.

    2. Copy a link to the audio clip.

    3. Return to the device webpage of the camera.

  4. Go to Rules and add a new rule:

    1. Under Condition, select Video motion detection.

    2. Under Action, select Send notification through HTTP.

Show a text overlay in the video stream when the device detects motion

This example explains how to display the text “Motion detected” when the device detects motion.

How to show text overlay when the camera detects motion

Make sure that AXIS Video Motion Detection is running:

  1. Go to Settings > Apps > AXIS Video Motion Detection.

  2. Start the application if it is not already running.

  3. Make sure you have set up the application according to your needs.

  4. Add the overlay text:
  5. Go to Settings > Overlay.

  6. Enter #D in the text field.

  7. Choose text size and appearance.

  8. Create a rule:
  9. Go to System > Events > Rules and add a rule.

  10. Type a name for the rule.

  11. In the list of conditions, select AXIS Video Motion Detection.

  12. In the list of actions, select Use overlay text.

  13. Select Camera 1.

  14. Type “Motion detected”.

  15. Set the duration.

  16. Click Save.

Send an email automatically if someone spray paints the lens

How to send an email notification if someone spray paint the lens
  1. Go to Settings > System > Detectors.

  2. Turn on Trigger on dark images. This will trigger an alarm if the lens is sprayed, covered, or rendered severely out of focus.

  3. Set a duration for Trigger after. The value indicates the time that must pass before an email is sent.

  1. Create a rule:
  2. Go to Settings > System > Events > Rules and add a rule.

  3. Type a name for the rule.

  4. In the list of conditions, select Tampering.

  5. In the list of actions, select Send notification to email.

  6. Select a recipient from the list or go to Recipients to create a new recipient.

    To create a new recipient, click . To copy an existing recipient, click .

  7. Type a subject and a message for the email.

  8. Click Save.

Detect tampering with input signal

This example explains how to trigger an alarm when the input signal has been cut or short-circuited. For more information about the I/O connector, see I/O connector.

How to send an email notification when someone tampers with the input signal
    1. Create a rule:
    2. Go to Settings > System > Events and add a rule.

    3. Type a name for the rule.

    4. In the list of conditions, select Digital input and then select a port.

    5. In the list of actions, select Send notification to email and then select a recipient from the list. Go to Recipients to create a new recipient.

      To create a new recipient, click . To copy an existing recipient, click .

    6. Type a subject and a message for the email.

    7. Click Save.

    Set up rules with a VMS

    You can also set up rules in your video management system (VMS) software. The principle is the same, but each VMS has a different interface.

    For information about how to set up rules in your VMS, see the user manual for the VMS.

    Integrate third-party devices

    I/O connection

    You can connect a third-party device to the I/O port of an Axis device.

    Example

    Start recording when a door is opened.

    In this case the camera is located near the door, and the door sensor is connected by cable to the I/O port on the camera.

    1. The door sensor sends a signal when the door is opened.

    2. The I/O connection on the camera receives the signal and triggers an action in the camera to start recording.

    Virtual input

    You can use a virtual input for incoming HTTP requests.

    Example

    Start recording when a door is opened.

    In this case the camera is not located close to the door. The door sensor is connected by cable to an I/O relay, which is connected to the camera over the network.

    1. The door sensor sends a signal when the door is opened.

    2. The I/O relay box receives the signal and triggers an HTTP request via the network to a virtual input on the camera.

    3. The camera receives the virtual input and triggers an action in the camera to start recording.

    Conditions and actions

    There are different conditions and actions available for different products. Here you find explanations for all of them.

    Conditions

    • I/O

      • Manual trigger: Select to start and stop the action manually by clicking a button in the live view. The button is only visible when there is a rule that uses this condition.

      • Virtual input: Select to trigger the action when any of the selected virtual inputs changes state. External clients, such as video management systems, can use this condition to initiate actions or to trigger one rule with another. Select a virtual port to trigger the action when that specific port is active.

      • Digital input: Select to trigger the action when any of the selected digital input ports changes state. Select an input port to trigger the action when that specific port is active.

      • Supervised input changed state: Select to trigger the action if someone tampers with the connection to digital I/O devices, such as PIRs and door/window contacts. You can detect both if an input is active/inactive (open/closed), and if it is tampered with (cut or shorted). This feature requires additional hardware (end-of-line resistors) in the external I/O loop.

        Example: You connect a push button to an input port. The normal state for the button is circuit open. When someone pushes the button, the current state changes to circuit closed, which activates the input. The input then triggers the product to, for example, record video.

    • Device status

      • System ready: Select to trigger the action when the system ready status is active, that is, when the device has successfully booted up.

      • Above operating temperature: Select to trigger the action when the device temperature is above the operating temperature range.

      • Below operating temperature: Select to trigger the action when the device temperature is below the operating temperature range.

      • Within operating temperature: Select to trigger the action when the device temperature is within the operating temperature range.

      • Above or below operating temperature: Select to trigger the action when the device temperature is outside the operating temperature range.

      • Fan failure: Select to trigger the action when one or multiple built-in fans fail.

      • Network lost: Select to trigger the action when the device has lost the network link to the connected network switch or midspan.

      • New IP address: Select to trigger the action when the device has got a new static IP address or got one through DHCP lease.

      • IP address removed: Select to trigger the action when the device’s current IP address has been removed.

      • PIR sensor: Select to trigger the action when the PIR sensor has detected movement.

      • Casing open: Select to trigger the action when the casing of a connected external device, for example a junction box, is removed or opened.

        Example: Send a notification to an operator if the casing has been opened for maintenance reasons or if someone has tampered with the casing.

      • Shock detected: Select to trigger the action when the device detects that it has been tilted or hit. You first need to turn on shock detection under System > Detectors.

      • Radar data failure: Select to trigger the action when the device detects issues with the radar data received from the sensor, or if the device detects interference on the received signal.

      • Storage failure: Select to trigger the action when the device detects issues with the SD card or network storage connection. When there is a storage failure, recordings are most likely interrupted and not saved.

    • Edge storage

      • Storage health issues detected: Select to trigger the action when the wear level of the SD card has reached a certain value. Go to System > Storage > Onboard storage to set the value.

      • Storage disruption: Select to trigger the action when storage problems are detected. Examples of problems: the storage device is unavailable, removed, full, locked, or has read or write issues. To find out what the issue is, you might need to check the logs.

      • Recording ongoing: Select to trigger the action when the device records to edge storage.

        Example: You can notify the operator by flashing LED lights if the device started or stopped recording.

    • Video

      • Average bitrate degradation: Select to trigger the action when an unexpected degradation occurs. This can happen when the bitrate is higher than anticipated and therefore the quality of the video stream is lower.

      • Tampering: Select to trigger the action when someone tampers with the image, for example, covers the view to prevent video from being recorded. You can configure the camera tampering detection in System > Detectors.

      • Temperature detection: Select to trigger the action whenever the configured threshold of a temperature zone is met. You can use it to, for example, send a notification to the operator when temperature rises above or falls below the set level. You can configure the temperature zone in System > Detectors.

      • Live stream open: Select to trigger the action when a video client accesses the live stream in the web interface. The stream can be of any media type, for example video or audio.

      • Day-night mode: Select to trigger the action when the device switches between day and night mode, for example automatic IR-cut filter. You can use this condition to, for example, control an external IR light through the output port.

    • Audio

      • Audio clip playing: Select to trigger the action when the device starts to play an audio clip.

      • Audio clip currently playing: Select to trigger the action for as long as an audio clip is playing.

      • Audio detection: Select to trigger the action when the sound level rises above or falls below the alarm level. You can configure the alarm level in System > Detectors.

      • Digital signal ok: Select to trigger the action as long as there is a valid digital input that is clock-synched.

      • Digital signal missing: Select to trigger the action when no digital signal is received. This usually occurs when the microphone’s power is lost or the cable is cut.

      • Digital signal has invalid sample rate: Select to trigger the action when the microphone’s sample rate of the clock source is not synced with the audio codec of the device. Usually there is a connection to the microphone but data can’t be interpreted because of the invalid sample rate.

      • Digital signal contains Axis metadata: Select to trigger the action when the digital signal is ok and device information of the microphone is received through the Axis Audio Metadata Protocol (AAMP).

      • Ring power over current protection: Select to trigger the action when the ring power for the digital microphone has been short circuited.

      • Speaker test result: Select to trigger the action based on the result of the speaker functionality test. You can trigger it either when the test was successful or when it was unsuccessful.

    • Scheduled and recurring

      • Schedule: Select to trigger the action based on a predefined schedule in the list of schedules. You can use this condition to record video in specific time periods, for example office hours or weekends. You can create a new schedule in System > Events > Schedules.

      • Pulse: Select to trigger the action based on a predefined recurrence in the list of pulses. You can use this condition to initiate recurring actions, for example upload the image every 30 minutes. You can create a new pulse in System > Events > Schedules.

    • MQTT

      • Stateless and Stateful: Select to trigger the action based on incoming MQTT messages. These messages are converted into events and categorized as either stateful (property) if the isStateData field is set to true, or stateless if the field is set to false. The topic of a stateful event is tnsaxis:MQTT/Message/Stateful, while the topic of a stateless event is tnsaxis:MQTT/Message/Stateless. The topic is embedded into the mqtt-topic field of the event. The first 1024 characters are copied, the remaining part is skipped. The payload of the message is embedded into the mqtt-payload field of the event. If the payload is UTF-8 encoded text, the first 1024 characters are copied, and the remaining part is skipped. You can configure MQTT subscriptions to receive MQTT messages in Settings > MQTT > MQTT subscriptions.

    • Radar motion

      • RMD: Select to trigger the action when motion is detected by the radar according to its zone configuration.

    • Light and siren

    • PTZ

      • PTZ malfunctioning: Select to trigger the action when the device has problems to pan, tilt, or zoom. You can use this condition to inform an operator that there is a problem with the PTZ functionality.

      • PTZ moving: Select to trigger the action when the device pans, tilts, or zooms. You can use this condition in combination with another one, to stop actions such as motion detection during pan, tilt, and zoom.

      • PTZ preset reached: Select to trigger the action when the view reaches a preset position. You can use this condition to save images from the preset positions of a guard tour, or to upload an image at each preset position. In the secondary drop-down list, select Any to trigger the action when any preset position is reached.

        For the option Preset reached, Yes triggers the action when the preset position is reached, and No triggers the action when the device starts to move away from the preset position.

      • PTZ ready: Select to trigger the action when PTZ is in ready status. For example, the device can trigger the action when PTZ is ready to be used after a restart. You can use this condition to move the device to a specific preset position after restart.

    Actions

    • I/O

      • Toggle I/O while the rule is active: Select to toggle an I/O for the duration of the rule.

      • Toggle I/O once: Select to toggle an I/O when the conditions for the rule are met.

        Port: Select the output port to use.

        State: Select if the I/O port should be active or inactive.

        Duration: Set the duration of the output port state. The output port will then go into the opposite state.

    • Notifications

      • Send notification through HTTP(S): Select to send a notification through HTTP or HTTPS.

        Message: The message is received in a CGE variable called Message on the target HTTP server. If the message contains more than 255 characters, this field excludes some or all of the content of the Custom parameter. Spaces are allowed. For a list of allowed modifiers, see [TBA].

        Query string suffix: Add any extra parameters, Name and Value, in a string here.

        Method: Select what method to use. GET and POST are the most common ones.

        HTTP(S) header: If desired, add HTTP(S) headers. You can find a list of HTTP(S) headers at en.wikipedia.org/wiki/List_of_HTTP_header_fields

        Body: If desired, enter a body text. You can’t use a body with the methods GET or DELETE.

      • Send notification through TCP: Select to send a notification through TCP.

        Message: The message is received in a CGE variable called Message on the target HTTP server. If the message contains more than 255 characters, this field excludes some or all of the content of the Custom parameter. Spaces are allowed. For a list of allowed modifiers, see [TBA].

      • Send notification to email: Select to send a notification by email.

        Subject: Enter the email subject.

        Message: Enter the email message.

    • Video clips

      When you send a video clip, it’s generated in a non-searchable way. It means that you can’t fast forward or rewind, or jump to a specific point on the timeline. To do these things, you can use Axis Matroska File Splitter or third-party software like MKVToolNix.

      • Send video clip through HTTP(S): Select to send a video clip to a remote HTTP or HTTPS server. You need to create a corresponding HTTP(S) recipient before you create a rule that includes this action. Optionally, you can define a destination folder or a filename. You can select a stream profile if you don’t want to use the default streaming settings. Prebuffer and postbuffer define for how long the device shall record before and after the actual event occurs.

      • Send video clip to network share: Select to send a video clip to a network share on a remote NAS in the network. You need to create a corresponding network share recipient before you create a rule that includes this action. Optionally, you can define a destination folder or a filename. You can select a stream profile if you don’t want to use the default streaming settings. Prebuffer and postbuffer define for how long the device shall record before and after the actual event occurs.

      • Send video clip to email: Select to send a video clip by email. You need to create a corresponding email recipient before you create a rule that includes this action. Optionally, you can define a filename. You can select a stream profile if you don’t want to use the default streaming settings. Prebuffer and postbuffer define for how long the device shall record before and after the actual event occurs.

      • Send video clip through (S)FTP: Select to send a video clip to a remote FTP or SFTP server. You need to create a corresponding (S)FTP recipient before you create a rule that includes this action. Optionally, you can define a destination folder or a filename. You can select a stream profile if you don’t want to use the default streaming settings. Prebuffer and postbuffer define for how long the device shall record before and after the actual event occurs.

    • Overlay text

      • Use overlay text: Select to display a text on top of a video stream image. The text can be used to provide information for forensic video analysis, notify operators or validate triggers and actions during product installation and configuration.

      • Note

        To display the overlay text, a text overlay with the modifier #D must be created.

    • Day-night mode

      You can use an IR-cut filter that is suitable for the lighting conditions.

      • Note

        Under Video > Image > Day-night mode, the IR-cut filter must not be set to Auto.

      • Use day-night mode while the rule is active:

        • Video source: Select the video source.

        • Mode when active: Select what mode to use when the conditions for the rule are met.

        • Mode when inactive: Select what mode to use when the conditions for the rule are not met.

          • Day: The IR-cut filer is turned on.

          • Night: The IR-cut filer is turned off.

          • Auto: The IR-cut filer is turned on or off depending on the lighting conditions.

    • Images

      • Send images through HTTP(S): Select to send images to a remote HTTP or HTTPS server. You need to create a corresponding HTTP(S) recipient before you create a rule that includes this action. Optionally, you can define a destination folder or a filename. You can select a stream profile if you don’t want to use the default streaming settings. Prebuffer and postbuffer define the number of seconds to include before and after the actual event occurs. If you want to send a limited amount of images only, define the maximum number of images to send or select a custom image frequency.

      • Send images to network share: Select to send images to a network share on a remote NAS in the network. You need to create a corresponding network share recipient before you create a rule that includes this action. Optionally, you can define a destination folder or a filename. You can select a stream profile if you don’t want to use the default streaming settings. Prebuffer and postbuffer define the number of seconds to include before and after the actual event occurs. If you want to send a limited amount of images only, define the maximum number of images to send or select a custom image frequency.

      • Send images to email: Select to send images by email. You need to create a corresponding email recipient before you create a rule that includes this action. Optionally, you can define a filename. You can select a stream profile if you don’t want to use the default streaming settings. Prebuffer and postbuffer define the number of seconds to include before and after the actual event occurs. If you want to send a limited amount of images only, define the maximum number of images to send or select a custom image frequency.

      • Send images through (S)FTP: Select to send images through FTP or SFTP. You need to create a corresponding (S)FTP recipient before you create a rule that includes this action. Optionally, you can define a destination folder or a filename. You can select a stream profile if you don’t want to use the default streaming settings. Prebuffer and postbuffer define the number of seconds to include before and after the actual event occurs. You can define the maximum number of images to send. If you want to send a limited amount of images only, define the maximum number of images to send or select a custom image frequency.

    • SNMP trap messages

      • Send SNMP trap message while the rule is active: Select to send an SNMP trap message for the duration of the rule. Go to System > Network > SNMP to turn on and set up SNMP before you create a rule that includes this action.

      • Send SNMP trap message: Select to send an SNMP trap message when the conditions for the rule are met. Go to System > Network > SNMP to.turn on and set up SNMP before you create a rule that includes this action.

        Alarm name: Enter a name for the alarm.

        Message: Enter the message.

    • Recordings

      Records video to a selected storage.

      • Record video while the rule is active: Select to record video for the duration of the rule.

      • Record video: Select to start recording video.

        • Storage: Select which storage to use for the recorded video.

        • Camera: Select which source to record from (for example a specific view area).

        • Stream profile: Select the stream profile you want to use.

        • Custom image frequency: Turn on this if you want to set the amount of frames per second for the recording.

        • Prebuffer: Enter the number of seconds to include in the recording from the time immediately before the rule was triggered. This time will be shortened automatically if there is insufficient memory when the recording is started.

        • Postbuffer: Enter the number of seconds to include immediately after the rule is no longer active.

    • MQTT

      • Send MQTT publish message: Select to send an MQTT publish message.

        Topic: Enter the topic of the MQTT publish message. The topic can be maximum 1024 characters long.

        Use device topic prefix: Select to add a device topic prefix to the topic.

        Payload: Enter the payload to publish. The payload can be a string or a text with maximum 8192 characters.

        Retain: Select to set a retain flag for the message. The last message on the topic will be retained.

        QoS: Select the quality of service level to use. 0 is default.

    • Audio clips

      • Play audio clip: Select to play a recorded audio clip. It can be used to automatically notify operator that Axis product has detected movement. From the Clip drop-down list, select an audio clip to play.

      • Stop playing audio clip: Select to stop a currently playing audio clip.

    • Audio

      • Run automatic speaker test: Select to send a test signal.

    • Status LED

      The status LED can be used during installation and configuration to visually validate if settings work correctly, for example to confirm that motion detection triggers an action.

      • Flash status LED while the rule is active: Select to make the status LED flash for the duration of the rule. You can choose a color for the LED.

      • Flash status LED: Select to make the status LED flash for a set duration. You can choose a color for the LED.

    • WDR mode

      • Set WDR mode: Select to set WDR mode to on or off. This action may be used when needed to change between the modes automatically. Select WDR on or WDR off for the product to be set to that specific mode.

    • Defog

      • Set defog mode: Select to set defog mode to on or off. This action may be used when needed to change between the modes automatically. Select Defog on or Defog off for the product to be set to that specific mode.

    • Guard tours: Select to set guard tour mode. Select tour from the drop-down list. Select Return to home position if you want the tour to return to the preset home position when it’s no longer active. Deselect the box if you want the tour to stop when the action is no longer active.

    • Preset position: Select to move the device to a set position when the action is triggered. Select Home if you want the device to return to home preset position when it’s no longer active. Select Return home when rule is no longer active and set a time if you want the device to wait before it returns to its preset home position.

    • Radar

      • Radar autotracking: Select to configure the radar autotracking for a PTZ camera. Radar autotracking can be set to On or Off. You need to enable radar autotracking globally for this device before you create a rule that includes this action.

      • Radar detection: Select to set the radar transmission to On or Off. When the radar transmission is off, the radar will not detect any movement.

      • Use radar autotracking while the rule is active: Select to start radar autotracking for the configured PTZ camera. Radar autotracking and radar detection must be set to On before this action can be used.

    • Lights

      The built-in Infrared (IR) light illuminator allows the camera to perform video surveillance in low light areas without the need for external lighting.

      • Use lights while the rule is active: Select to make the built-in IR light illuminator active for the duration of the rule.

      • Use lights for a duration: Select to activate the built-in IR light illuminator for a set duration. You can choose the number of seconds, minutes and hours that the light will stay activated.

    • Wiper

      • Activate wiper: Select to start the built-in wiper. The wiper will remove droplets from the front window. You can choose the number of seconds, minutes and hours that the wiper will stay activated.