---
title: "Alarm: read and reset alarms"
description: "Read the active alarms and the alarm history of a robot controller and reset the alarms with robot.Alarm. Brand support table, C# and Python examples."
---

# Alarm: read and reset alarms

`robot.Alarm` reads the active alarms and the alarm history of a robot controller, and resets the alarms that can be reset. The result types are the same for Fanuc, Yaskawa, Universal Robots, ABB and Stäubli controllers. The methods that you can call depend on the brand: see the table below.

## Prerequisites

- A connected `RobotController`. See [Connect to your robot](/robotics/documentation/connect).
- The license of the brand of the controller, or the 30 day trial. See [Licensing](/robotics/documentation/license).
- For `Reset`: the controller can refuse the reset, and then `ControllerRefusedException` is thrown (see [Errors](/robotics/documentation/errors)).

## Brand support

Each cell gives the protocol that the method uses on this brand, in the default order. The page [Routing](/robotics/documentation/routing) explains how the library chooses it. The table is generated from the route data of the library. (manual) marks a route that you enable yourself. "n of m" is the number of methods of the service that have a route on this brand.

Routes of each method in the default order. The first route is used, the next ones are fallbacks. (manual) marks a route that you enable yourself.

| Method | Fanuc | Yaskawa | Universal Robots | ABB | Stäubli |
| --- | --- | --- | --- | --- | --- |
| Alarm.ReadActive | SNPX, FTP | High Speed Ethernet Server, Ethernet Server | Primary Interface (Primary), Dashboard Server | Robot Web Services | Not available |
| Alarm.ReadHistory | SNPX, FTP | Not available | Not available | Robot Web Services | Not available |
| Alarm.Reset | SNPX, CGTP (CgtpKcl), Telnet | High Speed Ethernet Server, Ethernet Server | Dashboard Server | Not available | Not available |
| Alarm | **3 of 3** | **2 of 3** | **2 of 3** | **2 of 3** | **0 of 3** |

A brand that has no route for a method throws `FeatureNotSupportedException` (see [Errors](/robotics/documentation/errors)). Ask `robot.Alarm.IsAvailable(AlarmFeature.ReadHistory)` before the call.

## Example

### Read the active alarms and the history

`ReadActive` returns the alarms that are active now. `ReadHistory` returns the last alarms of the history, the most recent first. Check `HasDate` before you use `Date`: some controllers do not give it.

**C# : AlarmRead**
```csharp
using UnderAutomation.Robotics.Controllers;

public class AlarmRead
{
    static void Main()
    {
        RobotController robot = new RobotController();
        robot.Connect(RobotConnectionParameters.Create("fanuc", "192.168.0.1"));

        /**/
        foreach (ControllerAlarm alarm in robot.Alarm.ReadActive())
            Console.WriteLine($"{alarm.Code} {alarm.Severity}: {alarm.Message}");

        // The last 10 alarms
        foreach (ControllerAlarm alarm in robot.Alarm.ReadHistory(10))
            Console.WriteLine(alarm.HasDate ? $"{alarm.Date}: {alarm.Message}" : alarm.Message);
        /**/

        robot.Disconnect();
    }
}
```

**Python : AlarmRead**
```python
from underautomation.robotics.controllers.robot_controller import RobotController
from underautomation.robotics.controllers.robot_connection_parameters import RobotConnectionParameters

robot = RobotController()
robot.connect(RobotConnectionParameters.create("fanuc", "192.168.0.1", ""))

##
for alarm in robot.alarm.read_active():
    print(f"{alarm.code} {alarm.severity.name}: {alarm.message}")

# The last 10 alarms
for alarm in robot.alarm.read_history(10):
    print(f"{alarm.date}: {alarm.message}" if alarm.has_date else alarm.message)
##

robot.disconnect()
```

### Reset the alarms

`Reset` acknowledges the alarms that can be reset. Read the active alarms again to see what is left.

