Table of Contents

Class SwitchConfig

Namespace
HaMqttDiscoverable.Entities
Assembly
HaMqttDiscoverable.dll

Configuration for a Switch entity: a simple on/off control.

public sealed class SwitchConfig : EntityConfig
Inheritance
SwitchConfig
Inherited Members

Properties

Component

The MQTT component Home Assistant should treat this entity as, e.g. sensor or switch. Used to build the discovery topic; not part of the discovery payload itself.

public override string Component { get; }

Property Value

string

Optimistic

When true, Home Assistant assumes the command succeeded and updates the UI immediately instead of waiting for a state update. Only use this if you don't call PublishStateAsync(bool, bool, CancellationToken) after handling a command.

[JsonPropertyName("optimistic")]
public bool? Optimistic { get; set; }

Property Value

bool?

PayloadOff

The payload sent/expected to mean "off". Defaults to "OFF".

[JsonPropertyName("payload_off")]
public string PayloadOff { get; set; }

Property Value

string

PayloadOn

The payload sent/expected to mean "on". Defaults to "ON".

[JsonPropertyName("payload_on")]
public string PayloadOn { get; set; }

Property Value

string