Class Time
- Namespace
- HaMqttDiscoverable.Entities
- Assembly
- HaMqttDiscoverable.dll
A time-of-day value that can be read and set from Home Assistant, formatted as ISO 8601 ("HH:mm:ss").
public sealed class Time : HaEntity<TimeConfig>, IAsyncDisposable
- Inheritance
-
Time
- Implements
- Inherited Members
Constructors
Time(HaMqttConnection, TimeConfig, Func<TimeOnly, Task>?)
Creates a time entity from the given config, optionally subscribing onCommand to CommandReceived.
public Time(HaMqttConnection connection, TimeConfig config, Func<TimeOnly, Task>? onCommand = null)
Parameters
connectionHaMqttConnectionconfigTimeConfigonCommandFunc<TimeOnly, 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(TimeOnly, bool, CancellationToken)
Publishes the current time.
public Task PublishStateAsync(TimeOnly value, bool retain = true, CancellationToken cancellationToken = default)
Parameters
valueTimeOnlyretainboolcancellationTokenCancellationToken
Returns
Events
CommandReceived
Raised when Home Assistant sends a new time.
public event Func<TimeOnly, Task>? CommandReceived