**C# : AlarmReset**
```csharp
using UnderAutomation.Robotics.Controllers;

public class AlarmReset
{
    static void Main()
    {
        RobotController robot = new RobotController();
        robot.Connect(RobotConnectionParameters.Create("fanuc", "192.168.0.1"));

        /**/
        robot.Alarm.Reset();

        Console.WriteLine(robot.Alarm.ReadActive().Length == 0 ? "No alarm" : "Alarm still active");
        /**/

        robot.Disconnect();
    }
}
```

**Python : AlarmReset**
```python
from underautomation.robotics.controllers.robot_controller import RobotController
from underautomation.robotics.controllers.robot_connection_parameters import RobotConnectionParameters

robot = RobotController()
robot.connect(RobotConnectionParameters.create("fanuc", "192.168.0.1", ""))

##
robot.alarm.reset()

print("No alarm" if len(robot.alarm.read_active()) == 0 else "Alarm still active")
##

robot.disconnect()
```

## Reference

In Python, the names are in snake_case: `robot.alarm.read_active()`, `robot.alarm.read_history(10)`, `robot.alarm.reset()`, `robot.alarm.is_available(...)`. The enum members keep their names, and `alarm.severity.name` gives the name of the severity.

### Methods of IAlarmService

**Members of Controllers.IAlarmService**
```csharp
public interface IAlarmService {
    // Returns true when the method can be called on the connected controller.
    // The answer depends on the brand, on the routing settings and on the protocols that answered at the connection, not on the state of the controller.
    bool IsAvailable(AlarmFeature feature)

    // Reads the active alarms
    ControllerAlarm[] ReadActive()

    // Reads the last alarms of the history, the most recent first
    ControllerAlarm[] ReadHistory(int count)

    // Resets (acknowledges) the alarms that can be reset
    void Reset()
}
```

### ControllerAlarm

**Members of Controllers.ControllerAlarm**
```csharp
public sealed class ControllerAlarm {
    // Creates an alarm with the default value of each property
    public ControllerAlarm()

    // Cause of the alarm. Empty when the controller does not give it.
    public string Cause { get; set; }

    // Code of the alarm, as the controller writes it
    public string Code { get; set; }

    // Date of the alarm, in the time of the controller. Valid only when <xref href="UnderAutomation.Robotics.Controllers.ControllerAlarm.HasDate" data-throw-if-not-resolved="false"></xref> is true.
    public DateTime Date { get; set; }

    // Motion group that raised the alarm, from 1. 0 when the alarm is not related to a group.
    public int Group { get; set; }

    // True when the controller gives the date of the alarm
    public bool HasDate { get; set; }

    // Message of the alarm
    public string Message { get; set; }

    // Object of the brand SDK this alarm comes from. Null when there is none.
    public object Native { get; set; }

    // Remedy of the alarm. Empty when the controller does not give it.
    public string Remedy { get; set; }

    // Severity of the alarm
    public ControllerAlarmSeverity Severity { get; set; }

    // Task or program that raised the alarm. Empty when the alarm is not related to a task.
    public string Task { get; set; }

    public override string ToString()
}
```

**Members of Controllers.ControllerAlarmSeverity**
```csharp
public enum ControllerAlarmSeverity {
    // Error: the program or the motion is stopped
    Error = 3

    // Information, no effect on the robot
    Information = 1

    // The controller does not give the severity
    Unknown = 0

    // Warning: the robot continues
    Warning = 2
}
```

### Errors

The page [Errors](/robotics/documentation/errors) explains each exception and how to avoid it.

- `FeatureNotSupportedException`: the brand has no route for the method.
- `RouteUnavailableException`: the method has routes, but none of them can be used, for example because the protocol did not answer at the connection.
- `ControllerRefusedException`: the controller received the command and refused it.
- `RobotControllerException`: the route failed. Its inner exception is the exception of the brand SDK.

`IsAvailable` only throws `ArgumentOutOfRangeException`, for a value that is not in the enum.

## What to read next

- [Read and reset robot alarms](/robotics/documentation/how-to-read-reset-alarms): the same code on the brands that have an alarm route, and what each brand reads and resets.
- [State](/robotics/documentation/state): `AlarmPresent` tells you that an alarm is active, without reading the list.
- [Program](/robotics/documentation/program): start the program again after the reset.
- [Pendant](/robotics/documentation/pendant): show a message to the operator.