FredericG
(Frederic)
October 24, 2023, 7:25pm
1
Hi,
In the Sonos app I have created many alarms, all 15 minutes apart and in the evening I activate one or 2 of them. Now in HA, I can create buttons in a grid for the alarms but this is a bit tedious as the alarms are named after some internal Sonos ID and I would like the list to be dynamic:
I am trying the auto-entities card which brings me close, but the displayed name should be the alarm-time and not the friendly name.
How could I fix this or do I need to take another approach altogether?
Thanks a lot
Frederic
FredericG
(Frederic)
October 26, 2023, 6:49am
2
I think I have it fixed …
type: custom:auto-entities
card:
type: grid
columns: 4
square: false
card_param: cards
filter:
template: |-
{% for x in (states.switch | sort(attribute='name') | list) -%}
{%- if 'Slaapkamer Daily alarm' in x.name -%}
{{
{
'type': 'button',
'entity': x.entity_id,
'name': state_attr(x.entity_id, 'time')
}
}},
{%- endif -%}
{%- endfor %}
Still need to get rid of the seconds
Better late than never I guess. If you add the regex on the end you will get rid of the seconds:
type: custom:auto-entities
card:
type: grid
columns: 4
square: false
card_param: cards
filter:
template: |-
{% for x in (states.switch | sort(attribute='name') | list) -%}
{%- if 'Slaapkamer Daily alarm' in x.name -%}
{{
{
'type': 'button',
'entity': x.entity_id,
'name': state_attr(x.entity_id, 'time')[0:5]
}
}},
{%- endif -%}
{%- endfor %}