Using YAML Anchors

Trying to optimizie my configuration files, I wanted to use YAML anchors to avoid repetition. It appears that while the achors themselves work. HA also tries to start a component “anchors” with the following YAML code:

anchors:
  homematic-config: &hm-config
    host: 10.0.0.4
    username: Admin
    password: !secret homematic_admin_password

homeassistant:
  name: Home
  ...

lovelace:
  mode: yaml

mqtt:
  broker: localhost
  port: 1883
  client_id: hass
  username: hass
  password: hass
  birth_message:
    topic: 'hass/status'
    payload: 'online'
  will_message:
    topic: 'hass/status'
    payload: 'offline'
  discovery: true

homematic:
  interfaces:
    rf:
      <<: *hm-config
      resolvenames: json
    wired:
      <<: *hm-config
      resolvenames: json
      port: 2000
    ip:
      <<: *hm-config
      resolvenames: json
      port: 2010
    groups:
      <<: *hm-config
      resolvenames: json
      port: 9292
      path: /groups
  hosts:
    ccu2: *hm-config

It causes to problems, but it’s bad to have that error message in the logs. Does anyone know a better way?

Move the anchor to the homematic config, then you can get rid of the anchors entry:

homematic:
  hosts: &hm-config
    host: 10.0.0.4
    username: Admin
    password: !secret homematic_admin_password
  interfaces:
    rf:
      <<: *hm-config
      resolvenames: json
    wired:
      <<: *hm-config
      resolvenames: json
      port: 2000
    ip:
      <<: *hm-config
      resolvenames: json
      port: 2010
    groups:
      <<: *hm-config
      resolvenames: json
      port: 9292
      path: /groups
1 Like