Error config: required key not provided @ data['platform']

Hi guys,
I am new to the mqtt configuration and dont have much knowledge of dealing with json. I am trying to configure my tasmota flashed RF bridge with the door and motion sensors, however, when i add the config into the yaml file, im always getting this error:

Invalid config for [sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 11).

I cannot figure out how to fix it. Here is what i have on my binary_sensors.yaml:

mqtt:
 #Roof Door
 sensor:
    - name: "Roof Door"
      state_topic: "tele/bridge/RESULT"
      value_template: '{{value_json.RfReceived.Data}}'
      payload_available: "847BA9"
      payload_off: "847BA9"
      device_class: door
      qos: 1  
     
 #PIR 
   - name: "Motion Stairs"
     state_topic: "tele/bridge/RESULT"
     value_template: '{{value_json.RfReceived.Data}}'
     payload_on: "D238BE"
     payload_off: "D238BE_off"
     device_class: motion
     off_delay: 5
     qos: 1

Could someone please assist what might i be doing wrong here?
Thanks

Yup.
Please post what version of Home Assistant you are actually running.

Home Assistant 2022.10.0
Supervisor 2022.10.0
Operating System 9.0
Frontend 20221005.0 - latest

Thank you.
OK - if looks like your spacing is only one space and not two - so try this:

mqtt:
  #Roof Door
  sensor:
     - name: "Roof Door"
       state_topic: "tele/bridge/RESULT"
       value_template: '{{value_json.RfReceived.Data}}'
       payload_available: "847BA9"
       payload_off: "847BA9"
       device_class: door
       qos: 1  
     
  #PIR 
    - name: "Motion Stairs"
      state_topic: "tele/bridge/RESULT"
      value_template: '{{value_json.RfReceived.Data}}'
      payload_on: "D238BE"
      payload_off: "D238BE_off"
      device_class: motion
      off_delay: 5
      qos: 1

That didnt work, still giving me the same error when running check config

Please post all of your configuration.yaml so I can see what is actually happening before and after line 11.
Also hold on - the spacing is still wrong…

mqtt:
  #Roof Door
  sensor:
    - name: "Roof Door"
      state_topic: "tele/bridge/RESULT"
      value_template: '{{value_json.RfReceived.Data}}'
      payload_available: "847BA9"
      payload_off: "847BA9"
      device_class: door
      qos: 1  
     
  #PIR 
    - name: "Motion Stairs"
      state_topic: "tele/bridge/RESULT"
      value_template: '{{value_json.RfReceived.Data}}'
      payload_on: "D238BE"
      payload_off: "D238BE_off"
      device_class: motion
      off_delay: 5
      qos: 1

The first sensor still had one too many spaces.

I dont believe its a spacing problem, the file check is good, but the check config is the problem.
Here is the configuration.yaml, however, when i # all the lines in binary_sensors.yaml its fine, so it seems that the problem is within the binary_sensors.yaml

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
    ssdp:
    sun:
    system_health:
config:
scene: !include scenes.yaml
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
sensor: !include binary_sensors.yaml 
switch: !include switch.yaml

#SSL setup
http:
    ssl_certificate: /ssl/fullchain.pem
    ssl_key: /ssl/privkey.pem

Also here is a sample of what im getting from the RF bridge:

11:58:11.504 MQT: tele/bridge/RESULT = {"Time":"2022-10-11T11:58:11","RfReceived":{"Sync":7520,"Low":260,"High":740,"Data":"51F333","RfKey":"None"}}

Right yes - so you are including the mqtt stuff INSIDE an included file?

Yes, configuration.yaml just includes all other yaml files.
Is this not recommended?

That’s the problem, you can still have it in a separate file - and include that file, but you cannot do it the way you have - because:
what it actually says is:

binary_sensor:
  mqtt:
    sensor:

which is clearly wrong.

You need to have your mqtt sensors in a new file, which you can then include with:

mqtt: 
  binary_sensor: !include mqtt-binary_sensors.yaml

You don’t include either mqtt or they type of the sensor in the included file obviously.

  #Roof Door
    - name: "Roof Door"
      state_topic: "tele/bridge/RESULT"
      value_template: '{{value_json.RfReceived.Data}}'
      payload_available: "847BA9"
      payload_off: "847BA9"
      device_class: door
      qos: 1  
     
  #PIR 
    - name: "Motion Stairs"
      state_topic: "tele/bridge/RESULT"
      value_template: '{{value_json.RfReceived.Data}}'
      payload_on: "D238BE"
      payload_off: "D238BE_off"
      device_class: motion
      off_delay: 5
      qos: 1
1 Like

Excellent… Thank you so much :slight_smile: i really need to understand my way around these yaml files

As an example - this is the core part of my config:

mqtt:
  sensor: !include_dir_merge_list cfg/_component/mqtt/sensor/
  binary_sensor: !include_dir_merge_list cfg/_component/mqtt/binary_sensor/
  switch: !include_dir_merge_list cfg/_component/mqtt/switch/
sensor: !include_dir_merge_list cfg/_component/sensor/
binary_sensor: !include_dir_merge_list cfg/_component/binary_sensor/
climate: !include_dir_merge_list cfg/climate/
switch: !include_dir_merge_list cfg/_component/switch/
camera: !include_dir_merge_list cfg/_component/camera/
scene: !include scenes.yaml
script: !include scripts.yaml
automation: !include automations.yaml
group: !include_dir_merge_named cfg/_component/group/
light: !include_dir_merge_list cfg/_component/light/
template: !include_dir_merge_list cfg/_component/template/
notify: !include notifiers.yaml

media_player: !include_dir_merge_list cfg/_component/media_player/
timer: !include_dir_merge_named cfg/_component/timer/

Because I have used !include_dir_merge_list it means that I can have multiple files inside the folder for the respective integration - for example:

Inside cfg/_component/mqtt/sensor/ I have:

boiler_temperature.yaml
house_electric.yaml
ruuvi.yaml
temperature_foyer.yaml
temperature_organ_chamber.yaml
1 Like

Thats a better way to have a clean folder structure.

Thanks for the tip :+1:

1 Like