mqtt yaml error

Configuration warnings

Invalid config for ‘mqtt’ at configuration.yaml, line 16: ‘mqtt’ is an invalid option for ‘mqtt’, check: mqtt->0->mqtt

It would be a good idea if you showed the contents of the file.

1 Like

mqtt:
fan:
- name: “obk-livingroom-2 Ceiling Fan”
unique_id: “1216C29E_1”
icon: mdi:ceiling-fan
availability:
- topic: “obk-livingroom-2/connected”
state_topic: “obk-livingroom-2/1/get”
command_topic: “obk-livingroom-2/1/set”
payload_on: 1
payload_off: 0
percentage_state_topic: “obk-livingroom-2/3/get”
percentage_value_template: >-
{% if value == ‘0’ %}
0
{% elif value == ‘1’ %}
10
{% elif value == ‘2’ %}
30
{% elif value == ‘3’ %}
50
{% elif value == ‘4’ %}
70
{% else %}
100
{% endif %}
percentage_command_topic: “obk-livingroom-2/3/set”
percentage_command_template: >-
{% if value <= 1 %}
0
{% elif value > 1 and value < 20 %}
1
{% elif value >= 20 and value < 40 %}
2
{% elif value >= 40 and value < 60 %}
3
{% elif value >= 60 and value < 80 %}
4
{% else %}
5
{% endif %}
qos: 1
retain: true
number:
- name: “obk-livingroom-2 Ceiling Fan Countdown”
unique_id: “1216C29E_22”
icon: mdi:cog-counterclockwise
availability:
- topic: “obk-livingroom-2/connected”
state_topic: “obk-livingroom-2/22/get”
command_topic: “obk-livingroom-2/22/set”
qos: 1

switch:
- name: “obk-livingroom-2 Ceiling Fan Child Lock”
unique_id: “1216C29E_14”
icon: mdi:toggle-switch
availability:
- topic: “obk-livingroom-2/connected”
state_topic: “obk-livingroom-2/14/get”
state_on: 1
state_off: 0
command_topic: “obk-livingroom-2/14/set”
payload_on: 1
payload_off: 0
qos: 1
retain: true

sensor:
- name: “obk-livingroom-2 IP”
unique_id: “1216C29E_IP”
icon: mdi:ip-network
availability:
- topic: “obk-livingroom-2/connected”
state_topic: “obk-livingroom-2/IP/get”
qos: 1

switch:

  • platform: template
    switches:
    living_room_ceiling_fan_speed_lowest:
    friendly_name: Lowest
    unique_id: “living_room_ceiling_fan_speed_1”
    icon_template: >-
    mdi:fan-speed-1
    value_template: “{{ is_state(‘input_number.living_room_ceiling_fan_speed’, ‘1.0’) and is_state(‘fan.obk_livingroom_2_ceiling_fan’, ‘on’) }}”
    turn_on:
    - service: fan.turn_on
    target:
    entity_id: fan.obk_livingroom_2_ceiling_fan
    - service: fan.set_percentage
    data:
    percentage: 10
    target:
    entity_id: fan.obk_livingroom_2_ceiling_fan
    turn_off:
    - service: fan.turn_off
    target:
    entity_id: fan.obk_livingroom_2_ceiling_fan

    living_room_ceiling_fan_speed_low:
    friendly_name: Low
    unique_id: “living_room_ceiling_fan_speed_2”
    icon_template: >-
    mdi:fan-speed-2
    value_template: “{{ is_state(‘input_number.living_room_ceiling_fan_speed’, ‘2.0’) and is_state(‘fan.obk_livingroom_2_ceiling_fan’, ‘on’) }}”
    turn_on:
    - service: fan.turn_on
    target:
    entity_id: fan.obk_livingroom_2_ceiling_fan
    - service: fan.set_percentage
    data:
    percentage: 30
    target:
    entity_id: fan.obk_livingroom_2_ceiling_fan
    turn_off:
    - service: fan.turn_off
    target:
    entity_id: fan.obk_livingroom_2_ceiling_fan

    living_room_ceiling_fan_speed_med:
    friendly_name: Medium
    unique_id: “living_room_ceiling_fan_speed_3”
    icon_template: >-
    mdi:fan-speed-3
    value_template: “{{ is_state(‘input_number.living_room_ceiling_fan_speed’, ‘3.0’) and is_state(‘fan.obk_livingroom_2_ceiling_fan’, ‘on’) }}”
    turn_on:
    - service: fan.turn_on
    target:
    entity_id: fan.obk_livingroom_2_ceiling_fan
    - service: fan.set_percentage
    data:
    percentage: 50
    target:
    entity_id: fan.obk_livingroom_2_ceiling_fan
    turn_off:
    - service: fan.turn_off
    target:
    entity_id: fan.obk_livingroom_2_ceiling_fan

    living_room_ceiling_fan_speed_high:
    friendly_name: High
    unique_id: “living_room_ceiling_fan_speed_4”
    icon_template: >-
    mdi:fan
    value_template: “{{ is_state(‘input_number.living_room_ceiling_fan_speed’, ‘4.0’) and is_state(‘fan.obk_livingroom_2_ceiling_fan’, ‘on’) }}”
    turn_on:
    - service: fan.turn_on
    target:
    entity_id: fan.obk_livingroom_2_ceiling_fan
    - service: fan.set_percentage
    data:
    percentage: 70
    target:
    entity_id: fan.obk_livingroom_2_ceiling_fan
    turn_off:
    - service: fan.turn_off
    target:
    entity_id: fan.obk_livingroom_2_ceiling_fan

    living_room_ceiling_fan_speed_highest:
    friendly_name: Highest
    icon_template: >-
    mdi:fan
    unique_id: “living_room_ceiling_fan_speed_5”
    value_template: “{{ is_state(‘input_number.living_room_ceiling_fan_speed’, ‘5.0’) and is_state(‘fan.obk_livingroom_2_ceiling_fan’, ‘on’) }}”
    turn_on:
    - service: fan.turn_on
    target:
    entity_id: fan.obk_livingroom_2_ceiling_fan
    - service: fan.set_percentage
    data:
    percentage: 90
    target:
    entity_id: fan.obk_livingroom_2_ceiling_fan
    turn_off:
    - service: fan.turn_off
    target:
    entity_id: fan.obk_livingroom_2_ceiling_fan

Please format it properly with the </> button. Should look like this:

mqtt:
  fan:
    - name: "obk-livingroom-2 Ceiling Fan"
      unique_id: "1216C29E_1"

You’ll have to re-paste it as the quotes and indentation are destroyed in the prior version.

Also, that’s not the entire file. Please include everything before the mqtt: as I suspect the error is there.

1 Like

yaml file create mqtt format properly, but same error again will show.

That’s not configuration.yaml, that’s a separate file. Please don’t paste code as screenshots.

I guess that your configuration.yaml has a line like this:

mqtt: !include mqtt.yaml

and the file you’ve screenshotted is mqtt.yaml. Correct?

If that is correct, just remove the first line from that file so it starts:

  fan:

but you’ll also need to move the template switch definitions (e.g. living_room_ceiling_fan_speed_lowest) out of the MQTT file.

1 Like

thankyou for quick reply!!!