Table of Contents

Class Climate

Namespace
HaMqttDiscoverable.Entities
Assembly
HaMqttDiscoverable.dll

A thermostat/HVAC device: an operating mode (one of Modes) plus a target temperature, with optional fan mode, swing mode, preset mode, humidity, a heating/cooling range, a separate power toggle, and a read-only "current action" report - enable the ones you need via the corresponding ClimateConfig flags.

public sealed class Climate : HaEntity<ClimateConfig>, IAsyncDisposable
Inheritance
Climate
Implements
Inherited Members

Constructors

Climate(HaMqttConnection, ClimateConfig)

Creates a climate device from the given config.

public Climate(HaMqttConnection connection, ClimateConfig config)

Parameters

connection HaMqttConnection
config ClimateConfig

Properties

ActionTopic

The topic this device publishes its current action to, or null if SupportsAction is false.

public string? ActionTopic { get; }

Property Value

string

CurrentHumidityTopic

The topic this device publishes the currently measured humidity to, or null if SupportsHumidity is false.

public string? CurrentHumidityTopic { get; }

Property Value

string

CurrentTemperatureTopic

The topic this device publishes the currently measured temperature to.

public string CurrentTemperatureTopic { get; }

Property Value

string

FanModeCommandTopic

The topic this device accepts a fan mode on, or null if SupportsFanMode is false.

public string? FanModeCommandTopic { get; }

Property Value

string

FanModeStateTopic

The topic this device publishes its fan mode to, or null if SupportsFanMode is false.

public string? FanModeStateTopic { get; }

Property Value

string

HasStateTopic

Whether this entity type reports a state at all. Stateless entities like Button override this to false.

protected override bool HasStateTopic { get; }

Property Value

bool

ModeCommandTopic

The topic this device accepts a mode on.

public string ModeCommandTopic { get; }

Property Value

string

ModeStateTopic

The topic this device publishes its mode to.

public string ModeStateTopic { get; }

Property Value

string

PowerCommandTopic

The topic this device accepts an on/off power command on, or null if SupportsPower is false.

public string? PowerCommandTopic { get; }

Property Value

string

PresetModeCommandTopic

The topic this device accepts a preset mode on, or null if SupportsPresetMode is false.

public string? PresetModeCommandTopic { get; }

Property Value

string

PresetModeStateTopic

The topic this device publishes its preset mode to, or null if SupportsPresetMode is false.

public string? PresetModeStateTopic { get; }

Property Value

string

SwingModeCommandTopic

The topic this device accepts a swing mode on, or null if SupportsSwingMode is false.

public string? SwingModeCommandTopic { get; }

Property Value

string

SwingModeStateTopic

The topic this device publishes its swing mode to, or null if SupportsSwingMode is false.

public string? SwingModeStateTopic { get; }

Property Value

string

TargetHumidityCommandTopic

The topic this device accepts a target humidity on, or null if SupportsHumidity is false.

public string? TargetHumidityCommandTopic { get; }

Property Value

string

TargetHumidityStateTopic

The topic this device publishes its target humidity to, or null if SupportsHumidity is false.

public string? TargetHumidityStateTopic { get; }

Property Value

string

TargetTemperatureCommandTopic

The topic this device accepts a target temperature on. Null when SupportsTemperatureRange is true - see TargetTemperatureLowCommandTopic/TargetTemperatureHighCommandTopic instead.

public string? TargetTemperatureCommandTopic { get; }

Property Value

string

TargetTemperatureHighCommandTopic

The topic this device accepts the high end of a target range on. Only set when SupportsTemperatureRange is true.

public string? TargetTemperatureHighCommandTopic { get; }

Property Value

string

TargetTemperatureHighStateTopic

The topic this device publishes the high end of its target range to. Only set when SupportsTemperatureRange is true.

public string? TargetTemperatureHighStateTopic { get; }

Property Value

string

TargetTemperatureLowCommandTopic

The topic this device accepts the low end of a target range on. Only set when SupportsTemperatureRange is true.

public string? TargetTemperatureLowCommandTopic { get; }

Property Value

string

TargetTemperatureLowStateTopic

The topic this device publishes the low end of its target range to. Only set when SupportsTemperatureRange is true.

public string? TargetTemperatureLowStateTopic { get; }

Property Value

string

TargetTemperatureStateTopic

The topic this device publishes its target temperature to. Null when SupportsTemperatureRange is true.

public string? TargetTemperatureStateTopic { get; }

Property Value

string

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

PublishActionAsync(HvacAction, bool, CancellationToken)

Publishes what the equipment is actually doing right now. Requires SupportsAction.

public Task PublishActionAsync(HvacAction action, bool retain = true, CancellationToken cancellationToken = default)

Parameters

action HvacAction
retain bool
cancellationToken CancellationToken

