Display entities in a row with separator

Hi all,

I’m breaking my head over this.
A Modbus slave is having 6 registers which contain year, month, day, hour, minute, second.
I want to show these in a card like:

25-12-2024
10:40:30

So far i’m only able to show it like:

(‘25’, ‘12’, ‘2024’)
(‘10’, ‘40’, ‘30’)

with the help of a template:

- platform: template
  sensors:
    date_magnum_heating:
      value_template: "{{states('sensor.magnum_day'), states('sensor.magnum_month'), states('sensor.magnum_year')}}"
 - platform: template
  sensors:
    time_magnum_heating:
      value_template: "{{states('sensor.magnum_hour'), states('sensor.magnum_minute'), states('sensor.magnum_second')}}"

I have no idea how to format it or how to just place the entities in a row with a “-” and “:” separator like:

sensor.magnum_day-magnum-sensor.magnum_month-sensor.magnum_year
sensor.magnum_hour:sensor.magnum_minute:sensor.magnum_second

Any help will be appreciated.

EDIT:
With the solution @atlflyer provided i’ve created a sensor with some formatting if date or time includes a single digit like: H:M:S 1:2:3 will be 01:02:03

  - platform: template
    sensors:
      date_magnum_heating:
        value_template: "{{ '%0.2d' % states('sensor.magnum_day')|int }}-{{ '%0.2d' % states('sensor.magnum_month')|int }}-{{ '%0.4d' % states('sensor.magnum_year')|int }}"
  - platform: template
    sensors:
      time_magnum_heating:
        value_template: "{{ '%0.2d' % states('sensor.magnum_hour')|int }}:{{ '%0.2d' % states('sensor.magnum_minute')|int }}:{{ '%0.2d' % states('sensor.magnum_second')|int }}"

This might be something: GitHub - benct/lovelace-multiple-entity-row: Show multiple entity states and attributes on entity rows in Home Assistant's Lovelace UI

But “name: false” or “name: Day” doesn’t work for entities under: "type: custom: multiple-entity-row. They just disappear after saving.

type: entities
entities:
  - entity: sensor.date_magnum_heating
    show_state: false
    name: false
    icon: mdi:calendar
    type: custom:multiple-entity-row
    entities:
      - sensor.magnum_day
        name: Day #<- disappears.
      - sensor.magnum_month
      - sensor.magnum_year

And how to align the values and put a “-” or “:” between them?

When posting YAML, please be sure to follow the formatting guidance in this post. You should also consider using the new format for template sensor config instead of the retired legacy format.

You can mix templates with dynamic content (inside the curly brackets) with static content (outside), like so:

template:
  - sensor:
    - name: Date Magnum Heating
      state: >
        {{states(‘sensor.magnum_day’)}}-{{states(‘sensor.magnum_month’)}}-{{states(‘sensor.magnum_year’)}}
1 Like

Yes, that works, thank you @atlflyer.
For now i converted it to the old template style.
I will look into the new style.
Thanks again.

(post deleted by author)