Error Message after splitting my configuration.yaml file

I am new to the Home Assistant community. If this thread is in the wrong category, i am thankful for move it to the right one or post a Link to an existing thread.

My Problem is the following:
My parents have bought a PV-System with a battery system. Unfortunately i no integration for the inverter (Kostal PIKO) and the battery (Sonnen) available. They are manged by a proprietary system witch has no connection to Home Assistant. In the Internet i found the work of others to get the information of the inverter and battery.
When i copied the solution right in my configuration.yaml file it worked. Then i moved the API-Token in the secrets.yaml file and it still worked. But to keep every independent input clean and organized i wanted to move every component in its own yaml file. i.e. “inverters.yaml”. With its current Power, daly energy production etc.

The last working configuration.yaml file:

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# Battery sensors: 
rest:
  - resource: http://192.168.1.113:80/api/v2/latestdata
    method: GET
    headers:
      User-Agent: Home Assistant
      Content-Type: application/json
      Auth-Token: secret! SonnenBatterie_API_AUTH_Token

    scan_interval: 1
    timeout: 60
    sensor:
      - name: solar_power_w
        value_template: '{{ value_json["Production_W"] }}'
        unit_of_measurement: W
        device_class: power

      - name: battery_soc
        value_template: '{{ value_json["USOC"] }}'
        unit_of_measurement: "%"
        device_class: battery

      - name: battery_consumption_production_diff
        value_template: '{{ value_json["Pac_total_W"] }}'
        unit_of_measurement: W
        device_class: power

      - name: house_consumption
        value_template: '{{ value_json["Consumption_W"] }}'
        unit_of_measurement: W
        device_class: power

      - name: battery_capacity
        value_template: '{{ value_json["FullChargeCapacity"] }}'
        unit_of_measurement: Wh
        device_class: energy

      - name: battery_soc_energy
        value_template: '{{ (value_json["USOC"]|float / 100 * value_json["FullChargeCapacity"]|float)|round(0)|int }}'
        unit_of_measurement: Wh
        device_class: energy

Then i copied every thing from # Battery sensors: down into the sonnenbatteries.yaml and added the following line under scene: !include scenes.yaml
sonnenbatterie: !include sonnenbatteries.yaml

When i check my configuration with the Devtool i get following error message:
Integration error: sonnenbatterie - Integration ‘sonnenbatterie’ not found.

I am grateful for any help advise. Have a nice Week.
Adrian

The bits you pulled out to a file used to be a section called rest: which is a valid integration. But you placed the include file after a section called sonnenbattery: and that is not a valid integration. That should be rest:

Also make sure that everything in the include file no longer contains the rest: and is also one indentation level less.

Hi Edwin_D,
Thanks for your help. I am right, that i would have to create an own integration called sonnenbattery to push all the senors of the battery into its own .yaml file?
As i understand, i use the Rest-Integration to get the sensor information, can i call it in a separate .yaml file?

you can’t split the config like that.

the configuration.yaml is organized by “key:value” format.

the top level keys in the home assistant configuration.yaml represent integrations (sensor, switch, script, automation) also known as “domains”.

so in the example above the “rest:” key signifies that everything beneath that key is ion the “rest” integration domain.

there is no such integration called "sonnenbatterie’. Hence, the error.

the only way you can split it away is to split the “rest” integration (domain) specifically into it’s own yaml file or in a group of yaml files under a separate folder.

if you want to split all “rest” integration entries under one file do tyhis:

rest: !include rest_sensors.yaml # or whatever you want to call it

if you will have several “rest” sensors under different yaml files then you need to create a folder in your config directory and add the “sonnenbatterie.yaml” file there and then include it like this:

rest: !include_dir_merge_list rest_sensors/ #  or again whatever you want to call the folder

then every yaml file created under that folder will be merged into the “rest:” integration key.

also be sure toi remove the “rest:” key from the top of the included yaml file as it’s not needed since it is already referenced by the !include statement. If you leave it in you’ll get errors.

1 Like

No you can’t “just create” your own integration. if it’s not a core integration already in HA (or a custom integration which is far beyond the scope here) then it won’t be recognized ant it will error.

That’s sounds like what i wanted to do. I will try to set it up, like you described in the first post of finity.

Thanks to both of you for your fast replies and help.
And I wanted to avoid do set up a custom integration. I think with a lot of reading, and coping code examples i would be able to create one, but it sounds like a lot of work ;).

Edit:
I did it like finity told me to set up the files and folders and it worked first try.

rest: !include_dir_merge_list rest_folder #  or again whatever you want to call the folder