Alarms
Get​
Get a list of alarms in the last 30 days​
- Shell
- PowerShell (native)
- PowerShell (PSc8y)
c8y alarms list --dateFrom "-30d"
c8y alarms list --dateFrom "-30d"
Get-AlarmCollection -DateFrom "-30d"
Output
| id | status | type | severity | count | source.id | source.name | creationTime | text |
|-------------|-------------|------------------------------|------------|------------|-------------|-------------------------|-------------------------------|----------------------------------------|
| 497826 | ACTIVE | c8y_UnavailabilityAlarm | MAJOR | 1 | 497719 | mobile-device_0005 | 2021-04-24T19:48:47.790Z | No data received from device within r… |
| 497824 | ACTIVE | c8y_UnavailabilityAlarm | MAJOR | 1 | 497718 | mobile-device_0002 | 2021-04-24T19:48:47.768Z | No data received from device within r… |
| 497921 | ACTIVE | c8y_UnavailabilityAlarm | MAJOR | 1 | 497914 | mobile-device_0004 | 2021-04-24T19:48:43.796Z | No data received from device within r… |
note
Additional filtering is possible using some parameters like dateFrom
, dateTo
, fragmentType
, status
, severity
etc. For a full list of parameters use the inbuilt help
- Shell
- PowerShell (native)
- PowerShell (PSc8y)
c8y alarms list --help
c8y alarms list --help
Get-Help Get-AlarmCollection -Full
Get active alarms for a device by name​
- Shell
- PowerShell (native)
- PowerShell (PSc8y)
c8y alarms list --device device01 --status ACTIVE
c8y alarms list --device device01 --status ACTIVE
Get-AlarmCollection -Device device01 -Status ACTIVE
Output
| id | status | type | severity | count | source.id | source.name | creationTime | text |
|-------------|-------------|-----------------------|------------|------------|-------------|---------------|-------------------------------|---------------|
| 497924 | ACTIVE | c8y_temperature0 | MAJOR | 3 | 497835 | device01 | 2021-04-25T12:18:00.290Z | Too cold |
| 497727 | ACTIVE | c8y_temperature2 | MINOR | 4 | 497835 | device01 | 2021-04-25T12:17:46.606Z | Unknown error |
| 497734 | ACTIVE | c8y_sensor2 | MINOR | 2 | 497835 | device01 | 2021-04-25T12:18:54.500Z | Disconnected |
| 497725 | ACTIVE | c8y_sensor0 | MAJOR | 3 | 497835 | device01 | 2021-04-25T12:17:35.997Z | Too hot |
| 497729 | ACTIVE | c8y_sensor3 | WARNING | 4 | 497835 | device01 | 2021-04-25T12:17:53.808Z | Too cold |
Create​
Create a new alarm for a device​
- Shell
- PowerShell (native)
- PowerShell (PSc8y)
c8y alarms create \
--device "device01" \
--time "0s" \
--type "c8y_TestAlarm" \
--severity "MAJOR" \
--text "Test Alarm"
c8y alarms create `
--device "device01" `
--time "0s" `
--type "c8y_TestAlarm" `
--severity "MAJOR" `
--text "Test Alarm"
New-AlaRemove-Item `
-Device "device01" `
-Time "0s" `
-Type "c8y_TestAlarm" `
-Severity "MAJOR" `
-Text "Test Alarm"
Output
| id | status | type | severity | count | source.id | source.name | creationTime | text |
|-------------|-------------|--------------------|------------|------------|-------------|---------------|-------------------------------|-----------------|
| 497740 | ACTIVE | c8y_TestAlarm | MAJOR | 1 | 497835 | device01 | 2021-04-25T12:22:53.218Z | Test Alarm |
Update​
Update alarm status to ACKNOWLEDGED​
- Shell
- PowerShell (native)
- PowerShell (PSc8y)
c8y alarms update --id 497740 --status ACKNOWLEDGED
c8y alarms update --id 497740 --status ACKNOWLEDGED
c8y alarms update -Id 497740 -Status ACKNOWLEDGED
Output
| id | status | type | severity | count | source.id | source.name | creationTime | text |
|-------------|-------------------|--------------------|------------|------------|-------------|---------------|-------------------------------|-----------------|
| 497740 | ACKNOWLEDGED | c8y_TestAlarm | MAJOR | 1 | 497835 | device01 | 2021-04-25T12:22:53.218Z | Test Alarm |
Updating multiple alarms​
Existing alarms from a device can be updated based on queries. This can be helpful when updating a large number of alarms
- Shell
- PowerShell (native)
- PowerShell (PSc8y)
c8y alarms updateCollection --device device01 --status ACTIVE --newStatus ACKNOWLEDGED
c8y alarms updateCollection --device device01 --status ACTIVE --newStatus ACKNOWLEDGED
c8y alarms updateCollection -Device device01 -Status ACTIVE -NewStatus ACKNOWLEDGED
No output
Delete/Remove​
Remove alarms​
- Shell
- PowerShell (native)
- PowerShell (PSc8y)
c8y alarms deleteCollection --device device01 --status ACKNOWLEDGED --dateFrom -1d
c8y alarms deleteCollection --device device01 --status ACKNOWLEDGED --dateFrom -1d
Remove-AlarmCollection -Device device01 -Status ACKNOWLEDGED -DateFrom -1d
Output (standard error)
✓ Deleted /alarm/alarms => 204 No Content
Advanced use cases​
Subscribing to alarms for a device for 180 seconds​
- Shell
- PowerShell (native)
- PowerShell (PSc8y)
c8y alarms subscribe --device device01 --duration 180
c8y alarms subscribe --device device01 --duration 180
Watch-AlaRemove-Item -Device device01 -Duration 180
Output
| id | status | type | severity | count | source.id | source.name | creationTime | text |
|-------------|-------------|------------------|------------|------------|-------------|---------------|-------------------------------|--------------------|
| 497751 | ACTIVE | c8y_sensor0 | MAJOR | 1 | 497835 | device01 | 2021-04-25T12:33:28.231Z | Unknown error |