-
-
Save EverythingSmartHome/814bc87e83dcff1c06fffa3095b95b3f to your computer and use it in GitHub Desktop.
#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 %} | |
adjusted the Icon Color to match the current color of the lights:
the second line converts the rgb values returned by state_attr to html hexadecimal for the browser to render.
{% if is_state('light.bedroom_cans', 'on') %}
{{ '#%02x%02x%02x' % state_attr('light.bedroom_cans', 'rgb_color')}}
{% else %}
black
{% endif %}
Hello, happy new year to all of you.
I would like to know if someone can help me with my doubt, I'm trying to create a card for a sonoff zigbee port sensor. But I can not. What I want is for it to show:
The Inone of open or closed
The name of the sensor
The status
And the last-changed
But I can't put everything on the same card, the option I found was to make two cards but then it's not cool =/ Can someone help me?
type: horizontal-stack
cards:
- type: custom:mushroom-entity-card
name: 'Porta: Geladeira'
entity: binary_sensor.sonoff_xxxxx
primary_info: name
secondary_info: last-changed
layout: horizontal- type: custom:mushroom-template-card
primary: |
{% if 'off' in states('binary_sensor.sonoff_xxxxx') %}
Fechada
{% else %}
Aberta
{% endif %}
secondary: ''
icon: ''
multiline_secondary: false
fill_container: tru`
How did you do the light count near the beginning of the main card setup?
How did you do the light count near the beginning of the main card setup?
Try this
{% set domain = 'light' %}
{% set lightsOnCount = states[domain] | selectattr( 'state', 'eq', 'on') | list | count %}
{{lightsOnCount}}
You can do this with any kind of domain, media_player, cameras and so on.And use it like this:
- type: template double_tap_action: action: none icon: mdi:lightbulb content: >- {% set domain = 'light' %} {% set count = states[domain] | selectattr( 'state', 'eq', 'on') | list | count %} {{count}} lights on icon_color: >- {% set domain = 'light' %} {% set count = states[domain] | selectattr( 'state', 'eq', 'on') | list | count %} {% if count > 0 %} orange {%endif%} tap_action: action: navigate navigation_path: lights hold_action: action: none
EDIT: figured it out.
hue groups show up as lights, so I had to rejectattr('attributes.is_hue_group', 'true')
and that fixed the issue.
and turning the lights off was just a quick google away.
thanks anyways.
Hi!
Thanks for this.
Frist, lets clear out that I started with HA just a few days ago, so I'm an absolute noob about it and coding in general.
for now I only have 2 light bulbs, each on separated rooms and that's it, so HA is very much an overkill, but I have some smart plugs already on the way and I'm planning to get more lights and sensors in the near future, so decided to dip my toes into it (and I'm loving it)
with that out of the way, I have 2 questions.
- first, an issue I have: every time I turn a light on, it gets counted double. and I have no idea why.
- second: a request.. what would I need to type if I wanted to add for the hold action to turn all the lights off? i.e. leaving the house, just hold and turn all lights off. attempted a toggle, but if one is on and the other is off, they just exchange positions, lol.
thanks for your time.
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.
#Subtitle of Welcome Template Title Card
{% set time = now().weekday() %}
{% if (time >= 0) %}
Today is Monday
{% elif (time >= 1) %}
Today is Tuesday
{% elif (time >= 2) %}
Today is Wednesday
{% elif (time >= 3) %}
Today is Thursday
{% elif (time >= 4) %}
Today is Friday
{% elif (time >= 5) %}
Today is Saturday
{% elif (time >= 6) %}
Today is Sunday
{% else %}
Today is fudged
{% endif %}
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 %}
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 %}
THANK YOU SO MUCH!
@stoniwankenobii I updated the code so it should work correctly now. don't know if you noticed but it only ever showed Monday as the day
EDIT: figured it out.
hue groups show up as lights, so I had torejectattr('attributes.is_hue_group', 'true')
and that fixed the issue.
and turning the lights off was just a quick google away.
thanks anyways.
Hi guys,
ihm really new into HA...
Can you please tell me, how to integrate this piece of code "rejectattr('attributes.is_hue_group', 'true')" into the whole code for the light count?
I have the same issue, that every light is double displayed....
Maybe you can paste it into the code, that I can understand how to do this, for the next time :-)
Thanks!!
{% 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 %}
I finally added it in to my new dashboard. Thanks for sticking with it.
Here are some templates for setting room icon color for multiple lights:
{% if is_state('light.kitchen_ceiling','on') or is_state('light.kitchen_counter','on') or is_state('light.kitchen_table','on') %} orange {% endif %}
For Garage Door Room Icon to indicate garage door state:
{% if is_state ('cover.garage_door', 'open') %} {%set icon='mdi:garage-open'%} {%elif is_state ('cover.garage_door','closed') %} {%set icon='mdi:garage'%} {%endif%} {{icon}}
Another example of Icon Color:
{% if is_state('switch.garage_light','on') %} orange {% endif %}
It may be better in some cases to use a grid card so can move around easier.
I like putting lights that have RGB control in one horizontal stack so the slider has more room on a mobile device.
How did you do the light count near the beginning of the main card setup?
How did you do the light count near the beginning of the main card setup?
Try this
{% set domain = 'light' %}
{% set lightsOnCount = states[domain] | selectattr( 'state', 'eq', 'on') | list | count %}
{{lightsOnCount}}
You can do this with any kind of domain, media_player, cameras and so on.And use it like this:
- type: template double_tap_action: action: none icon: mdi:lightbulb content: >- {% set domain = 'light' %} {% set count = states[domain] | selectattr( 'state', 'eq', 'on') | list | count %} {{count}} lights on icon_color: >- {% set domain = 'light' %} {% set count = states[domain] | selectattr( 'state', 'eq', 'on') | list | count %} {% if count > 0 %} orange {%endif%} tap_action: action: navigate navigation_path: lights hold_action: action: none
I made this, but I want to make that clickable, when I click it, it turns all the lights off, how can I do that?
Thanks
EDIT: I found a solution for this, created a Script and then I set the script as an action for this.
service: light.turn_off
data: {}
target:
entity_id: all
@Morcegolas
It'd be better to create a group of lights in the helpers section and turn that group off.
I have some lights that I don't want to show or turn off when I hold the button, like my underglow, backlighting, deck lights, etc.
You can also use the group properties to set the icon color and count how many lights are on.
type: custom:mushroom-template-card
primary: Lights
secondary: >-
{% set count =
states|selectattr('entity_id','in',state_attr('light.all_people_lights','entity_id'))|selectattr('state','eq','on')|list|count
%} {{count}} lights on
icon: mdi:lightbulb
icon_color: >-
{% set count =
states|selectattr('entity_id','in',state_attr('light.all_people_lights','entity_id'))|selectattr('state','eq','on')|list|count
%} {% if count > 0 %} orange {%endif%}
tap_action:
action: navigate
navigation_path: /dashboard-mushroom/lights
layout: vertical
hold_action:
action: call-service
service: light.turn_off
data: {}
target:
entity_id: light.all_people_lights
also set it to a hold action, not a tap action, using a tap action is one miss-tap away from putting everyone in the dark.
Thanks, I didn't even know where I could create groups ;)
Hi guys , i came strait forward from Youtube page and i am a bit confused on setting the count . I have followed every step but when i switch the light on for a room is automatically count 2 lights ! meanwhile i have only one light in that room ! the same light inside the room been used in both Horizontal Stack configuration , how do you go about sorting this out ? I have one main light . Thanks
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 %}
hi guys, i added this and it works fine, but shows me the english format of Date
i would need the Format 12.04.2023.
would be nice if someone have an hint for. Just 2 days with HA.
How do we get that chip where it shows what lights are on?
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 %}
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")
YOU'RE A WIZARD HARRY
can someone please give detail instruction how to creat the light counter card
What is required to have the dashboard format correctly on a tablet or desktop?
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 %}
I can't get the secondary information to work with the temperature. The same is true for the icon color, when the light is on... Can anybody send me their YAML for that part?
How did you do the light count near the beginning of the main card setup?
Try this
{% set domain = 'light' %}
{% set lightsOnCount = states[domain] | selectattr( 'state', 'eq', 'on') | list | count %}
{{lightsOnCount}}
You can do this with any kind of domain, media_player, cameras and so on.
Is there a way to use categories as domain? I have smart switches for the lights and several smart plugs (which are also in domain switch), so when I do the count against domain switch - it does add up plugs and switches.
Thanks in advance
I use the following helper values: Powerplugs, Lights on, window shutters, window/doors, room temperature, Sonos active.
This is my configuration yaml:
- sensor:
- name: "Steckdosen an"
unique_id: poweroutlets_turned_on
icon: mdi:power-socket-eu
state: |
{{ states.light
| rejectattr('attributes.entity_id', 'defined')
| selectattr('entity_id', 'in', ['light.aussensteckdose', 'light.steckdose_balkon', 'light.steckdose_dachterrasse'])
| rejectattr('attributes.is_hue_group', 'true')
| selectattr('state', 'eq', 'on')
| reject('search', 'screen')
| reject('search', 'segment')
| list
| count }}
- sensor:
- name: "Lampen an"
unique_id: lights_turned_on
icon: mdi:window-shutter-open
state: |
{{ label_entities("lamp") | select('is_state', 'on') | list | count }}
- sensor:
- name: "Rollläden oben"
unique_id: rollos_oben
icon: mdi:window-shutter-closed
state: |
{{ states.cover | selectattr('state', 'eq', 'open') | reject('search', 'motor') | reject('search', 'markise') | list | count + states.cover | selectattr('state', 'eq', 'opening') | reject('search', 'motor') | reject('search', 'markise') | list | count + states.cover | selectattr('state', 'eq', 'closing') | reject('search', 'motor') | reject('search', 'markise') | list | count }}
- sensor:
- name: "Offene Fenster/Türen"
unique_id: open_window_count
icon: mdi:window-open-variant
state: |
{{ states.binary_sensor | selectattr('attributes.device_class', 'eq', 'door') | selectattr('state', 'eq', 'on') | reject('search', 'ev6') | reject('search', 'gruppe') | list | count +
states.binary_sensor | selectattr('attributes.device_class', 'eq', 'window') | selectattr('state', 'eq', 'on') | reject('search', 'ev6') | reject('search', 'gruppe') | list | count }}
- sensor:
- name: "RTR in Betrieb"
unique_id: active_rtr_count
icon: mdi:thermometer-lines
state: |
{{ states.climate | selectattr('state', 'eq', 'heat_cool') | reject('search', 'ev6') | reject('search', 'gruppe') | list | count }}
- sensor:
- name: "Badheizkörper in Betrieb"
unique_id: active_badheizkorper
icon: mdi:heating-coil
state: |
{{ states.light | selectattr('state', 'eq', 'on') | selectattr('entity_id', 'in', ['light.badheizkorper_og', 'light.badheizkorper_dg']) | list | count }}
- sensor:
- name: "Sonos in Betrieb"
unique_id: active_media_count
icon: mdi:music
state: |
{{ states.media_player | selectattr('state', 'eq', 'playing') | reject('search', 'ev6') | reject('search', 'gruppe') | list | count }}
Old thread, not sure if anyone is interested but if like myself you have setup your full name on HA then it might be worth using (either directly or as a helper):
{{ user.split()[0] }}
Looks cleaner with just the first name and fits better.
I have this code below which is working fine, but I want to make the icon in orange every time that any of these 4 lights below turns on.
light.banheiro_suite_interruptor_iluminacao_interruptor_1
light.banheiro_suite_interruptor_iluminacao_interruptor_2
light.banheiro_suite_interruptor_iluminacao_interruptor_3
light.banheiro_suite_interruptor_iluminacao_interruptor_4
{% if is_state('light.banheiro_suite_interruptor_iluminacao_interruptor_1','on')
%} orange
{% endif %}
Does anybody know how to ADD the "OR" clause on this sintax?
I have this code below which is working fine, but I want to make the icon in orange every time that any of these 4 lights below turns on. light.banheiro_suite_interruptor_iluminacao_interruptor_1 light.banheiro_suite_interruptor_iluminacao_interruptor_2 light.banheiro_suite_interruptor_iluminacao_interruptor_3 light.banheiro_suite_interruptor_iluminacao_interruptor_4
{% if is_state('light.banheiro_suite_interruptor_iluminacao_interruptor_1','on') %} orange {% endif %}
Does anybody know how to ADD the "OR" clause on this sintax?
{% if is_state('light.banheiro_suite_interruptor_iluminacao_interruptor_1','on')
or is_state('light.light_2','on')
or is_state('light.light_3','on')
or is_state('light.light_4','on')
%} orange
{% endif %}
Many thanks @danewhitfield for your assistance! You rock! :-)
And use it like this: