Configuration yaml help for sensor

I have these two entries in my /config/configuration.yaml No matter how I put them I can only get one to work. I can’t figure out what to add or the order to make both parts work. Any guidance? I’ve been fighting this one for a while now. I can’t find any reference to help solve it.

sensor: !include sensor.yaml

sensor:
  - platform: history_stats
    name: Well Pump ON today
    entity_id: binary_sensor.well_pump
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
    end: "{{ now() }}"

IIRC, the include should be a child of the homeassistant key.

homeassistant:
  sensor: !include sensor.yaml

sensor:
  - platform: history_stats
    name: Well Pump ON today
    entity_id: binary_sensor.well_pump
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
    end: "{{ now() }}"

Thanks for the suggestion. When I put the include as a child, I get a configuration error.

Configuration invalid!
extra keys not allowed @ data[‘sensor’]

What is your thought about that?

Sorry about that… it’s been a while since I switched to Packages (which I highly recommend if you’re planning on using multiple directories to organized you config.

You can use a split:

sensor split: !include sensor.yaml

sensor:
  - platform: history_stats
    name: Well Pump ON today
    entity_id: binary_sensor.well_pump
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
    end: "{{ now() }}"

Just make sure that your history stats sensor and all other sensors in the configuration.yaml file are nest under a single top-level sensor key.

Thanks for the help! I used the split method just because it was easy.