Table of Contents

Class WaterHeater

Namespace
HaMqttDiscoverable.Entities
Assembly
HaMqttDiscoverable.dll

A water heater with an operating mode plus a target/current temperature.

public sealed class WaterHeater : HaEntity<WaterHeaterConfig>, IAsyncDisposable
Inheritance
WaterHeater
Implements
Inherited Members

Constructors

WaterHeater(HaMqttConnection, WaterHeaterConfig)

Creates a water heater from the given config.

public WaterHeater(HaMqttConnection connection, WaterHeaterConfig config)

Parameters

connection HaMqttConnection
config WaterHeaterConfig

Properties

CurrentTemperatureTopic

The topic this water heater publishes the currently measured temperature to.

public string CurrentTemperatureTopic { 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 water heater accepts a mode on.

public string ModeCommandTopic { get; }

Property Value

string

ModeStateTopic

The topic this water heater publishes its mode to.

public string ModeStateTopic { get; }

Property Value

string

PowerCommandTopic

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

public string? PowerCommandTopic { get; }

Property Value

string

TargetTemperatureCommandTopic

The topic this water heater accepts a target temperature on.

public string TargetTemperatureCommandTopic { get; }

Property Value

string

TargetTemperatureStateTopic

The topic this water heater publishes its target temperature to.

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

PublishCurrentTemperatureAsync(double, bool, CancellationToken)

Publishes the currently measured water temperature.

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

Parameters

temperature double
retain bool
cancellationToken CancellationToken

Returns

Task

PublishModeAsync(string, bool, CancellationToken)

Publishes the water heater's current mode.

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

Parameters

mode string
retain bool
cancellationToken CancellationToken

Returns

Task

PublishTargetTemperatureAsync(double, bool, CancellationToken)

Publishes the water heater's current target temperature.

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

Parameters

temperature double
retain bool
cancellationToken CancellationToken

Returns

Task

Events

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>

TargetTemperatureCommandReceived

Raised when Home Assistant sends a new target temperature.

public event Func<double, Task>? TargetTemperatureCommandReceived

Event Type

Func<double, Task>