Hi,
Thanks for sharing the code. I got most of the stuff to work but have 3 issues
- Islamic date wonβt show up on the top
- the timer bar wonβt work
- not able to get Fajr & Ψ§ΩΩΨ¬Ψ± in separate lines
This is yaml for my card
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
</>type: custom:stack-in-card
cards:
- type: custom:button-card
variables:
currentview: |
[[[
return window.location.pathname.split(β/β).slice(-1);
]]]
entity: sensor.islamic_day
show_name: false
show_state: true
color_type: card
card_mod:
style: |
ha-card {
margin-top: 1px;
margin-bottom: 1px;
margin-left: 1px;
margin-right: 10px;
border: skyblue solid 5px !important;
}
styles:
card:
- height: 3em
- align: center
- font-weight: bold
- background-color: ββ
- color: orange
- type: custom:layout-card
layout_type: custom:grid
layout:
grid-template-columns: auto 100px
grid-template-rows: auto auto
margin: β-4px 0px -10px -4px;β
cards:
-
type: custom:mushroom-template-card
primary: Prayer Times | Ψ£ΩΩΨ§Ψͺ Ψ§ΩΨ΅ΩΨ§Ψ©
secondary: |-
Next Prayer: {{ states(βsensor.next_prayerβ) }} | Starts in {{
states(βsensor.time_until_next_prayerβ) }}
icon: mdi:mosque
entity: sensor.next_prayer
tap_action:
action: none
hold_action:
action: none
icon_color: blue
fill_container: false
multiline_secondary: false
card_mod:
style:
.: |
ha-card {
background: none;
box-shadow: none;
font-style: italic;
font-variant: small-caps;
}
mushroom-state-info$: |
.container {
--primary-text-color: rgba(255, 255, 255, 0.9); /* White with slight transparency for high legibility */
--secondary-text-color: rgba(255, 235, 59, 0.9); /* A soft amber for a warm contrast */
}
-
type: custom:mushroom-template-card
primary: Now is
secondary: β{{ states(βsensor.current_prayerβ) }} timeβ
entity: sensor.current_prayer
tap_action:
action: none
hold_action:
action: none
icon_color: blue
fill_container: false
multiline_secondary: false
card_mod:
style:
.: |
ha-card {
background: #A100ff;
box-shadow: none;
font-style: italic;
font-variant: small-caps;
font-weight: bold
}
mushroom-state-info$: |
.container {
--primary-text-color: rgba(255, 255, 255, 0.9); /* White with slight transparency for high legibility */
--secondary-text-color: rgba(0, 255, 206, 0.9); /* A soft amber for a warm contrast */
--card-secondary-font-size: 13px;
align-items: center;
}
- type: custom:timer-bar-card
entity: sensor.next_prayer_timer
name: Until Next Prayer
icon: mdi:clock
- type: horizontal-stack
cards:
-
type: custom:mushroom-template-card
primary: Fajr / Ψ§ΩΩΨ¬Ψ±
secondary: β{{ states(βsensor.fajr_timeβ) }}β
icon: mdi:mosque
icon_color: β#Fff600β
layout: vertical
tap_action:
action: more-info
entity: sensor.current_prayer
card_mod:
style: |
ha-card {
{% if states(βsensor.current_prayerβ) == βFajrβ %}
border: 1px outset green;
background: rgba(161, 0, 255, 0.5) !important;
{% else %}
background: rgba(21,76,121, 0.5) !important;
{% endif %}
width: 75px;
padding: 8px !important;
margin-bottom: 5px;
box-shadow: var(βha-card-box-shadow) !important;
border-radius: 15px !important;
margin-left: auto;
margin-right: auto;
}
ha-card:hover {
background: rgba(255, 235, 59, 0.5) !important;
border-color: orange;
}
ha-state-icon {
{% if states(βsensor.current_prayerβ) == βFajrβ %}
animation: spin 2s linear infinite;
{% endif %}
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
-
type: custom:mushroom-template-card
primary: Dhuhr
secondary: |
{{ states(βsensor.dhuhr_timeβ) }}
tap_action:
action: more-info
entity: sensor.current_prayer
icon: mdi:mosque-outline
icon_color: β#Ffa800β
layout: vertical
card_mod:
style:
.: |
ha-card {
/* Set size and spacing of button */
{% if states('sensor.current_prayer') == 'Dhuhr' %}
border: 1px outset green; /* Example border color */
background: rgba(161, 0, 255, 0.5) !important;
{% else %}
background: rgba(21,76,121, 0.5) !important;
{% endif %}
width: 75px;
--spacing: 8px;
padding-bottom: calc(var(--spacing) * 1.718) !important;
margin-bottom: 5px;
/* Styling of button */
box-shadow: var(--ha-card-box-shadow) !important;
border-radius: calc(var(--ha-card-border-radius, 15px) * 1 ) !important;
/* Center button */
margin-left: auto;
margin-right: auto;
transition: all 0s;
}
/* Add subtle color on hover */
ha-card:hover {
background: rgba(255, 235, 59, 0.5) !important; /* Soft amber on hover with reduced opacity */
border-color: orange; /* Orange border on hover */
}
ha-state-icon {
{% if states('sensor.current_prayer') == 'Dhuhr' %}
animation: spin 2s linear infinite;
{% endif %}
}
@keyframes spin {
0% {transform: rotate(0deg);}
mushroom-state-info$: |
.primary:after {
content: 'Ψ§ΩΨΈΩΨ±';
display: flex;
flex-direction: column;
color: skyblue;
}
.container {
--secondary-text-color: rgba(238,238,228, 0.9); /* A soft amber for a warm contrast */
--primary-text-color: orange;
}
-
type: custom:mushroom-template-card
primary: Asr
secondary: |
{{ states(βsensor.asr_timeβ) }}
icon: mdi:mosque
icon_color: β#2fff00β
layout: vertical
tap_action:
action: more-info
entity: sensor.current_prayer
card_mod:
style:
.: |
ha-card {
/* Set size and spacing of button */
{% if states('sensor.current_prayer') == 'Asr' %}
border: 1px outset green; /* Example border color */
background: rgba(161, 0, 255, 0.5) !important;
{% else %}
background: rgba(21,76,121, 0.5) !important;
{% endif %}
width: 75px;
--spacing: 8px;
padding-bottom: calc(var(--spacing) * 1.718) !important;
margin-bottom: 5px;
/* Styling of button */
box-shadow: var(--ha-card-box-shadow) !important;
border-radius: calc(var(--ha-card-border-radius, 15px) * 1 ) !important;
/* Center button */
margin-left: auto;
margin-right: auto;
transition: all 0s;
}
/* Add subtle color on hover */
ha-card:hover {
background: rgba(255, 235, 59, 0.5) !important; /* Soft amber on hover with reduced opacity */
border-color: orange; /* Orange border on hover */
}
ha-state-icon {
{% if states('sensor.current_prayer') == 'Asr' %}
animation: spin 2s linear infinite;
{% endif %}
}
@keyframes spin {
0% {transform: rotate(0deg);}
mushroom-state-info$: |
.primary:after {
content: 'Ψ§ΩΨΉΨ΅Ψ±';
display: flex;
flex-direction: column;
color: skyblue;
}
.container {
--secondary-text-color: rgba(238,238,228, 0.9); /* A soft amber for a warm contrast */
--primary-text-color: orange;
}
-
type: custom:mushroom-template-card
primary: |
Maghrib
Ψ§ΩΩ
ΨΊΨ±Ψ¨
secondary: |
{{ states(βsensor.maghrib_timeβ) }}
icon: mdi:mosque-outline
icon_color: β#00d5ffβ
layout: vertical
tap_action:
action: more-info
entity: sensor.current_prayer
card_mod:
style:
.: |
ha-card {
/* Set size and spacing of button */
{% if states('sensor.current_prayer') == 'Maghrib' %}
border: 1px outset green; /* Example border color */
background: rgba(161, 0, 255, 0.5) !important;
{% else %}
background: rgba(21,76,121, 0.5) !important;
{% endif %}
width: 75px;
--spacing: 8px;
padding-bottom: calc(var(--spacing) * 1.718) !important;
margin-bottom: 5px;
/* Styling of button */
box-shadow: var(--ha-card-box-shadow) !important;
border-radius: calc(var(--ha-card-border-radius, 15px) * 1 ) !important;
/* Center button */
margin-left: auto;
margin-right: auto;
transition: all 0s;
}
/* Add subtle color on hover */
ha-card:hover {
background: rgba(255, 235, 59, 0.5) !important; /* Soft amber on hover with reduced opacity */
border-color: orange; /* Orange border on hover */
}
ha-state-icon {
{% if states('sensor.current_prayer') == 'Maghrib' %}
animation: spin 2s linear infinite;
{% endif %}
}
@keyframes spin {
0% {transform: rotate(0deg);}
mushroom-state-info$: |
.primary:after {
content: 'Ψ§ΩΩ
ΨΊΨ±Ψ¨';
display: flex;
flex-direction: column;
color: skyblue;
}
.container {
--secondary-text-color: rgba(238,238,228, 0.9); /* A soft amber for a warm contrast */
--primary-text-color: orange;
-
type: custom:mushroom-template-card
primary: Isha
secondary: |
{{ states(βsensor.isha_timeβ) }}
tap_action:
action: more-info
entity: sensor.current_prayer
icon: mdi:mosque
icon_color: β#B6ff00β
layout: vertical
card_mod:
style:
.: |
ha-card {
/* Set size and spacing of button */
{% if states('sensor.current_prayer') == 'Isha' %}
border: 1px outset green; /* Example border color */
background: rgba(161, 0, 255, 0.5) !important;
{% else %}
background: rgba(21,76,121, 0.5) !important;
{% endif %}
width: 75px;
--spacing: 8px;
padding-bottom: calc(var(--spacing) * 1.718) !important;
margin-bottom: 5px;
/* Styling of button */
box-shadow: var(--ha-card-box-shadow) !important;
border-radius: calc(var(--ha-card-border-radius, 15px) * 1 ) !important;
/* Center button */
margin-left: auto;
margin-right: auto;
transition: all 0s;
}
/* Add subtle color on hover */
ha-card:hover {
background: rgba(255, 235, 59, 0.5) !important; /* Soft amber on hover with reduced opacity */
border-color: orange; /* Orange border on hover */
}
ha-state-icon {
{% if states('sensor.current_prayer') == 'Isha' %}
animation: spin 2s linear infinite;
{% endif %}
}
@keyframes spin {
0% {transform: rotate(0deg);}
mushroom-state-info$: |
.primary:after {
content: 'Ψ§ΩΨΉΨ΄Ψ§Ψ‘';
display: flex;
flex-direction: column;
color: skyblue;
}
.container {
--secondary-text-color: rgba(238,238,228, 0.9); /* A soft amber for a warm contrast */
--primary-text-color: orange;
}
card_mod:
style: |
ha-card {
/* Styling of card background */
background: linear-gradient(to bottom right, rgba(95, 158, 160, 0.85, 0.85) 30%, rgba(33,19,13, 0.85) 100%);
}</>
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
These are my sensorsβ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
</> - sensor:
- name: βNext Prayerβ
state: >
{% set current = now().strftime(β%H:%Mβ) %}
{% set times = {
βFajrβ: states(βsensor.fajr_timeβ),
βDhuhrβ: states(βsensor.dhuhr_timeβ),
βAsrβ: states(βsensor.asr_timeβ),
βMaghribβ: states(βsensor.maghrib_timeβ),
βIshaβ: states(βsensor.isha_timeβ),
βSunriseβ: states(βsensor.sunrise_timeβ)
} %}
{% set next = namespace(name=βIshaβ, time=times[βIshaβ]) %}
{% for name, time in times.items() %}
{% if time and β:β in time and time > current %}
{% set next.name = name %}
{% set next.time = time %}
{% break %}
{% endif %}
{% endfor %}
{{ next.name }} | {{ next.time }}
- name: "Time Until Next Prayer"
state: >
{% set current = now() %}
{% set next_prayer = states('sensor.next_prayer').split('|')[1] | trim %}
{% if ':' in next_prayer %}
{% set prayer_hour = next_prayer.split(':')[0] | int %}
{% set prayer_minute = next_prayer.split(':')[1] | int %}
{% set prayer_time = current.replace(
hour=prayer_hour,
minute=prayer_minute,
second=0,
microsecond=0
) %}
{% if prayer_time < current %}
{% set prayer_time = prayer_time + timedelta(days=1) %}
{% endif %}
{% set diff = prayer_time - current %}
{% set total_minutes = diff.total_seconds() // 60 %}
{% set hours = (total_minutes // 60) | int %}
{% set minutes = (total_minutes % 60) | int %}
{% if hours > 0 %}
{{ hours }}h {{ minutes }}m
{% else %}
{{ minutes }}m
{% endif %}
{% else %}
0m
{% endif %}
- name: "Current Prayer"
state: >
{% set current = now().strftime('%H:%M') %}
{% set prayers = [
['Fajr', states('sensor.fajr_time')],
['Dhuhr', states('sensor.dhuhr_time')],
['Asr', states('sensor.asr_time')],
['Maghrib', states('sensor.maghrib_time')],
['Isha', states('sensor.isha_time')]
] %}
{# Handle overnight period (after Isha until Fajr) #}
{% if current >= prayers[-1][1] or current < prayers[0][1] %}
Isha
{# Check all prayer periods #}
{% else %}
{% set current_prayer = 'Fajr' %} {# Default to Fajr after Fajr time until Dhuhr #}
{% for i in range(1, prayers|length) %}
{% if current >= prayers[i][1] %}
{% set current_prayer = prayers[i][0] %}
{% endif %}
{% endfor %}
{{ current_prayer }}
{% endif %}
- name: "Prayer Period Debug"
state: >
Now: {{ now().strftime('%H:%M') }}
Current: {{ states('sensor.current_prayer') }}
Next: {{ states('sensor.next_prayer') }}
Countdown: {{ states('sensor.time_until_next_prayer') }}
Schedule:
Fajr: {{ states('sensor.fajr_time') }}
Dhuhr: {{ states('sensor.dhuhr_time') }}
Asr: {{ states('sensor.asr_time') }}
Maghrib: {{ states('sensor.maghrib_time') }}
Isha: {{ states('sensor.isha_time') }}
- name: "Active Prayer Countdown"
state: >
{% set prayer = states('sensor.next_prayer').split('|')[1] | trim %}
{% set prayer_hour = prayer.split(':')[0] | int %}
{% set prayer_minute = prayer.split(':')[1] | int %}
{% set now = now() %}
{% set prayer_time = now.replace(hour=prayer_hour, minute=prayer_minute, second=0, microsecond=0) %}
{% if prayer_time < now %}
{% set prayer_time = prayer_time + timedelta(days=1) %}
{% endif %}
{{ prayer_time.isoformat() }}
- name: "Next Prayer Timer"
state: "active"
attributes:
friendly_name: "Next Prayer Timer"
start: "2025-06-23T11:00:00+01:00"
end: "2025-06-23T18:00:00+01:00"
- name: "Test Timer"
state: "active"
attributes:
friendly_name: "Test Timer"
start: "2025-06-23T15:00:00+01:00"
end: "2025-06-23T16:00:00+01:00"</>
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