Packages and !include in ESPHome fail

Hi, all!

I am playing with packages and !include the the yaml file in ESPHome, but it seems I am missing something.
First I define common/sensor/wifi_signal.config.yaml

- platform: wifi_signal
  name: ${friendly_name} WiFi signal
  update_interval: 600s

Then I would reference this in the main configuration file, eg. /config/esphome/led_sofie_tak.yaml

sensor:
  - !include common/sensor/wifi_signal.config.yaml
  - platform: dallas
    name: ${sensor_temperatur}
    unit_of_measurement: "°C"  
    index: 0
    filters:
      - offset: -3.7

I get this error when validating

Failed config

sensor.unknown: [source /config/esphome/led_sofie_tak.yaml:42]
  
  Platform schemas must be key-value pairs.
  - platform: uptime
    name: LED Sofie tak Uptime

The packages reference:

packages:
  wifi: !include common/wifi.yaml

validates OK, though :slight_smile:
What am I missing here?

Solved this!
Solution is to not use the !include statement within sensor:, but rather put the !include: within packages: which will be defined in the top level config.yaml (/config/esphome/led_sofie_tak.yaml)

I then realized the sensor: can be defined both from a local reference within the config.yaml and in a referenced yaml via !include:

2 Likes