A while back I created a “smart fan” using an esp8266 with an rf transmitter, and mqtt to control the fan speed settings. Recently I discovered hassio and would love to include fan control, but I am a beginner and don’t have any clue how to add a fan to the lovelace ui and configure it properly.
Any help would be appreciated.
Here is the doc page for an MQTT fan:
And here is an example of using that config to set up a fan (iFan03) running Tasmota. But as long as you have the basic entries in this config it should be able to be adapted to any MQTT fan:
- platform: mqtt
name: "Master Bedroom Fan"
command_topic: "cmnd/iFan03-2/FanSpeed"
speed_command_topic: "cmnd/iFan03-2/FanSpeed"
state_topic: "stat/iFan03-2/RESULT"
speed_state_topic: "stat/iFan03-2/RESULT"
state_value_template: >
{% if value_json.FanSpeed is defined %}
{% if value_json.FanSpeed == 0 -%}0{%- elif value_json.FanSpeed > 0 -%}4{%- endif %}
{% else %}
{% if states.fan.master_bedroom_fan.state == 'off' -%}0{%- elif states.fan.master_bedroom_fan.state == 'on' -%}4{%- endif %}
{% endif %}
speed_value_template: "{{ value_json.FanSpeed }}"
availability_topic: tele/iFan03-2/LWT
payload_off: "0"
payload_on: "4"
payload_low_speed: "1"
payload_medium_speed: "2"
payload_high_speed: "3"
payload_available: Online
payload_not_available: Offline
speeds:
- "off"
- low
- medium
- high