mattlang
(Matthew Langridge)
April 5, 2023, 9:00am
1
I have used card-mod to remove the secondary state text on a tile card as per this post:
Can not create Tile card with empty state on device_tracker?
However, what I now want to do is change the secondary text which i have highlighted below.
Anyone know how?
I have had some success putting the text template into the content field as below:
type: tile
entity: light.master_bedroom_lamp
card_mod:
style:
ha-tile-info$: |
.secondary {
visibility: hidden;
}
.secondary:before {
visibility: visible;
content: "{{ states(config.entity) | title }}";
}
This gives me the below card:
I do notice that sometimes I have to clear by browser cache after making a new card before it works properly.
1 Like
bremby
(bremby)
August 15, 2023, 6:59pm
3
@doranashburner , do you think that could be possible to do the same to show last changed value?
NCO3
(Nco3)
October 30, 2023, 10:24am
4
thank you for this thread.
I have modified so that I can see the state of the gardenshed door and the state of its lock:
card_mod:
style:
ha-tile-info$: |
.secondary {
visibility: hidden;
}
.secondary:before {
visibility: visible;
content: "{{ states('binary_sensor.gartenhaus_tur_intrusion_2') | title + ' & ' + states('lock.gartenhaus_schlos') | title}}";
}
However, as a result I get “Off & Locked
”
So, one thing is that it’s Off
instead of Closed
and even in the German view it’s not translated.
Any hint would be greatly appreciated.
My Example => Tile Card with two Secondary States
type: tile
entity: sensor.room_temperature
name: Temperature and Humidity
tap_action:
action: none
icon_tap_action:
action: none
card_mod:
style:
ha-tile-info$: |
.secondary {
visibility: hidden;
}
.secondary:before {
visibility: visible;
content: '{{ states('sensor.room_temperature') | round(1) }} °C - {{ states('sensor.room_humidity') | round(0) }} %'
}
Note: the preview editor only shows 1 state?
→ Simply click on “OK” in the editor and the second state will appear.
1 Like
BBE-FR
(BBE)
March 25, 2024, 2:13pm
6
Another way to perform this is to use the mushroom cards which are very close to Tile cards.
And use specifically the Mushroom template cards , which gives full control on the icon, its color, the primary information, and the secondary information through JINJA2 template.
And as a bonus a small badge that you can customize in icon and color…
All this with UI available, without needing cardmod, and with the possibility to separate the behaviour for single tap, hold and double tap…
card_mod:
style:
ha-tile-info$: |
.secondary {
visibility: hidden;
}
.secondary:before {
visibility: visible;
content: "{{ states(config.entity) | title + ' - mdi:thermometer ' + states('sensor.smoke_detector_soverom_air_temperature')| title + '°C'| title}}";
}
Can someone please tell me how to insert an thermometer icon in the content string.
CChris
(Christoph)
June 30, 2024, 6:04pm
8
just to mention:
this card mod does not look well if you use the tile in vertical
Does anyone have an idea, how to “align” the text without using “before” etc.?
How can you prepend the secondary text using this method ?
I would love to see the last_changed attribute, but before I would also like to add the value of another sensor.