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 }}"