exactly, as Ildar says, let me add to it:
just create a binary sensor for that and use the binary in the conditional.
.
okey thank you.
I have the same question to this, is there a solution?
So, entity is an object. That is expecting a string I believe. I am surprised that it passes [[entity]] and that you don’t get [object].
That should be fixable by wrapping it inside a custom:card-templater. You can then get the name of the entity that is passed using
{{ state_attr(''[[entity]]'', ''friendly_name'') }}
this is what I’m trying and it’s not working
decluttering_templates:
big_button:
default:
- name: {{ state_attr('[[entity]]', friendly_name) }}
card:
type: custom:button-card
entity: '[[entity]]'
name: '[[name]]'
An example of what I am talking about is explained here:
Food in the Freezer Tracker - Share your Projects! - Home Assistant Community (home-assistant.io)
You need quotes around friendly_name.
But, also need to wrap the big_button inside the card-templater if big_button does not support it.
Hi
I’m having an issue with decluttering-cards not behaving in a horizontal stack.
Initially all of the individual cards were custom:button-cards. I’ve transitioned some to a decluttering-card so that I can pass the MAC address as a variable so that a click sends a wake_on_lan request.
As you can see the formatting is screwed up:
- In the row of dining room and main bedroom the first decluttering-card of the 3 is missing.
- In the last row the first card (Asustor2) is a decluttering card, Spare is a button card.
- type: custom:button-card
template: container
color: "#808080"
name: Computers / Servers
custom_fields:
buttons:
card:
type: vertical-stack
cards:
- type: horizontal-stack
cards:
- type: custom:button-card
template: computer
entity: sensor.hasspi
icon: mdi:raspberry-pi
name: HassOS
- type: custom:button-card
template: computer
entity: sensor.rasppi
icon: mdi:raspberry-pi
name: RaspberryPi
- type: custom:button-card
template: computer
entity: sensor.server
icon: mdi:desktop-tower
name: Server
- type: horizontal-stack
cards:
- type: custom:button-card
template: computer
entity: sensor.zephyrus
icon: mdi:laptop
name: Zephyrus
- type: custom:button-card
template: computer
entity: sensor.swiftx
icon: mdi:laptop
name: SwiftX
- type: horizontal-stack
cards:
- type: custom:decluttering-card
template: computer
variabes:
- entity: sensor.h570m
- icon: mdi:desktop-tower
- name: Lounge HTPC
- mac: "A8-A1-59-92-75-3E"
- type: custom:decluttering-card
template: computer
variables:
- entity: sensor.h610m
- icon: mdi:desktop-tower
- name: Dining Room HTPC
- type: custom:decluttering-card
template: computer
variables:
- entity: sensor.z370
- icon: mdi:desktop-tower
- name: Main Bedroom HTPC
- type: horizontal-stack
cards:
- type: custom:button-card
template: computer
entity: sensor.h81t
icon: mdi:desktop-tower
name: Charlie HTPC
- type: custom:button-card
template: computer
entity: sensor.h81t2
icon: mdi:desktop-tower
name: Girl's HTPC
- type: horizontal-stack
cards:
- type: custom:button-card
template: computer
entity: sensor.mediamaster
icon: mdi:nas
name: MediaMaster
- type: custom:button-card
template: computer
entity: sensor.readynas428
icon: mdi:nas
name: RN428
- type: custom:button-card
template: computer
entity: sensor.backup
icon: mdi:nas
name: Backup
- type: horizontal-stack
cards:
- type: custom:decluttering-card
template: computer
variables:
- name: Asustor2
- icon: mdi:nas
- entity: sensor.asustor2
- mac: "78-72-64-41-3D-C2"
- type: custom:decluttering-card
template: computer
variables:
- entity: sensor.spare
- icon: mdi:nas
- name: Spare
Grateful for any advice?
Thanks
Andy
Can you show us your decluttering card?
And, note, the last row, both are decluttering cards. Not one decluttering and a button card.
Hi
Sorry you are right about the bottom row - same with one of each however - they are not next to each other.
Card:
computer:
default:
- mac: "ff-ff-ff-ff-ff-ff"
card:
type: custom:button-card
hold_action:
action: none
tap_action:
action: call-service
service: wake_on_lan.send_magic_packet
service_data:
mac: '[[mac]]'
name: '[[name]]'
icon: '[[icon]]'
entity: '[[entity]]'
styles:
card:
- background-color: rgba(115, 115, 115, 0.2)
- border-radius: 10%
- padding: 5px
- color: ivory
- font-size: 10px
- text-transform: capitalize
- width: 90px
- height: 90px
- align-items: start
grid:
- grid-template-areas: '"i temp" "n n" "cpu cpu" "ram ram" "sd sd"'
- grid-template-columns: 1fr 1fr
- grid-template-rows: 3fr 1fr 1fr 1fr 1fr
name:
- font-weight: bold
- font-size: 13px
- color: white
- align-self: middle
- justify-self: start
- padding-bottom: 4px
img_cell:
- justify-content: start
- align-items: start
- margin: none
icon:
- width: 70%
- margin-top: "-10%"
- color: |
[[[
if (states[entity.entity_id].state == 'off') return 'gray';
if (isNaN(states[entity.entity_id].attributes.cpu_temperature)) return 'white';
if (states[entity.entity_id].attributes.cpu_temperature < 60) return 'lime';
if (states[entity.entity_id].attributes.cpu_temperature >= 60 &&
states[entity.entity_id].attributes.cpu_temperature < 80) return 'orange';
else return 'red';
]]]
custom_fields:
temp:
- align-self: start
- justify-self: end
cpu:
- padding-bottom: 2px
- align-self: middle
- justify-self: start
- "--text-color-sensor": "[[[ if (states[entity.entity_id].attributes.cpu_use > 80) return 'rgba(255,96,96,1)'; ]]]"
ram:
- padding-bottom: 2px
- align-self: middle
- justify-self: start
- "--text-color-sensor": "[[[ if (states[entity.entity_id].attributes.memory_use > 80) return 'rgba(255,96,96,1)'; ]]]"
sd:
- align-self: middle
- justify-self: start
- "--text-color-sensor": "[[[ if (states[entity.entity_id].attributes.disk_use > 80) return 'rgba(255,96,96,1)'; ]]]"
custom_fields:
temp: |
[[[
if (states[entity.entity_id].state == 'on' && !isNaN(states[entity.entity_id].attributes.cpu_temperature)) {
return `<ha-icon
icon="mdi:thermometer"
style="width: 12px; height: 12px; color: yellow;">
</ha-icon><span>${states[entity.entity_id].attributes.cpu_temperature}°C</span>`
} else {
return '';
}
]]]
cpu: |
[[[
if (states[entity.entity_id].state == 'on' && !isNaN(states[entity.entity_id].attributes.cpu_use)) {
return `<ha-icon
icon="mdi:server"
style="width: 12px; height: 12px; color: deepskyblue;">
</ha-icon><span>CPU: <span style="color: var(--text-color-sensor);">${states[entity.entity_id].attributes.cpu_use}%</span></span>`
} else {
return '';
}
]]]
ram: |
[[[
if (states[entity.entity_id].state == 'on' && !isNaN(states[entity.entity_id].attributes.memory_use)) {
return `<ha-icon
icon="mdi:memory"
style="width: 12px; height: 12px; color: deepskyblue;">
</ha-icon><span>RAM: <span style="color: var(--text-color-sensor);">${states[entity.entity_id].attributes.memory_use}%</span></span>`
} else {
return '';
}
]]]
sd: |
[[[
if (states[entity.entity_id].state == 'on' && states[entity.entity_id].attributes.disk_use && !isNaN(states[entity.entity_id].attributes.disk_use)) {
return `<ha-icon
icon="mdi:harddisk"
style="width: 12px; height: 12px; color: deepskyblue;">
</ha-icon><span>Disk: <span style="color: var(--text-color-sensor);">${states[entity.entity_id].attributes.disk_use}%</span></span>`
} else {
return '';
}
]]]
Thanks
Andy
You have a typo, it should be variables
BTW, why not just use the variables from button card instead of using decluterring-card’s variables and skip decluterring-card completely ?
Thank you. That fixes the missing card, not the layout.
The only reason I use decluttering-card is to pass tha variable mac to the card. I can see (and do) use variables within a button-card but can’t see how to pass them - I would be more than happy to just use a button-card.
Thanks
Andy
If you take the decluttering card and put in in for real with each set of variables, does it line up correctly? That will determine if it is the decluttering card or the settings used.
Sorry, I don’t understand what you mean.
Each card has a valid set of variables.
They are defined like:
- name: H570M
unique_id: "H570M"
state: |
{% if states.sensor.H570M_satellite_cputemperature.state == 'unavailable' or states.sensor.H570M_satellite_cputemperature.state == 'Unknown' %}
off
{% else %}
on
{% endif %}
attributes:
cpu_temperature: "{{ states.sensor.H570M_satellite_cputemperature.state }}"
cpu_use: "{{ states.sensor.H570M_satellite_cpuload.state }}"
memory_use: "{{ states.sensor.H570M_satellite_memoryusage.state }}"
disk_use: "{{ state_attr('sensor.H570M_satellite_storage_c','UsedSpacePercentage') }}"
Either from MQTT or some are through SNMP:
- platform: snmp
host: 192.168.1.125
baseoid: 1.3.6.1.4.1.44738.5.1.1.6.1
community: public
name: 'Asustor2 Total Space'
scan_interval: 30
accept_errors: true
- platform: snmp
host: 192.168.1.125
baseoid: 1.3.6.1.4.1.44738.5.1.1.7.1
community: public
name: 'Asustor2 Free Space'
scan_interval: 30
accept_errors: true
- platform: snmp
host: 192.168.1.125
baseoid: 1.3.6.1.4.1.44738.2.3.0
community: public
name: 'Asustor2 CPU Temperature'
scan_interval: 30
accept_errors: true
- platform: snmp
host: 192.168.1.125
baseoid: 1.3.6.1.4.1.44738.2.7.1.1.2.0
community: public
name: 'Asustor2 CPU Usage'
scan_interval: 30
accept_errors: true
Does that help??
Thanks
Andy
So, to ‘declutter’ a card, you have cards that you build, duplicate, and change a bunch of stuff.
In that, you need to build a card, test it with different options, declutter it, and use that decluttering template.
For all of that to work, you need to have a card that works before decluttering it.
The decluttering card you showed above is 116 lines.
Have you tried that with two full cards built into a horizontal stack to see if they line up correctly. I suspect they do not. I expect something in that 116 lines to be throwing something off. That is why testing it manually for two cards inside of a horizontal stack is necessary.
I hope that makes sense.
Setting the width and height of button-card will break automatic alignment in a stack. Use aspect_ratio: 1/1
instead if you want to make them square.
Thank you.
Changing the width/height for an aspect_ratio now gives:
Is there any way to control the size and still keep the alignment??
Cheers
Andy
Use grid card and an empty card for organizing layout if must.
Never an issue and auto adaptive.
Easy and elegantly simple
Hey, you should really switch to grid-template-areas in your custom button card, and not try to include vertical and horizontal stacks. That is really complicating things for you.
Anyone know of a way to use conditional card with decluttering card to achieve cards that only appear if the variable is populated ?
I have it working fine with mushroom chips conditional, but if I use the normal conditional card for other lovelace cards it fails saying it’s an invalid condition (since the entity name is essentially blank)
What I’m trying to achieve is a page with lets say 4 lights, which I can simply re-use for all my rooms, specifying the light entities as the variables, but some rooms have 1 light, others 2 etc… so the idea would be if one of the 4 entity variable is blank (or some dummy value) then don’t show the card for that light.
Try an entity-filter card.
I did not try it in a decluttering-card. But, if I read you correctly, I think this should work.
- type: entity-filter
entities:
- switch.living_room_lamp
- switch.does_not_exist
- switch.garage_relay
- switch.does_not_exist2
state_filter:
- operator: '!='
value: undefined
card:
type: entities
It only shows the two entities in the list that actually exist.