Table of Contents

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

connection HaMqttConnection
config DateConfig
onCommand Func<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

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

Publishes the current date.

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

Parameters

value DateOnly
retain bool
cancellationToken CancellationToken

Returns

Task

Events

CommandReceived

Raised when Home Assistant sends a new date.

public event Func<DateOnly, Task>? CommandReceived

Event Type

Func<DateOnly, Task>