Look in the Cookbook at YAML-Advanced.
I have been using a mixture of Legacy format and New Format for quite some time. @jyavenard it sounds like you are already setup with ‘packages’
My Configuration
In configuration.yaml
# Home Assistant Core Configuration
homeassistant:
allowlist_external_dirs:
- "/config"
packages: !include_dir_named packages
My Packages Folder
/config/packages
Example of using mixed Legacy Template and New Template Format in a Package
garden_irrigation.yaml
# SENSORS ---------------------------------------------------------------------
sensor:
# Rain Last 7 Days (mm) (Outputs Rain Accumulation Last 7 Days) - Common to ALL
- platform: statistics
name: "Rain last 7 days"
unique_id: afe4b9f2-d0a6-4c42-86eb-786737f2ea14
entity_id: sensor.netatmo_devonport_tas_indoor_rain_rain_today
state_characteristic: sum_differences_nonnegative
max_age:
minutes: 10080
precision: 1
keep_last_sample: true
# TEMPLATE SENSORS LEGACY FORMAT -----------------------------------------------------------
- platform: template
sensors:
# Back Garden Water Valve - 0 or 1 for Mini Graph Card
back_garden_valve_on_off:
unique_id: 686b9ef3-26fa-4057-9734-f4cd39f41749
friendly_name: "Back Garden Water Valve ON OFF"
value_template: >-
{%- if is_state('switch.back_garden_water_valve_state', 'on') %}
0
{%- elif is_state('switch.back_garden_water_valve_state', 'off') %}
1
{% else %}
1
{%- endif -%}
# Template for RAIN VOLUME LAST 7 DAYS - Back Garden - (= Rain 7 Days * Set Garden Area)
rain_volume_7_days:
unique_id: 88518e81-3826-4efa-9501-388afc1dfeaa
friendly_name: Rain Volume Last 7 Days
unit_of_measurement: L
value_template: "{{(states('sensor.rain_last_7_days') | float(0)) * (states('input_number.back_garden_set_area') | float(0)) | round(1)}}"
# TEMPLATE SENSORS NEW FORMAT ---------------------------------------------------------------------
# Template Time Since Last ON Back Garden (Outputs timestamp of last ON)
template:
- trigger:
- trigger: state
entity_id: switch.back_garden_water_valve_state
to: "on"
sensor:
- name: back_garden_valve_last_on
unique_id: 20ed7a5b-7878-47d4-9515-7150e46c4660
state: "{{ as_timestamp(states('sensor.date_time_iso')) | timestamp_custom('%H:%M %a %b %d') }}"
# Template Time Since Last ON Side Garden (Outputs timestamp of last ON)
- trigger:
- trigger: state
entity_id: switch.side_garden_water_valve_state
to: "on"
sensor:
- name: side_garden_valve_last_on
unique_id: 07805459-cad0-4bf2-9c8f-6d9201144267
state: "{{ as_timestamp(states('sensor.date_time_iso')) | timestamp_custom('%H:%M %a %b %d') }}"
@petro it may pay to place another little note in your repair notifications.
Note: If there are any existing
template:sections in your configuration, make sure to omit thetemplate:line from the yaml above. There can only be 1template:section inconfiguration.yaml. Also, ensure the indentation is aligned with the existing entities within thetemplate:section.
Note: Advanced YAML configurations like Splitting Configuration and Packages are still supported. Each package can contain a
template:section.
Even though users with Advanced Configurations should already know this, it may assist other users that read the repair literally.

