Class Vacuum
- Namespace
- HaMqttDiscoverable.Entities
- Assembly
- HaMqttDiscoverable.dll
A robot vacuum with start/pause/stop/return-to-base/clean-spot/locate controls and an optional fan speed.
public sealed class Vacuum : HaEntity<VacuumConfig>, IAsyncDisposable
- Inheritance
-
Vacuum
- Implements
- Inherited Members
Constructors
Vacuum(HaMqttConnection, VacuumConfig)
Creates a vacuum from the given config.
public Vacuum(HaMqttConnection connection, VacuumConfig config)
Parameters
connectionHaMqttConnectionconfigVacuumConfig
Properties
SetFanSpeedTopic
The topic this vacuum accepts a fan speed on, or null if FanSpeedList is empty.
public string? SetFanSpeedTopic { get; }
Property Value
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
EnrichDiscoveryPayload(JsonObject)
Allows subclasses to add fields to the discovery payload that aren't part of EntityConfig directly.
protected override void EnrichDiscoveryPayload(JsonObject payload)
Parameters
payloadJsonObject
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(VacuumActivity, string?, IReadOnlyDictionary<string, object?>?, bool, CancellationToken)
Publishes the vacuum's current activity, and optionally its fan speed and any extra attributes (e.g. battery_level), as a single JSON payload.
public Task PublishStateAsync(VacuumActivity activity, string? fanSpeed = null, IReadOnlyDictionary<string, object?>? extraAttributes = null, bool retain = true, CancellationToken cancellationToken = default)
Parameters
activityVacuumActivityfanSpeedstringextraAttributesIReadOnlyDictionary<string, object>retainboolcancellationTokenCancellationToken
Returns
Events
CommandReceived
Raised when Home Assistant sends a start/pause/stop/return/clean-spot/locate command.
public event Func<VacuumCommand, Task>? CommandReceived
Event Type
FanSpeedCommandReceived
Raised when Home Assistant sends a new fan speed. Only raised when FanSpeedList is non-empty.
public event Func<string, Task>? FanSpeedCommandReceived