MQTT Fan


mqtt 팬(fan) 플랫폼을 사용하면 MQTT 지원 팬을 제어할 수 있습니다.

설정

이상적인 시나리오에서 MQTT 디바이스에는 상태 변경 사항을 publish하는 state_topic이 있습니다. 이러한 메시지가 RETAIN 플래그와 함께 공개되면 MQTT 팬은 subscription 후 즉시 상태 업데이트를 수신하고 변경된 상태로 시작합니다. 그렇지 않으면 팬의 초기 상태는 false / off입니다.

state_topic을 사용할 수 없으면 팬은 optimistic 모드에서 작동합니다. 이 모드에서 팬은 모든 명령 후 즉시 상태를 변경합니다. 그렇지 않으면 팬은 장치에서 상태 확인을 기다립니다 (state_topic의 메시지).

state_topic이 사용 가능하더라도 Optimistic 모드를 강제할 수 있습니다. 팬이 잘못 작동하면 활성화하십시오.

설치에서 MQTT 팬을 사용하려면 configuration.yaml 파일에 다음을 추가하십시오.

# Example configuration.yaml entry
fan:
  - platform: mqtt
    command_topic: "bedroom_fan/on/set"

Configuration Variables

command_topic

(string)(Required)

The MQTT topic to publish commands to change the fan state.

name

(string)(Optional)

The name of the fan.

Default value:

MQTT Fan

state_topic

(string)(Optional)

The MQTT topic subscribed to receive state updates.

payload_on

(string)(Optional)

The payload that represents the running state.

Default value:

ON

payload_off

(string)(Optional)

The payload that represents the stop state.

Default value:

OFF

state_value_template

(string)(Optional)

Defines a template to extract a value from the state.

qos

(integer)(Optional)

The maximum QoS level of the state topic.

Default value:

0

optimistic

(boolean)(Optional)

Flag that defines if lock works in optimistic mode

Default value:

true if no state topic defined, else false.

retain

(boolean)(Optional)

If the published message should have the retain flag on or not.

Default value:

true

oscillation_state_topic

(string)(Optional)

The MQTT topic subscribed to receive oscillation state updates.

oscillation_command_topic

(string)(Optional)

The MQTT topic to publish commands to change the oscillation state.

payload_oscillation_on

(string)(Optional)

The payload that represents the oscillation on state.

Default value:

oscillate_on

payload_oscillation_off

(string)(Optional)

The payload that represents the oscillation off state.

Default value:

oscillate_off

oscillation_value_template

(string)(Optional)

Defines a template to extract a value from the oscillation.

speed_state_topic

(string)(Optional)

The MQTT topic subscribed to receive speed state updates.

speed_command_topic

(string)(Optional)

The MQTT topic to publish commands to change speed state.

payload_low_speed

(string)(Optional)

The payload that represents the fan’s low speed.

Default value:

low

payload_medium_speed

(string)(Optional)

The payload that represents the fan’s medium speed.

Default value:

medium

payload_high_speed

(string)(Optional)

The payload that represents the fan’s high speed.

Default value:

high

speed_value_template

(string)(Optional)

Defines a template to extract a value from the speed payload.

speeds

(string | list)(Optional)

List of speeds this fan is capable of running at. Valid entries are off, low, medium and high.

availability_topic

(string)(Optional)

The MQTT topic subscribed to receive availability (online/offline) updates.

payload_available

(string)(Optional)

The payload that represents the available state.

Default value:

online

payload_not_available

(string)(Optional)

The payload that represents the unavailable state.

Default value:

offline

json_attributes_topic

(string)(Optional)

The MQTT topic subscribed to receive a JSON dictionary payload and then set as sensor attributes. Usage example can be found in MQTT sensor documentation.

json_attributes_template

(template)(Optional)

Defines a template to extract the JSON dictionary from messages received on the json_attributes_topic. Usage example can be found in MQTT sensor documentation.

unique_id

(string)(Optional)

An ID that uniquely identifies this fan. If two fans have the same unique ID, Home Assistant will raise an exception.

device

(map)(Optional)

Information about the device this fan is a part of to tie it into the device registry. Only works through MQTT discovery and when unique_id is set.

identifiers

(string | list)(Optional)

A list of IDs that uniquely identify the device. For example a serial number.

connections

(list | map)(Optional)

A list of connections of the device to the outside world as a list of tuples [connection_type, connection_identifier]. For example the MAC address of a network interface: "connections": [["mac", "02:5b:26:a8:dc:12"]].

manufacturer

(string)(Optional)

The manufacturer of the device.

model

(string)(Optional)

The model of the device.

name

(string)(Optional)

The name of the device.

sw_version

(string)(Optional)

The firmware version of the device.

topics가 정확히 일치하는지 확인하십시오. some-topic/some-topic은 다른 topic입니다.

사례

이 섹션에는 이 팬을 사용하는 방법에 대한 실제 예가 나와 있습니다.

전체 설정

아래 예는 MQTT 팬의 전체 설정을 보여줍니다.

# Example configuration.yaml entry
fan:
  - platform: mqtt
    name: "Bedroom Fan"
    state_topic: "bedroom_fan/on/state"
    command_topic: "bedroom_fan/on/set"
    oscillation_state_topic: "bedroom_fan/oscillation/state"
    oscillation_command_topic: "bedroom_fan/oscillation/set"
    speed_state_topic: "bedroom_fan/speed/state"
    speed_command_topic: "bedroom_fan/speed/set"
    qos: 0
    payload_on: "true"
    payload_off: "false"
    payload_oscillation_on: "true"
    payload_oscillation_off: "false"
    payload_low_speed: "low"
    payload_medium_speed: "medium"
    payload_high_speed: "high"
    speeds:
      - "off"
      - low
      - medium
      - high