Returns

Task

PublishCurrentHumidityAsync(double, bool, CancellationToken)

Publishes the currently measured humidity (0-100). Requires SupportsHumidity.

public Task PublishCurrentHumidityAsync(double humidity, bool retain = true, CancellationToken cancellationToken = default)

Parameters

humidity double
retain bool
cancellationToken CancellationToken

Returns

Task

PublishCurrentTemperatureAsync(double, bool, CancellationToken)

Publishes the currently measured temperature.

public Task PublishCurrentTemperatureAsync(double temperature, bool retain = true, CancellationToken cancellationToken = default)

Parameters

temperature double
retain bool
cancellationToken CancellationToken

Returns

Task

PublishFanModeAsync(string, bool, CancellationToken)

Publishes the device's current fan mode. Requires SupportsFanMode.

public Task PublishFanModeAsync(string fanMode, bool retain = true, CancellationToken cancellationToken = default)

Parameters

fanMode string
retain bool
cancellationToken CancellationToken

Returns

Task

PublishModeAsync(string, bool, CancellationToken)

Publishes the device's current mode.

public Task PublishModeAsync(string mode, bool retain = true, CancellationToken cancellationToken = default)

Parameters

mode string
retain bool
cancellationToken CancellationToken

Returns

Task

PublishPresetModeAsync(string, bool, CancellationToken)

Publishes the device's current preset mode. Requires SupportsPresetMode.

public Task PublishPresetModeAsync(string presetMode, bool retain = true, CancellationToken cancellationToken = default)

Parameters

presetMode string
retain bool
cancellationToken CancellationToken

Returns

Task

PublishSwingModeAsync(string, bool, CancellationToken)

Publishes the device's current swing mode. Requires SupportsSwingMode.

public Task PublishSwingModeAsync(string swingMode, bool retain = true, CancellationToken cancellationToken = default)

Parameters

swingMode string
retain bool
cancellationToken CancellationToken

Returns

Task

PublishTargetHumidityAsync(double, bool, CancellationToken)

Publishes the device's current target humidity (0-100). Requires SupportsHumidity.

public Task PublishTargetHumidityAsync(double humidity, bool retain = true, CancellationToken cancellationToken = default)

Parameters

humidity double
retain bool
cancellationToken CancellationToken

Returns

Task

PublishTargetTemperatureAsync(double, bool, CancellationToken)

Publishes the device's current target temperature. Requires SupportsTemperatureRange to be false.

public Task PublishTargetTemperatureAsync(double temperature, bool retain = true, CancellationToken cancellationToken = default)

Parameters

temperature double
retain bool
cancellationToken CancellationToken

Returns

Task

PublishTargetTemperatureRangeAsync(double, double, bool, CancellationToken)

Publishes the device's current target temperature range. Requires SupportsTemperatureRange to be true.

public Task PublishTargetTemperatureRangeAsync(double low, double high, bool retain = true, CancellationToken cancellationToken = default)

Parameters

low double
high double
retain bool
cancellationToken CancellationToken

Returns

Task

Events

FanModeCommandReceived

Raised when Home Assistant sends a new fan mode. Only raised when SupportsFanMode is true.

public event Func<string, Task>? FanModeCommandReceived

Event Type

Func<string, Task>

ModeCommandReceived

Raised when Home Assistant sends a new mode (one of Modes).

public event Func<string, Task>? ModeCommandReceived

Event Type

Func<string, Task>

PowerCommandReceived

Raised when Home Assistant sends an on/off power command. Only raised when SupportsPower is true.

public event Func<bool, Task>? PowerCommandReceived

Event Type

Func<bool, Task>

PresetModeCommandReceived

Raised when Home Assistant sends a new preset mode. Only raised when SupportsPresetMode is true.

public event Func<string, Task>? PresetModeCommandReceived

Event Type

Func<string, Task>

SwingModeCommandReceived

Raised when Home Assistant sends a new swing mode. Only raised when SupportsSwingMode is true.

public event Func<string, Task>? SwingModeCommandReceived

Event Type

Func<string, Task>

TargetHumidityCommandReceived

Raised when Home Assistant sends a new target humidity (0-100). Only raised when SupportsHumidity is true.

public event Func<double, Task>? TargetHumidityCommandReceived

Event Type

Func<double, Task>

TargetTemperatureCommandReceived

Raised when Home Assistant sends a new target temperature. Only raised when SupportsTemperatureRange is false.

public event Func<double, Task>? TargetTemperatureCommandReceived

Event Type

Func<double, Task>

TargetTemperatureRangeCommandReceived

Raised when Home Assistant sends a new target temperature range (low, high). Only raised when SupportsTemperatureRange is true.

public event Func<double, double, Task>? TargetTemperatureRangeCommandReceived

Event Type

Func<double, double, Task>