Cleaning up the config.yaml file

Hi guys, I’m looking to cleanup my main config.yaml file and break it down into smaller more manageable files and I have a question.
I know I can break down each individual component like so:

script: !include scripts.yaml
switch: !include switch.yaml
light: !include light.yaml
group: !include groups.yaml
recorder: !include recorder.yaml

But what if I want to add two integrations to the same yaml file, is that allowed and how?
How would I put both the konnected and alarm_control_panel into an alarm.yaml file and then call that inside config.yaml?

konnected:
  access_token: !secret konnected_token  
  api_host: !secret hassio_ip
  devices:
    - id: !secret konnected_board1
      discovery: false
      host: !secret konnected_board1_ip
      port: !secret konnected_board1_port
      switches:
        - zone: out
          momentary: 500    
          name: 'Trigger Alarm'  
      binary_sensors:
        - zone: 1
          type: door
          name: 'Front Door'
          inverse: true

alarm_control_panel:
  - platform: manual
    name: Home Alarm
    code: !secret alarm_code
    arming_time: 0
    delay_time: 0
    trigger_time: 0
    disarmed:
      trigger_time: 0
    armed_home:
      arming_time: 0
      delay_time: 0

Not sure if there is actually any reason to do this now.
I’m guessing the config will be less and less for each new version.

You are right it does get smaller but I still have quite a few manual configs like this (which will not be added to the integrations list anytime soon) and I would like to break them down a little but cannot find out how to do it this way - I know you can add one integration per file but I want to merge a few

sure, that’s what packages are for.

I think that should be it, I wasn’t aware of the functionality, thanks.
Will try it out :slight_smile:

Ok those two integrations worked just fine but when I tried to add this to the package file it doesn’t like it:

platform: template
sensors: 
  alarm_arm_status:
    friendly_name: Alarm Arm Status
    value_template: >-
      {% if is_state('binary_sensor.alarm_arm_status', 'off') %}
        Disarmed
      {% elif is_state('binary_sensor.alarm_arm_status', 'on') %}
        Armed
      {% else %}
        Unknown
      {% endif %}

Error is expected dict for dictionary value @ data['packages']['alarm']['platform']
Wrong syntax or not allowed to add sensors here?

well, the new template: integration can not be configured in packages unfortunately.

the legacy format can using correct syntax, beginning with the sensor: key

sensor:
  - platform: template
    sensors:
      solar_angle:
        friendly_name: "Sun angle"
        unit_of_measurement: "degrees"
        value_template: "{{ state_attr('sun.sun', 'elevation') }}"

see Template - Home Assistant

Yes, I was missing the sensor: above it, thanks
And I guess scripts and automations also do not work inside the package file?

almost anything works, and scripts and automations most certainly do

1 Like