Class Date
- Namespace
- HaMqttDiscoverable.Entities
- Assembly
- HaMqttDiscoverable.dll
A calendar date that can be read and set from Home Assistant, formatted as ISO 8601 ("yyyy-MM-dd").
public sealed class Date : HaEntity<DateConfig>, IAsyncDisposable
- Inheritance
-
Date
- Implements
- Inherited Members
Constructors
Date(HaMqttConnection, DateConfig, Func<DateOnly, Task>?)
Creates a date entity from the given config, optionally subscribing onCommand to CommandReceived.
public Date(HaMqttConnection connection, DateConfig config, Func<DateOnly, Task>? onCommand = null)
Parameters
connectionHaMqttConnectionconfigDateConfigonCommandFunc<DateOnly, 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(DateOnly, bool, CancellationToken)
Publishes the current date.
public Task PublishStateAsync(DateOnly value, bool retain = true, CancellationToken cancellationToken = default)
Parameters
valueDateOnlyretainboolcancellationTokenCancellationToken
Returns
Events
CommandReceived
Raised when Home Assistant sends a new date.
public event Func<DateOnly, Task>? CommandReceived