Class Humidifier
- Namespace
- HaMqttDiscoverable.Entities
- Assembly
- HaMqttDiscoverable.dll
A humidifier or dehumidifier: on/off with a target humidity, optionally with named modes (e.g. "auto", "sleep"). Set DeviceClass to "humidifier" (the default Home Assistant assumes) or "dehumidifier".
public sealed class Humidifier : HaEntity<HumidifierConfig>, IAsyncDisposable
- Inheritance
-
Humidifier
- Implements
- Inherited Members
Constructors
Humidifier(HaMqttConnection, HumidifierConfig)
Creates a humidifier from the given config.
public Humidifier(HaMqttConnection connection, HumidifierConfig config)
Parameters
connectionHaMqttConnectionconfigHumidifierConfig
Properties
CurrentHumidityTopic
The topic this humidifier publishes the currently measured humidity to.
public string CurrentHumidityTopic { get; }
Property Value
ModeCommandTopic
The topic this humidifier accepts a mode on, or null if Modes is empty.
public string? ModeCommandTopic { get; }
Property Value
ModeStateTopic
The topic this humidifier publishes its mode to, or null if Modes is empty.
public string? ModeStateTopic { 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
TargetHumidityCommandTopic
The topic this humidifier accepts a target humidity on.
public string TargetHumidityCommandTopic { get; }
Property Value
TargetHumidityStateTopic
The topic this humidifier publishes its target humidity to.
public string TargetHumidityStateTopic { 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
PublishCurrentHumidityAsync(double, bool, CancellationToken)
Publishes the currently measured humidity (0-100).
public Task PublishCurrentHumidityAsync(double humidity, bool retain = true, CancellationToken cancellationToken = default)
Parameters
humiditydoubleretainboolcancellationTokenCancellationToken
Returns
PublishModeAsync(string, bool, CancellationToken)
Publishes the humidifier's current mode. Requires Modes to be non-empty.
public Task PublishModeAsync(string mode, bool retain = true, CancellationToken cancellationToken = default)
Parameters
modestringretainboolcancellationTokenCancellationToken
Returns
PublishStateAsync(bool, bool, CancellationToken)
Publishes the humidifier's current on/off state.
public Task PublishStateAsync(bool isOn, bool retain = true, CancellationToken cancellationToken = default)
Parameters
isOnboolretainboolcancellationTokenCancellationToken
Returns
PublishTargetHumidityAsync(double, bool, CancellationToken)
Publishes the humidifier's current target humidity (0-100).
public Task PublishTargetHumidityAsync(double humidity, bool retain = true, CancellationToken cancellationToken = default)
Parameters
humiditydoubleretainboolcancellationTokenCancellationToken
Returns
Events
CommandReceived
Raised when Home Assistant sends a command to turn the humidifier on or off.
public event Func<bool, Task>? CommandReceived
Event Type
ModeCommandReceived
Raised when Home Assistant sends a new mode. Only raised when Modes is non-empty.
public event Func<string, Task>? ModeCommandReceived
Event Type
TargetHumidityCommandReceived
Raised when Home Assistant sends a new target humidity (0-100).
public event Func<double, Task>? TargetHumidityCommandReceived