Table of Contents

Class SensorConfig

Namespace
HaMqttDiscoverable.Entities
Assembly
HaMqttDiscoverable.dll

Configuration for a read-only Sensor entity.

public sealed class SensorConfig : EntityConfig
Inheritance
SensorConfig
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

ExpireAfter

If set, the sensor becomes "unknown" when no update is received within this many seconds - useful for detecting a stalled or offline sensor.

[JsonPropertyName("expire_after")]
public int? ExpireAfter { get; set; }

Property Value

int?

StateClass

Tells Home Assistant how to interpret readings over time, e.g. "measurement", "total", or "total_increasing" (for ever-increasing counters like energy usage).

[JsonPropertyName("state_class")]
public string? StateClass { get; set; }

Property Value

string

SuggestedDisplayPrecision

Number of decimals to display for numeric values.

[JsonPropertyName("suggested_display_precision")]
public int? SuggestedDisplayPrecision { get; set; }

Property Value

int?

UnitOfMeasurement

The unit of measurement of the sensor's value, e.g. "°C" or "kWh".

[JsonPropertyName("unit_of_measurement")]
public string? UnitOfMeasurement { get; set; }

Property Value

string