Table of Contents

Class AlarmControlPanel

Namespace
HaMqttDiscoverable.Entities
Assembly
HaMqttDiscoverable.dll

A security alarm panel that can be armed/disarmed/triggered from Home Assistant.

public sealed class AlarmControlPanel : HaEntity<AlarmControlPanelConfig>, IAsyncDisposable
Inheritance
AlarmControlPanel
Implements
Inherited Members

Examples

var alarm = new AlarmControlPanel(connection, new AlarmControlPanelConfig
{
    Name = "Alarm",
    UniqueId = "house-alarm",
    Device = device,
});
alarm.CommandReceived += async command =>
{
    ApplyToHardware(command);
    await alarm.PublishStateAsync(AlarmControlPanelState.ArmedAway);
};
await alarm.PublishDiscoveryAsync();

Constructors

AlarmControlPanel(HaMqttConnection, AlarmControlPanelConfig, Func<AlarmControlPanelCommand, Task>?)

Creates an alarm control panel from the given config, optionally subscribing onCommand to CommandReceived.

public AlarmControlPanel(HaMqttConnection connection, AlarmControlPanelConfig config, Func<AlarmControlPanelCommand, Task>? onCommand = null)

Parameters

connection HaMqttConnection
config AlarmControlPanelConfig
onCommand Func<AlarmControlPanelCommand, Task>

Properties

SupportsCommands

Whether this entity type accepts commands from Home Assistant (e.g. switches, numbers). Sensors are read-only and return false.

protected override bool SupportsCommands { get; }

Property Value

bool

Methods

OnCommandReceivedAsync(string)

Called with the raw payload every time a message arrives on CommandTopic. Overridden by controllable entity types.

protected override Task OnCommandReceivedAsync(string payload)

Parameters

payload string

Returns

Task

Events

CommandReceived

Raised when Home Assistant sends an arm/disarm/trigger command.

public event Func<AlarmControlPanelCommand, Task>? CommandReceived

Event Type

Func<AlarmControlPanelCommand, Task>