Class EntityConfig
- Namespace
- HaMqttDiscoverable.Entities
- Assembly
- HaMqttDiscoverable.dll
Configuration shared by every discoverable entity type. Subclasses add the fields that are
specific to their Home Assistant component (e.g. unit_of_measurement for sensors).
public abstract class EntityConfig
- Inheritance
-
EntityConfig
- Derived
- Inherited Members
Properties
Availability
Overrides the availability topic/payloads used for this specific entity. When null, the entity uses the shared device availability topic managed by the HaMqttConnection it is created with (if PublishClientAvailability is enabled).
[JsonIgnore]
public Availability? Availability { get; set; }
Property Value
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.
[JsonIgnore]
public abstract string Component { get; }
Property Value
Device
The device this entity belongs to. Required - every entity must belong to a device.
[JsonPropertyName("device")]
public Device Device { get; set; }
Property Value
DeviceClass
The Home Assistant device class for this entity, which controls its icon, unit handling and UI treatment. The allowed values depend on the entity type - see Home Assistant's documentation for the component you're configuring, e.g. https://www.home-assistant.io/integrations/sensor/#device-class.
[JsonPropertyName("device_class")]
public string? DeviceClass { get; set; }
Property Value
EnabledByDefault
Whether the entity should be enabled when it's first added. Defaults to Home Assistant's own default (true).
[JsonPropertyName("enabled_by_default")]
public bool? EnabledByDefault { get; set; }
Property Value
- bool?
EntityCategory
Classifies the entity as configuration or diagnostic rather than a primary feature.
[JsonPropertyName("entity_category")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public EntityCategory EntityCategory { get; set; }
Property Value
HasEntityName
When true (the default), Name is treated as a suffix of the device's name rather than a standalone entity name, matching current Home Assistant conventions.
[JsonPropertyName("has_entity_name")]
public bool HasEntityName { get; set; }
Property Value
Icon
An icon to display, e.g. "mdi:thermometer".
[JsonPropertyName("icon")]
public string? Icon { get; set; }
Property Value
Name
The friendly name of the entity. When HasEntityName is true (the default) this is combined with the device's name by Home Assistant, e.g. device "Weather Station"
- entity name "Temperature" becomes "Weather Station Temperature". Leave null to have the entity take the device's name directly (appropriate for a device that only exposes one entity).
[JsonPropertyName("name")]
public string? Name { get; set; }
Property Value
ObjectId
Used to generate entity_id, e.g. an object id of "front_door" produces
sensor.front_door. Optional; Home Assistant derives one from the name when omitted.
[JsonPropertyName("object_id")]
public string? ObjectId { get; set; }
Property Value
Qos
The QoS level used for the entity's MQTT topics. Defaults to 0.
[JsonPropertyName("qos")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public int Qos { get; set; }
Property Value
UniqueId
A globally unique id for this entity, used by Home Assistant's entity registry to track it across restarts and renames. Required.
[JsonPropertyName("unique_id")]
public string UniqueId { get; set; }