Table of Contents

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

connection HaMqttConnection
config VacuumConfig

Properties

SetFanSpeedTopic

The topic this vacuum accepts a fan speed on, or null if FanSpeedList is empty.

public string? SetFanSpeedTopic { get; }

Property Value

string

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

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

payload JsonObject

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

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

activity VacuumActivity
fanSpeed string
extraAttributes IReadOnlyDictionary<string, object>
retain bool
cancellationToken CancellationToken

Returns

Task

Events

CommandReceived

Raised when Home Assistant sends a start/pause/stop/return/clean-spot/locate command.

public event Func<VacuumCommand, Task>? CommandReceived

Event Type

Func<VacuumCommand, Task>

FanSpeedCommandReceived

Raised when Home Assistant sends a new fan speed. Only raised when FanSpeedList is non-empty.

public event Func<string, Task>? FanSpeedCommandReceived

Event Type

Func<string, Task>