@ginden/ha-mqtt-discoverable
    Preparing search index...

    Class SensorInfo

    Sensor specific information

    Hierarchy (View Summary)

    Index

    Properties

    component: "sensor" = 'sensor'

    Sensor component type

    device?: DeviceInfo

    Information about the device this sensor belongs to

    deviceClass?: string

    Sets the class of the device, changing the device state and icon that is displayed on the frontend.

    enabledByDefault?: boolean

    Flag which defines if the entity should be enabled when first added.

    entityCategory?: string

    Classification of a non-primary entity.

    expireAfter?: number

    If set, it defines the number of seconds after the sensor’s state expires, if it’s not updated. After expiry, the sensor’s state becomes unavailable. Default the sensors state never expires.

    forceUpdate?: boolean

    Sends update events even if the value hasn’t changed. Useful if you want to have meaningful value graphs in history.

    icon?: string

    Icon of the entity

    lastResetValueTemplate?: string

    Defines a template to extract the last_reset. When last_reset_value_template is set, the state_class option must be total. Available variables: entity_id. The entity_id can be used to reference the entity’s attributes.

    name: string

    Name of the sensor inside Home Assistant

    objectId?: string

    Set this to generate the entity_id in HA instead of using name

    qos?: number

    The maximum QoS level to be used when receiving messages.

    stateClass?: string

    Defines the type of state. If not None, the sensor is assumed to be numerical and will be displayed as a line-chart in the frontend instead of as discrete values.

    suggestedDisplayPrecision?: number

    The number of decimals which should be used in the sensor’s state after rounding.

    uniqueId?: string

    Set this to enable editing sensor from the HA ui and to integrate with a device

    unitOfMeasurement?: string

    Defines the units of measurement of the sensor, if any.

    valueTemplate?: string

    Defines a template to extract the value. If the template throws an error, the current state will be used instead.

    Methods

    • Generates a JSON object that can be used as an MQTT payload.

      Returns Record<string, unknown>

    • Mapping of class properties to MQTT payload keys.

      Returns {
          component: "component";
          device: "device";
          deviceClass: "device_class";
          enabledByDefault: "enabled_by_default";
          entityCategory: "entity_category";
          expireAfter: "expire_after";
          forceUpdate: "force_update";
          icon: "icon";
          lastResetValueTemplate: "last_reset_value_template";
          name: "name";
          objectId: "object_id";
          qos: "qos";
          stateClass: "state_class";
          suggestedDisplayPrecision: "suggested_display_precision";
          uniqueId: "unique_id";
          unitOfMeasurement: "unit_of_measurement";
          valueTemplate: "value_template";
      }