Class Siren
- Namespace
- HaMqttDiscoverable.Entities
- Assembly
- HaMqttDiscoverable.dll
An on/off alarm sounder. AvailableTones, SupportDuration
and SupportVolumeSet only affect what Home Assistant's UI shows -
without a command_template (which this library doesn't expose, matching its other entities),
Home Assistant sends only the plain on/off payload over MQTT, so tone/duration/volume choices
made in the UI aren't transmitted. If you need them, read them from the service call on the
Home Assistant side via an automation, or use the raw HaMqttConnection APIs.
public sealed class Siren : HaEntity<SirenConfig>, IAsyncDisposable
- Inheritance
-
Siren
- Implements
- Inherited Members
Constructors
Siren(HaMqttConnection, SirenConfig, Func<bool, Task>?)
Creates a siren from the given config, optionally subscribing onCommand to CommandReceived.
public Siren(HaMqttConnection connection, SirenConfig config, Func<bool, Task>? onCommand = null)
Parameters
connectionHaMqttConnectionconfigSirenConfigonCommandFunc<bool, 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
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
payloadstring
Returns
PublishStateAsync(bool, bool, CancellationToken)
Publishes the siren's current on/off state.
public Task PublishStateAsync(bool isOn, bool retain = true, CancellationToken cancellationToken = default)
Parameters
isOnboolretainboolcancellationTokenCancellationToken
Returns
Events
CommandReceived
Raised when Home Assistant sends a command to turn the siren on or off.
public event Func<bool, Task>? CommandReceived