Skip to content

Instantly share code, notes, and snippets.

@EverythingSmartHome
Created April 6, 2022 13:13
Show Gist options
  • Save EverythingSmartHome/814bc87e83dcff1c06fffa3095b95b3f to your computer and use it in GitHub Desktop.
Save EverythingSmartHome/814bc87e83dcff1c06fffa3095b95b3f to your computer and use it in GitHub Desktop.
Home Assistant Mushroom card templates
#Showing the state of a temperature in a template card:
{{ states('sensor.your_temperature_sensor') }}
#Change the colour of the light depending on status:
{% if is_state('light.your_light', 'on') %}
orange
{% endif %}
#Welcome template:
{% set time = now().hour %}
{% if (time >= 18) %}
Good Evening, {{user}}!
{% elif (time >= 12) %}
Good Afternoon, {{user}}!
{% elif (time >= 5) %}
Good Morning, {{user}}!
{% else %}
Hello, {{user}}!
{% endif %}
@jaymartinez723
Copy link

How do we get that chip where it shows what lights are on?

@ma-si
Copy link

ma-si commented Feb 11, 2024

How would I go about adding the date after each day of my subtitle addition to the Welcome Screen template. I am not sure how to get that added in.

I added this in the secondary information field since I am always forgetting the date 😅

{% set time = now().weekday() %}
{% if (time >= 0) %}
Today is Monday, {{ now().date()}}
{% elif (time >= 1) %}
Today is Tuesday, {{ now().date()}}
{% elif (time >= 2) %}
Today is Wednesday, {{ now().date()}}
{% elif (time >= 3) %}
Today is Thursday, {{ now().date()}}
{% elif (time >= 4) %}
Today is Friday, {{ now().date()}}
{% elif (time >= 5) %}
Today is Saturday, {{ now().date()}}
{% elif (time >= 6) %}
Today is Sunday, {{ now().date()}}
{% else %}
Today is fudged....
{% endif %}

image

THANK YOU SO MUCH!

now() is python date object so you can use formatting.

{% set current_datetime = now() -%}
Today is {{ current_datetime.strftime("%A") }}, {{ current_datetime.date()}}

@stoniwankenobii this way will be easier ;)

@dos1973 you can use formatting

now().strftime("%d.%m.%Y")

@stoniwankenobii
Copy link

YOU'RE A WIZARD HARRY

@yellowdre
Copy link

can someone please give detail instruction how to creat the light counter card

@TrialMaster
Copy link

What is required to have the dashboard format correctly on a tablet or desktop?

@Octavian1973
Copy link

Hello everybody!

I added this in the secondary information field since I am always forgetting the date 😉

{% set time = now().weekday() %}
{% if (time == 0) %}
Today is Monday, {{ now().strftime("%d.%m.%Y")}}
{% elif (time == 1) %}
Today is Tuesday, {{ now().strftime("%d.%m.%Y")}}
{% elif (time == 2) %}
Today is Wednesday, {{ now().strftime("%d.%m.%Y")}}
{% elif (time == 3) %}
Today is Thursday, {{ now().strftime("%d.%m.%Y")}}
{% elif (time == 4) %}
Today is Friday, {{ now().strftime("%d.%m.%Y")}}
{% elif (time == 5) %}
Today is Saturday, {{ now().strftime("%d.%m.%Y")}}
{% elif (time == 6) %}
Today is Sunday, {{ now().strftime("%d.%m.%Y")}}
{% else %}
Today is the lucky day...
{% endif %}

000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment