I have been banging my head against the wall on this one. No matter what I try I can not see the state of this fan in Home Assistant, it only shows as “unkown”. I can see it in MQTT Explorer and if I call the same state topic through a switch but it just will not give me the state when used for the fan below. My preset mode topics work fine but the state_topic does nothing. Any ideas? Thanks.
fan:
- platform: mqtt
name: Samuel Fan
availability_topic: "home/OpenMQTTGateway/LWT"
state_topic: "home/OpenMQTTGateway/433toMQTT/Samuel_Fan/state"
command_topic: "home/OpenMQTTGateway/commands/MQTTto433"
state_value_template: "{{ value_json.value }}"
payload_on: '{"value":16774298,"protocol":11,"length":24,"delay":386, "repeat": 5}'
payload_off: '{"value":16774299,"protocol":11,"length":24,"delay":386, "repeat": 5}'
qos: "0"
retain: true
preset_modes:
- "off"
- "high"
- "medium"
- "low"
preset_mode_command_topic: "home/OpenMQTTGateway/commands/MQTTto433"
preset_mode_command_template: >
{% if value == 'high' %}
{"value":16774145,"protocol":11,"length":24,"delay":386, "repeat": 5}
{% elif value == 'medium' %}
{"value":16774146,"protocol":11,"length":24,"delay":386, "repeat": 5}
{% elif value == 'low' %}
{"value":16774147,"protocol":11,"length":24,"delay":386, "repeat": 5}
{% else %}
{"value":16774144,"protocol":11,"length":24,"delay":386, "repeat": 5}
{% endif %}
preset_mode_state_topic: "home/OpenMQTTGateway/433toMQTT/Samuel_Fan/speed"
preset_mode_value_template: "{{ value_json.value }}"