Help - Proper format of sensors.yaml file

Better is in the eye of the beholder.

But I will break m y configuration.yaml up into several !included files(or folders) to make it easier to read.

I will then break up the files into multiple files included by folder if the individual files start getting too long.

as an example I use the configuration.yaml file for any one-off individual configurations. I use one !include file for each domain that only has a few entries. Like input booleans or timers.

Then for things like automations that will have many many different entries I will break those up into files that have similar functionality.

For example here is my “automations” folder structure:

ex

Lastly for things that would makes sense for different domains to be grouped together because they make up logical systems then for those I use packages

here is my “packages” folder:

ex2

I am picking up on this old topic as I cannot wrap my head around the YAML-code. I have a similar problem:

  • I have a separate file for my sensors. My configuration.yaml has the line: “sensor: !include sensors.yaml”
  • The below code from my sensors.yaml works fine for my custom sensors that are tracking the power consumption:
### Elpris och elförbrukning ###
- platform: template
  sensors:
    elpris_totalt:
      friendly_name: Totalt elpris
      unit_of_measurement: 'SEK/kWh'
      value_template: >-
        {{ (states('sensor.electricity_price_skogsmyrsvagen')|float + 1.16)|round(2) }}

    fas_a_effekt:
      friendly_name: Effekt fas A
      unit_of_measurement: 'W'
      value_template: >-
        {{ states('sensor.shellyem3_bcff4dfd1b45_channel_a_power')|float }}
        
    fas_b_effekt:
      friendly_name: Effekt fas B
      unit_of_measurement: 'W'
      value_template: >-
        {{ states('sensor.shellyem3_bcff4dfd1b45_channel_b_power')|float }}

    fas_c_effekt:
      friendly_name: Effekt fas C
      unit_of_measurement: 'W'
      value_template: >-
        {{ states('sensor.shellyem3_bcff4dfd1b45_channel_c_power')|float }}

    anlaggning_effekt:
      friendly_name: Effekt hela anläggningen
      value_template: >-
        {{ states('sensor.shellyem3_bcff4dfd1b45_channel_a_power')|float + states('sensor.shellyem3_bcff4dfd1b45_channel_b_power')|float + states('sensor.shellyem3_bcff4dfd1b45_channel_c_power')|float}}

    nuvarande_elkostnad_timme:
      friendly_name: Nuvarande elkostnad per timme
      unit_of_measurement: 'SEK/h'
      value_template: >-
        {{ ((states('sensor.elpris_totalt')|float * states('sensor.anlaggning_effekt')|float) / 1000)|round(1) }}

However, when I now try to add one additional sensor, the Nordpool sensor from HACS, the new nordpool-sensor does not show up. This is the code I try to add in the sensors.yaml just a few rows below the above code:

### Nordpool ###
- platform: nordpool
  region: "SE3"

I do not get any error message and the “Check Configuration” comes back green.

I assume there is something wrong with the intendations but I cannot understand how to use the intendations properly.

I am aware that the second code I am trying to add does not include the line “sensors:”. But if I instead try this code:

### Nordpool ###
- platform: nordpool
  sensor:
    nordpool:
      region: "SE3"

I will get the error message

Invalid config for [sensor.nordpool]: [sensor] is an invalid option for [sensor.nordpool]. Check: sensor.nordpool->sensor. (See ?, line ?).