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
connectionHaMqttConnectionconfigNumberConfigonCommandFunc<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
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
payloadstring
Returns
PublishStateAsync(double, bool, CancellationToken)
Publishes the current value.
public Task PublishStateAsync(double value, bool retain = true, CancellationToken cancellationToken = default)
Parameters
valuedoubleretainboolcancellationTokenCancellationToken
Returns
Events
CommandReceived
Raised when Home Assistant sends a new value.
public event Func<double, Task>? CommandReceived