mqtt2ha
    Preparing search index...

    Class Fan

    Represents a fan in Home Assistant.

    Hierarchy (View Summary)

    Index
    attributesTopic: string

    MQTT topic for entity attributes

    availabilityTopic: string

    MQTT topic for entity availability status

    baseTopicName: string

    Base MQTT topic name for this entity

    commandTopics: CommandTopicConfiguration[] = []

    List of MQTT topics for entity commands.

    component: FanInfo

    The component configuration containing entity-specific settings

    configTopic: string

    MQTT topic for entity configuration

    identifier: string

    Unique identifier for this entity

    logger: Logger

    Logger instance for debugging and error reporting

    mqttClient: MqttClient

    The MQTT client instance used for communication

    The component settings including MQTT configuration

    stateChangedHandler: StateChangedHandler<StateTopicMap>

    Callback function to handle state changes

    stateTopics: StateTopicConfiguration[]

    List of MQTT topics for entity state

    wroteConfiguration: boolean = false

    Flag indicating whether configuration has been written to MQTT

    • get isOn(): boolean | undefined

      Returns boolean | undefined

      Whether the fan is on. Setting a value publishes the configured on/off payload on the state_topic.

    • set isOn(isOn: boolean | undefined): void

      Parameters

      • isOn: boolean | undefined

      Returns void

    • get oscillation(): boolean | undefined

      Returns boolean | undefined

      Whether the fan is oscillating. Setting a defined value publishes the configured oscillation on/off payload on the oscillation_state_topic.

    • set oscillation(oscillation: boolean | undefined): void

      Parameters

      • oscillation: boolean | undefined

      Returns void

    • get percentage(): number | undefined

      Returns number | undefined

      The fan speed as a percentage (0-100). Setting a defined value publishes it on the percentage_state_topic; setting undefined publishes the configured payload_reset_percentage.

    • set percentage(percentage: number | undefined): void

      Parameters

      • percentage: number | undefined

      Returns void

    • get presetMode(): string | undefined

      Returns string | undefined

      The active preset mode. Setting it publishes the value on the preset_mode_state_topic; setting undefined publishes the configured payload_reset_preset_mode.

    • set presetMode(presetMode: string | undefined): void

      Parameters

      • presetMode: string | undefined

      Returns void

    • Clears the entity's retained discovery configuration, causing Home Assistant to remove the entity.

      Use this when an entity that may have been published by a previous run should no longer exist. Because writeConfig retains its payload, simply not calling it leaves the entity in place indefinitely.

      Returns Promise<void>

    • Sets additional attributes for the entity

      Parameters

      • attributes: Record<string, unknown>

        Key-value pairs of attributes to set

      Returns Promise<void>

    • Sets the availability state of the entity

      Parameters

      • availability: boolean

        True if the entity is available, false otherwise

      Returns Promise<void>

    • Sets the state of the entity

      Type Parameters

      • K extends keyof StateTopicMap

      Parameters

      • topicName: K

        The name of the MQTT topic to publish the state to

      • state: StateTopicMap[K]

        The new state to set

      Returns Promise<void>

    • Sets the state of the entity

      Type Parameters

      • K extends keyof StateTopicMap

      Parameters

      • topicName: K

        The name of the MQTT topic to publish the state to

      • state: StateTopicMap[K]

        The new state to set

      Returns void

    • Writes the entity's configuration to MQTT for Home Assistant discovery Also sets the entity's initial availability state if not manually managed

      Returns Promise<void>