Table of Contents

Class Number

Namespace
HaMqttDiscoverable.Entities
Assembly
HaMqttDiscoverable.dll

A numeric value that can be read and set from Home Assistant, e.g. a target temperature.

public sealed class Number : HaEntity<NumberConfig>, IAsyncDisposable
Inheritance
Number
Implements
Inherited Members

Constructors

Number(HaMqttConnection, NumberConfig, Func<double, Task>?)

Creates a number from the given config, optionally subscribing onCommand to CommandReceived.

public Number(HaMqttConnection connection, NumberConfig config, Func<double, Task>? onCommand = null)

Parameters

connection HaMqttConnection
config NumberConfig
onCommand Func<double, Task>

Properties

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

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(double, bool, CancellationToken)

Publishes the current value.

public Task PublishStateAsync(double value, bool retain = true, CancellationToken cancellationToken = default)

Parameters

value double
retain bool
cancellationToken CancellationToken

Returns

Task

Events

CommandReceived

Raised when Home Assistant sends a new value.

public event Func<double, Task>? CommandReceived

Event Type

Func<double, Task>