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
connectionHaMqttConnectionconfigClimateConfig
Properties
ActionTopic
The topic this device publishes its current action to, or null if SupportsAction is false.
public string? ActionTopic { get; }
Property Value
CurrentHumidityTopic
The topic this device publishes the currently measured humidity to, or null if SupportsHumidity is false.
public string? CurrentHumidityTopic { get; }
Property Value
CurrentTemperatureTopic
The topic this device publishes the currently measured temperature to.
public string CurrentTemperatureTopic { get; }
Property Value
FanModeCommandTopic
The topic this device accepts a fan mode on, or null if SupportsFanMode is false.
public string? FanModeCommandTopic { get; }
Property Value
FanModeStateTopic
The topic this device publishes its fan mode to, or null if SupportsFanMode is false.
public string? FanModeStateTopic { get; }
Property Value
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
ModeCommandTopic
The topic this device accepts a mode on.
public string ModeCommandTopic { get; }
Property Value
ModeStateTopic
The topic this device publishes its mode to.
public string ModeStateTopic { get; }
Property Value
PowerCommandTopic
The topic this device accepts an on/off power command on, or null if SupportsPower is false.
public string? PowerCommandTopic { get; }
Property Value
PresetModeCommandTopic
The topic this device accepts a preset mode on, or null if SupportsPresetMode is false.
public string? PresetModeCommandTopic { get; }
Property Value
PresetModeStateTopic
The topic this device publishes its preset mode to, or null if SupportsPresetMode is false.
public string? PresetModeStateTopic { get; }
Property Value
SwingModeCommandTopic
The topic this device accepts a swing mode on, or null if SupportsSwingMode is false.
public string? SwingModeCommandTopic { get; }
Property Value
SwingModeStateTopic
The topic this device publishes its swing mode to, or null if SupportsSwingMode is false.
public string? SwingModeStateTopic { get; }
Property Value
TargetHumidityCommandTopic
The topic this device accepts a target humidity on, or null if SupportsHumidity is false.
public string? TargetHumidityCommandTopic { get; }
Property Value
TargetHumidityStateTopic
The topic this device publishes its target humidity to, or null if SupportsHumidity is false.
public string? TargetHumidityStateTopic { get; }
Property Value
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
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
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
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
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
TargetTemperatureStateTopic
The topic this device publishes its target temperature to. Null when SupportsTemperatureRange is true.
public string? TargetTemperatureStateTopic { 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
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
actionHvacActionretainboolcancellationTokenCancellationToken
Returns
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
humiditydoubleretainboolcancellationTokenCancellationToken
Returns
PublishCurrentTemperatureAsync(double, bool, CancellationToken)
Publishes the currently measured temperature.
public Task PublishCurrentTemperatureAsync(double temperature, bool retain = true, CancellationToken cancellationToken = default)
Parameters
temperaturedoubleretainboolcancellationTokenCancellationToken
Returns
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
fanModestringretainboolcancellationTokenCancellationToken
Returns
PublishModeAsync(string, bool, CancellationToken)
Publishes the device's current mode.
public Task PublishModeAsync(string mode, bool retain = true, CancellationToken cancellationToken = default)
Parameters
modestringretainboolcancellationTokenCancellationToken
Returns
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
presetModestringretainboolcancellationTokenCancellationToken
Returns
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
swingModestringretainboolcancellationTokenCancellationToken
Returns
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
humiditydoubleretainboolcancellationTokenCancellationToken
Returns
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
temperaturedoubleretainboolcancellationTokenCancellationToken
Returns
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
lowdoublehighdoubleretainboolcancellationTokenCancellationToken
Returns
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
ModeCommandReceived
Raised when Home Assistant sends a new mode (one of Modes).
public event Func<string, Task>? ModeCommandReceived
Event Type
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
PresetModeCommandReceived
Raised when Home Assistant sends a new preset mode. Only raised when SupportsPresetMode is true.
public event Func<string, Task>? PresetModeCommandReceived
Event Type
SwingModeCommandReceived
Raised when Home Assistant sends a new swing mode. Only raised when SupportsSwingMode is true.
public event Func<string, Task>? SwingModeCommandReceived
Event Type
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
TargetTemperatureCommandReceived
Raised when Home Assistant sends a new target temperature. Only raised when SupportsTemperatureRange is false.
public event Func<double, Task>? TargetTemperatureCommandReceived
Event Type
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