Yaml Automation is Wrong

Hello everyone

I’m new to HA and wanted to do some automation myself in YAML.

Since the heating insert I own has never been used:

https://www.askoma.com/de/produkte/heizen/flansch-heizkoerper/ahfr-bi-plus-44-oe180mm.html

The whole thing works too! But unfortunately the other automations are no longer loaded.

Therefore I did something wrong. Unfortunately I don’t know what… :frowning:

I hope you can help me.

# 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

http:
  ssl_certificate: /ssl/10.0.99.3.pem
  ssl_key: /ssl/10.0.99.3-key.pem
  use_x_forwarded_for: true
  trusted_proxies:
    - 10.0.99.0/24
  ip_ban_enabled: true
  login_attempts_threshold: 5

#******
# Config für den Boiler
#******

input_number:
  min_temp_by_time:
    name: "Minimum Temperatur um Uhrzeit"
    initial: 60
    min: 0
    max: 70
    step: 1
    unit_of_measurement: "°C"
  min_temp_by_day:
    name: "Minimum Temperatur um Uhrzeit"
    initial: 30
    min: 0
    max: 70
    step: 1
    unit_of_measurement: "°C"
  end_temp_by_day:
    name: "Minimum Temperatur um Uhrzeit"
    initial: 40
    min: 0
    max: 70
    step: 1
    unit_of_measurement: "°C"
  testemp:
    name: "testemp"
    initial: 40
    min: 0
    max: 70
    step: 1
    unit_of_measurement: "°C"

input_boolean:
  min_temp_abends:
    name: "Minimum Temperatur bei Zeit abends"
    initial: false
  minimal_waerme_ein:
    name: "Aktiviert die Minimale Waerme"
    initial: false
  notfall_heizung:
    name: "Aktiviert Heizen"
    initial: false

input_datetime:
  einschalten_wen_kalt:
    name: Einschaltzeit wen Boiler noch kalt ist
    has_date: false
    has_time: true
    initial: "19:00:00"
  ausschalten_wen_kalt:
    name: Ausschaltzeit wen Boiler noch kalt ist
    has_date: false
    has_time: true
    initial: "05:00:00"

# Variablen von Heizeinsatz
sensor:
  - platform: rest
    name: "Boiler Temperatur"
    device_class: temperature
    resource: http://10.0.99.6/status.json
    method: GET
    value_template: "{{ value_json.ACTUAL_VALUES.TEMP_SENSOR_0.split(' ')[0] | int }}"
    unit_of_measurement: "°C"
    scan_interval: 10

  - platform: rest
    name: "Boiler aktuelle Heizleistung"
    resource: http://10.0.99.6/status.json
    method: GET
    value_template: "{{ value_json.ACTUAL_VALUES.ACTUAL_HEATER_LOAD.split(' ')[0] | int }}"
    unit_of_measurement: "W"
    scan_interval: 10

  - platform: rest
    name: "Boiler Heizlimite"
    resource: http://10.0.99.6/status.json
    method: GET
    value_template: "{{ value_json.TEMPERATURE_CONTROL.ACTUAL_TEMPERATURE_LIMIT.split(' ')[0] | int }}"
    unit_of_measurement: "°C"
    scan_interval: 10

  - platform: rest
    name: "Boiler aktuelle Heizstufe"
    resource: http://10.0.99.6/status.json
    method: GET
    value_template: "{{ value_json.ACTUAL_VALUES.ACTUAL_HEATER_STEP }}"
    scan_interval: 10

# Set befehl für Heizeinsatz
rest_command:
  set_modbus_cmd_load_setpoint_value:
    url: "http://10.0.99.6/getcmd.json"
    method: post
    headers:
      Content-Type: application/json
    payload: '{"MODBUS_CMD_LOAD_SETPOINT_VALUE": "{{ value }}"}'


    automation:
  - alias: "Set MODBUS_CMD_LOAD_SETPOINT_VALUE"
    trigger:
      - platform: time_pattern
        seconds: "/30"  # Diese Automatisierung wird alle 5 Sekunden ausgelöst
    action:
      - choose:
          # Notfallschaltung
          - conditions: 
              - condition: state
                entity_id: input_boolean.notfall_heizung
                state: 'on'
            sequence:
              - service: rest_command.set_modbus_cmd_load_setpoint_value
                data:
                  value: 4400
          # NotfallSchaltung END

          # Abendschaltung mit flexiblen werten
          - conditions: 
              - condition: state
                entity_id: input_boolean.min_temp_abends
                state: 'on'
              - condition: time
                after: input_datetime.einschalten_wen_kalt
                before: input_datetime.ausschalten_wen_kalt
              - condition: numeric_state
                entity_id: sensor.boiler_temperatur
                below: input_number.min_temp_by_time
            sequence:
              - service: rest_command.set_modbus_cmd_load_setpoint_value
                data:
                  value: 4400
          # Abendschaltung mit flexivlen werten END
        # NormaleSchaltung
        default:
          - service: rest_command.set_modbus_cmd_load_setpoint_value
            data:
              value: "{{ states('sensor.sofar_ActivePower_PCC_Total') }}"


You want your automations in automations.yaml, not configuration.yaml. Make sure you have this entry in configuration.yaml: automation: !include automations.yaml

The automation keyword should not be indented…

[quote=“simontiefenbacher, post:1,
topic:736074”]

payload: '{"MODBUS_CMD_LOAD_SETPOINT_VALUE": "{{ value }}"}'

# THIS FOLLOWING LINE WAS INDENTED TOO FAR
automation:
  - alias: "Set MODBUS_CMD_LOAD_SETPOINT_VALUE"
    trigger:
      - platform: time_pattern
        seconds: "/30"  # Diese Automatisierung wird alle 5 Sekunden ausgelöst

Welcome to the forum! :slight_smile:

As you’re a beginner, you’re now at that point, where you want to start sorting and ordering things in your configuration. It will be getting un-readable or difficult to maintain in the near future. The solution to this is splitting up your configuration, as you already do by including a separate file for automations, scripts and scenes. :slight_smile: These names are so called “domains”. Automation is a domain, light, script, fan and so on.

Domains can only be included once, so if you have your automation domain setup in a separate file, it should raise an error, saying that you can’t include domains twice. As you would do with automation: in the automations.yaml file as well as in your configuration.yaml.

I would highly recommend reading up on splitting your configuration, as there are numerous ways to do that. My personal favourite are packages, as they are easy to setup and even easier to use.

Here are the docs on splitting the config:

And here are packages:

1 Like