Ça avance
Voilà mon template :
EDIT: code
voir POST suivant: Maj de HACS version 1.34, vers la version 2.0. procédure d'installation? - #72 par mrgrlscz
Je suis sûr qu’il y a plus simple mais j’avais cette formule qui traînait ailleurs dans mon code
C’est cette partie là qui détermine quelles entités vont peupler la carte:
filter:
include:
- entity_id: update.*
state: 'off'
exclude:
- entity_id: update.*
attributes:
skipped_version: null
- entity_id: update.*
attributes:
device_class: firmware
- entity_id: update.*
attributes:
supported_features: 23
- entity_id: update.*
attributes:
supported_features: 25
avec ces filtres, que Warcozes a posté plus haut, tu as les maj HACS dispo, et en enlevant certains exclude
, ta liste va s’aggrandir!
filter:
include:
- entity_id: update.*
state: 'on'
exclude:
- entity_id: update.*
state: 'off'
- entity_id: update.*
attributes:
device_class: firmware
- entity_id: update.*
attributes:
supported_features: 25
- entity_id: update.home_assistant_core_update
- entity_id: update.home_assistant_operating_system_update
- entity_id: update.home_assistant_supervisor_update
Comme ça:
{% if is_state('sensor.hacsfr','0') %}
A jour
{% else %}
{{ states('sensor.hacsfr') }} Mise(s) à jour disponible(s)
{% endif %}
PS: penses à formater tes morceaux de code à poster… c’est pas facile de copier/coller depuis un screenshot!!
Merci pour ton aide ! Ok pour le code.
Au passage est il possible de colorer un badge pour une entité ? C’était possible en card-mod mais mon code ne fonctionne plus.
Je voulais utiliser le mushroom template mais je ne sais pas quoi mettre dans « Contenu »
Tu peux mettre
{{state_attr(entity, 'entity_picture')}}
Edit : pardon, j’ai mal lu. picture sert à mettre une image en remplacement de l’icône.
Un message a été scindé en un nouveau sujet : Badge, colorer le contour suivant l’été d’une entité
Bonjour,
Je trouve ton code top.
aurais tu également les sensors :
- sensor.tplt_skipped_updates_system
- sensor.tplt_skipped_updates_addon
- sensor.tplt_skipped_updates_hacs
Stp
merci d’avance
Finalement j’ai quand même fait la carte des updates disponibles, ça donne ça dans un pop-up bubble-card
:
sensor
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# -------------------------------------------------------------------- available
- name: tplt_available_updates_system
state: |
{% set var = states.update
|selectattr('state', 'equalto', 'on')
|select('search', 'home_assistant')
|map(attribute='entity_id')
|list %}
{% set result = var |length %}
{{ result }}
- name: tplt_available_updates_addon
state: |
{% set var = states.update
|selectattr('state', 'equalto', 'on')
|selectattr('attributes.supported_features', 'equalto', 25)
|map(attribute='entity_id')
|list %}
{% set result = var |length %}
{{ result }}
- name: tplt_available_updates_hacs
state: |
{% set var = states.update
|selectattr('state', 'equalto', 'on')
|selectattr('attributes.supported_features', 'equalto', 23)
|map(attribute='entity_id')
|list %}
{% set result = var |length %}
{{ result }}
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# ---------------------------------------------------------------------- skipped
- name: tplt_skipped_updates_system
state: |
{% set var = states.update
|select('search', 'home_assistant')
|selectattr('attributes.skipped_version', 'ne', none)
|map(attribute='entity_id')
|list %}
{% set result = var |length %}
{{ result }}
- name: tplt_skipped_updates_addon
state: |
{% set var = states.update
|selectattr('attributes.supported_features', 'equalto', 25)
|selectattr('attributes.skipped_version', 'ne', none)
|map(attribute='entity_id')
|list %}
{% set result = var |length %}
{{ result }}
- name: tplt_skipped_updates_hacs
state: |
{% set var = states.update
|selectattr('attributes.supported_features', 'equalto', 23)
|selectattr('attributes.skipped_version', 'ne', none)
|map(attribute='entity_id')
|list %}
{% set result = var |length %}
{{ result }}
binary_sensor
# ======================================================================================
# ======================================================================================
# ============================================================================== UPDATES
- name: tplt_update_restart
icon: mdi:restart-alert
device_class: update
state: |
{% set var = states.update
|selectattr('attributes.release_summary', 'search', 'Restart of Home Assistant required')
|map(attribute='entity_id')
|list %}
{% set nr_count = var |length %}
{% if nr_count == 0 %}
off
{% else %}
on
{% endif %}
attributes:
list: |
{% set var = states.update
|selectattr('attributes.release_summary', 'search', 'Restart of Home Assistant required')
|map(attribute='attributes.friendly_name')
|map('replace', 'Update', '')
|map('replace', 'update', '')
|list %}
{% set nr_count = var | length %}
{% if nr_count == 0 %}
null
{% else %}
{{ var | join('et ') }}{{ 'nécessite' if nr_count == 1 else 'nécessitent' }} un redémarrage.
{% endif %}
# {% set var = states.update
# |selectattr('attributes.release_summary', 'search', 'Restart of Home Assistant required')
# |map(attribute='attributes.friendly_name')
# |map('replace', 'Update', '')
# |map('replace', 'update', '')
# |list %}
# {% set nr_count = var |length %}
# {% if nr_count == 0 %}
# null
# {% else %}
# {% set nr_joined = var |join('\n'+' ') %}
# {{" "}}{{ nr_joined }}
# {% endif %}
- name: tplt_available_updates
icon: mdi:update
device_class: update
state: |
{% set var = states.update
|selectattr('state', 'equalto', 'on')
|reject('search','Swiss Army Knife custom card')
|map(attribute='attributes.friendly_name')
|map('replace', 'Update', '')
|map('replace', 'update', '')
|list %}
{% set result = var |length %}
{% if result == 0 %}
off
{% else %}
on
{% endif %}
- name: tplt_skipped_updates
icon: mdi:debug-step-over
device_class: update
state: |
{% set var = states.update
|selectattr('attributes.skipped_version', 'ne', none)
|map(attribute='entity_id')
|list %}
{% set result = var |length %}
{% if result == 0 %}
off
{% else %}
on
{% endif %}
attributes:
count_all: |
{% set var = states.update
|selectattr('attributes.skipped_version', 'ne', none)
|map(attribute='entity_id')
|list %}
{% set result = var |length %}
{{ result }}
count_system: |
{% set var = states.update
|select('search', 'home_assistant')
|selectattr('attributes.skipped_version', 'ne', none)
|map(attribute='entity_id')
|list %}
{% set result = var |length %}
{{ result }}
count_addon: |
{% set var = states.update
|selectattr('attributes.supported_features', 'equalto', 25)
|selectattr('attributes.skipped_version', 'ne', none)
|map(attribute='entity_id')
|list %}
{% set result = var |length %}
{{ result }}
count_hacs: |
{% set var = states.update
|selectattr('attributes.supported_features', 'equalto', 23)
|selectattr('attributes.skipped_version', 'ne', none)
|map(attribute='entity_id')
|list %}
{% set result = var |length %}
{{ result }}
list: |
{% set var = states.update
|selectattr('attributes.skipped_version', 'ne', none)
|map(attribute='attributes.friendly_name')
|map('replace', 'Update', '')
|map('replace', 'update', '')
|list %}
{% set result = var |join('\n'+' ') %}
{{ result }}
pop-up
### ================================================================== UPDATES
- type: vertical-stack
cards:
- type: custom:bubble-card
card_type: pop-up
hash: "#update"
name: Mises à jour
icon: mdi:update
close_on_click: false
sub_button:
- entity: switch.hacs_pre_release
name: Beta
show_name: false
icon: ''
show_state: true
show_last_changed: false
show_attribute: false
tap_action:
action: toggle
show_icon: false
show_background: true
# ------------------------------------------ cards
- type: conditional
conditions:
- condition: state
entity: binary_sensor.tplt_available_updates
state: 'on'
card:
type: vertical-stack
cards:
- type: custom:bubble-card
card_type: separator
name: "Mise(s) à jour disponible(s):"
<<: &separator
styles: |-
ha-card { color: var(--primary-background-color); }
.bubble-line {
background: var(--primary-background-color);
opacity: 0.2;
}
- !include ../cards/card_update_available.yaml
# ------------------------------------------ cards
- type: conditional
conditions:
- condition: state
entity: binary_sensor.tplt_skipped_updates
state: 'on'
card:
type: vertical-stack
cards:
- type: custom:bubble-card
card_type: separator
name: "Mise(s) à jour ignorée(s):"
<<: *separator
- !include ../cards/card_update_skipped.yaml
card_update_available.yaml
type: custom:stack-in-card
card_mod:
class: stock
cards:
# ===================================================================== SYSTEM UPDATES
- type: conditional
conditions:
- condition: state
entity: sensor.tplt_available_updates_system
state_not: '0'
card:
type: custom:auto-entities
filter:
include: &include
- entity_id: update.*
state: 'on'
exclude:
- entity_id: update.*
attributes:
device_class: firmware
- entity_id: update.*
attributes:
supported_features: 23
- entity_id: update.*
attributes:
supported_features: 25
card:
<<: &card
type: custom:flex-table-card
card_mod:
class: stock
style: |
table {
padding: 4px;
}
sort_by: friendly_name+
clickable: true
columns:
- <<: &col1
data: entity_picture
align: center
name: ''
modify: '''<img src="'' + x + ''"style="height:30px;width:30px">'''
- <<: &col2
name: ''
data: friendly_name
align: left
modify: |-
x = x.replace('Update', '');
x;
name: Système
- <<: &col3
data: installed_version
name: Actuelle
align: right
- <<: &col4
data: latest_version
name: Disponible
align: right
css: &css
thead th: 'color: var(--text);'
tbody tr: 'background-color: transparent !important;'
tbody tr td:nth-child(1): 'width: 32px;'
tbody tr td:nth-child(3): 'width: 64px; font-weight: bold;'
tbody tr td:nth-child(4): 'width: 64px; color: var(--success-color); font-weight: bold;'
# ===================================================================== ADD-ON UPDATES
- type: conditional
conditions:
- condition: state
entity: sensor.tplt_available_updates_addon
state_not: '0'
card:
type: custom:auto-entities
filter:
include: *include
exclude:
- entity_id: update.*
attributes:
device_class: firmware
- entity_id: update.*
attributes:
supported_features: 23
- entity_id: update.home_assistant_core_update
- entity_id: update.home_assistant_operating_system_update
- entity_id: update.home_assistant_supervisor_update
card:
<<: *card
columns:
- <<: *col1
- <<: *col2
name: Module comp.
- <<: *col3
- <<: *col4
css: *css
# ======================================================================= HACS UPDATES
- type: conditional
conditions:
- condition: state
entity: sensor.tplt_available_updates_hacs
state_not: '0'
card:
type: custom:auto-entities
filter:
include: *include
exclude:
- entity_id: update.*
attributes:
device_class: firmware
- entity_id: update.*
attributes:
supported_features: 25
- entity_id: update.swiss_army_knife_custom_card_update
- entity_id: update.home_assistant_core_update
- entity_id: update.home_assistant_operating_system_update
- entity_id: update.home_assistant_supervisor_update
card:
<<: *card
columns:
- <<: *col1
- <<: *col2
name: HACS
modify: |-
x = x.replace('update', '');
x;
- <<: *col3
- <<: *col4
css: *css
card_update_skipped.yaml
type: custom:stack-in-card
card_mod:
class: stock
cards:
# ===================================================================== SYSTEM UPDATES
- type: conditional
conditions:
- condition: state
entity: sensor.tplt_skipped_updates_system
state_not: '0'
card:
type: custom:auto-entities
filter:
include: &include
- entity_id: update.*
state: 'off'
exclude:
- entity_id: update.*
attributes:
skipped_version: null
- entity_id: update.*
attributes:
device_class: firmware
- entity_id: update.*
attributes:
supported_features: 23
- entity_id: update.*
attributes:
supported_features: 25
card:
<<: &card
type: custom:flex-table-card
card_mod:
class: stock
style: |
table {
padding: 4px;
}
sort_by: friendly_name+
clickable: true
columns:
- <<: &col1
data: entity_picture
align: center
name: ''
modify: '''<img src="'' + x + ''"style="height:30px;width:30px">'''
- <<: &col2
name: ''
data: friendly_name
align: left
modify: |-
x = x.replace('Update', '');
x;
name: Système
- <<: &col3
data: installed_version
name: Actuelle
align: right
- <<: &col4
data: skipped_version
name: Ignorée
align: right
css: &css
thead th: 'color: var(--text);'
tbody tr: 'background-color: transparent !important;'
tbody tr td:nth-child(1): 'width: 32px;'
tbody tr td:nth-child(3): 'width: 64px; font-weight: bold;'
tbody tr td:nth-child(4): 'width: 64px; color: var(--nova-color); font-weight: bold;'
# ===================================================================== ADD-ON UPDATES
- type: conditional
conditions:
- condition: state
entity: sensor.tplt_skipped_updates_addon
state_not: '0'
card:
type: custom:auto-entities
filter:
include: *include
exclude:
- entity_id: update.*
attributes:
skipped_version: null
- entity_id: update.*
attributes:
device_class: firmware
- entity_id: update.*
attributes:
supported_features: 23
- entity_id: update.home_assistant_core_update
- entity_id: update.home_assistant_operating_system_update
- entity_id: update.home_assistant_supervisor_update
card:
<<: *card
columns:
- <<: *col1
- <<: *col2
name: Module comp.
- <<: *col3
- <<: *col4
css: *css
# ======================================================================= HACS UPDATES
- type: conditional
conditions:
- condition: state
entity: sensor.tplt_skipped_updates_hacs
state_not: '0'
card:
type: custom:auto-entities
filter:
include: *include
exclude:
- entity_id: update.*
attributes:
skipped_version: null
- entity_id: update.*
attributes:
device_class: firmware
- entity_id: update.*
attributes:
supported_features: 25
- entity_id: update.home_assistant_core_update
- entity_id: update.home_assistant_operating_system_update
- entity_id: update.home_assistant_supervisor_update
card:
<<: *card
columns:
- <<: *col1
- <<: *col2
name: HACS
modify: |-
x = x.replace('update', '');
x;
- <<: *col3
- <<: *col4
css: *css
Voilà il restera comme ça pour le moment
Et le code complet de la vue.
cards:
- type: markdown
content: >-
{% set maj = states.update |
selectattr('attributes.release_summary','eq','<ha-alert
alert-type=\'error\'>Restart of Home Assistant required</ha-alert>')
|map(attribute='name') | list %}
{% set maj_count = maj | count | int(2) %}
{% if maj_count >= 1 %}
<ha-alert alert-type="error" title="{{maj_count}} intégrations nécessitent
un redémarrage :">
<hr>
<ul >{% for i in maj%}
<li> {{i}}</li>
{% endfor%}</ul>
{% else %}
{% endif %}</ha-alert>
card_mod:
style: |
:host {
--ha-card-margin: 0px;
--ha-card-background: #00000000 !important;
--ha-card-border-color: #00000000 !important;
}
ha-markdown.no-header {
padding: 0px !important;
padding-bottom: 10px !important;
margin: 0px !important;
}
- show_name: true
show_icon: true
type: custom:button-card
tap_action:
action: perform-action
always_execute: |
[[[
this.shadowRoot.getElementById('icon').style.animation = "rotating reverse 1s linear infinite";
]]]
perform_action: homeassistant.restart
icon: |
[[[
return 'mdi:restart'
]]]
name: Redémarrer
styles:
name:
- font-size: 1em
- justify-self: start
icon:
- width: 100%
- height: 90%
- animation: |
[[[
if(states["sensor.home_assistant_core_cpu_percent"].state == "unavailable")
return ' rotating reverse 1s linear infinite'
else if(states["sensor.home_assistant_core_cpu_percent"].state == 0)
return ' rotating reverse 1s linear infinite'
else return ""
]]]
card:
- background: rgba(255,0,0,0.1)
- padding: 0%
- width: 100%
grid:
- grid-template-columns: 0.4fr 1fr
- grid-template-rows: repeat(2, 100%)
- grid-template-areas: "\"i n\""
- type: vertical-stack
cards:
- type: custom:button-card
show_name: false
show_icon: false
show_state: false
styles:
grid:
- grid-template-areas: "\"card1 card2\" "
- grid-template-columns: 1fr 1fr
- grid-template-rows: 1fr
card:
- margin-top: 20px
- padding: 5px 0px 5px 10px
- background: rgba(0,0,255,0.1)
- border: 1px solid blue
- border-radius: 5px
- box-shadow: 0px -1px 15px blue
custom_fields:
card1:
- width: 90%
card2:
- align-self: top
- height: 100%
custom_fields:
card1:
card:
type: custom:mushroom-title-card
title: Home Assistant
alignment: start
card_mod:
style: |
.header {
padding: 0px !important;
}
.header div {
margin: 0px !important
}
card2:
card:
type: markdown
content: >-
{% set
maj=integration_entities('hassio')|select('search','update.home')|select('is_state','on')|list%}
{% set
total=integration_entities('hassio')|select('search','update.home')|list|count|int(2)
%} {% set maj_count = maj|count|int(2) %} {% if maj_count == 0
%} <ha-alert alert-type="success" title="{{maj_count}} sur
{{total}} " > {% elif maj_count >= 1 %} <ha-alert
alert-type="warning" title="{{maj_count}} mise a jour sur
{{total}} " ></ha-alert> {% else %} {% endif %}
card_mod:
style: |
:host {
--ha-card-margin: 0px;
--ha-card-background: #00000000 !important;
--ha-card-border-color: #00000000 !important;
}
ha-markdown.no-header {
padding: 0px !important;
margin: 0px !important;
}
- type: custom:auto-entities
card:
square: false
type: grid
columns: 1
filter:
include:
- domain: update
name: Home*
options:
show_name: true
show_icon: true
show_entity_picture: true
variables:
url: |
[[[
return entity.attributes.release_url
]]]
sensor: |
[[[
let name = Object.values(entity)
return name[0]
]]]
type: custom:button-card
name: |
[[[
return entity.attributes.friendly_name.replace('Home Assistant','HA').replace('Update','')
]]]
state_display: |
[[[ if(entity.state== "on" & entity.attributes.in_progress == false)
return 'v' + entity.attributes.installed_version +' - v' + entity.attributes.latest_version
else if(entity.state== "off")
return helpers.localize(entity) +' - v'+ entity.attributes.installed_version
else
return "instal - "+entity.attributes.in_progress+"%"
]]]
show_state: true
tap_action:
action: url
url_path: |
[[[
return variables.url
]]]
custom_fields:
upload:
card:
show_icon: true
type: custom:button-card
size: 2em
icon: |
[[[
if(entity.state == "off")
return ""
if(entity.attributes.in_progress == false)
return 'mdi:upload-circle'
else return 'mdi:rotate-right'
]]]
styles:
card:
- padding: 0px
- margin-top: 0px
- background: none
- border: none
icon:
- animation: |
[[[
if(entity.attributes.in_progress == false)
return ''
else return 'rotating 1s linear infinite'
]]]
- color: |
[[[
if(entity.state == 'on')
return 'rgba(255, 182, 56, 1)'
else return 'green'
]]]
- left: 15%
tap_action:
action: perform-action
perform_action: update.install
target:
entity_id: "[[[return variables.sensor]]]"
styles:
grid:
- grid-template-columns: 1fr 1.8fr 1fr;
- grid-template-rows: repeat(2, 50%);
- gap: 0px 0px;
- grid-template-areas: "\"i n upload\" \"i s upload\""
card:
- padding: 5px
icon:
- width: 2em
name:
- justify-self: start
- font-size: 0.70em
- font-weight: 900
- text-decoration: underline
state:
- justify-self: start
- font-size: 0.6em
exclude: []
show_empty: false
card_param: cards
- type: vertical-stack
cards:
- type: custom:button-card
show_name: false
show_icon: false
show_state: false
styles:
grid:
- grid-template-areas: "\"card1 card2\" "
- grid-template-columns: 1fr 1fr
- grid-template-rows: 1fr
card:
- margin-top: 20px
- padding: 5px 0px 5px 10px
- background: rgba(0,0,255,0.1)
- border: 1px solid blue
- border-radius: 5px
- box-shadow: 0px -1px 15px blue
custom_fields:
card1:
- width: 90%
card2:
- align-self: top
- height: 100%
custom_fields:
card1:
card:
type: custom:mushroom-title-card
title: HACS
alignment: start
subtitle: v{{ state_attr('update.hacs_update', 'installed_version') }}
card_mod:
style: |
.header {
padding: 0px !important;
}
.header div {
margin: 0px !important
}
card2:
card:
type: markdown
content: >-
{% set
maj=integration_entities('hacs')|select('search','update.')|select('is_state','on')|list%}
{% set
total=integration_entities('hacs')|select('search','update.')|list|count|int(2)
%} {% set maj_count = maj|count|int(2) %} {% if maj_count == 0
%} <ha-alert alert-type="success" title="{{maj_count}} sur
{{total}} " > {% elif maj_count >= 1 %} <ha-alert
alert-type="warning" title="{{maj_count}} mise a jour sur
{{total}} " ></ha-alert> {% else %} {% endif %}
card_mod:
style: |
:host {
--ha-card-margin: 0px;
--ha-card-background: #00000000 !important;
--ha-card-border-color: #00000000 !important;
}
ha-markdown.no-header {
padding: 0px !important;
margin: 0px !important;
}
- type: custom:auto-entities
card:
square: false
type: grid
columns: 2
filter:
include:
- domain: update
state: "on"
integration: hacs
options:
show_name: true
show_icon: true
show_entity_picture: true
variables:
url: |
[[[
return entity.attributes.release_url
]]]
sensor: |
[[[
let name = Object.values(entity)
return name[0]
]]]
type: custom:button-card
name: |
[[[
return entity.attributes.friendly_name.replace('update','')
]]]
state_display: >
[[[
if(entity.state== "on" & entity.attributes.in_progress ==
false)
return entity.attributes.installed_version +' - ' + entity.attributes.latest_version
else if(entity.state== "off")
return helpers.localize(entity) +' - '+ entity.attributes.installed_version
else
return "instal - "+entity.attributes.in_progress+"%"
]]]
show_state: true
tap_action:
action: url
url_path: |
[[[
return variables.url
]]]
custom_fields:
upload:
card:
show_icon: true
type: custom:button-card
size: 2em
icon: |
[[[
if(entity.state == "off")
return ""
if(entity.attributes.in_progress == false)
return 'mdi:upload-circle'
else return 'mdi:rotate-right'
]]]
styles:
card:
- padding: 0px
- margin-top: 0px
- background: none
- border: none
icon:
- animation: |
[[[
if(entity.attributes.in_progress == false)
return ''
else return 'rotating 1s linear infinite'
]]]
- color: |
[[[
if(entity.state == 'on' & entity.attributes.in_progress != false)
return 'green'
else return 'rgba(255, 182, 56, 1)'
]]]
- left: 15%
tap_action:
action: perform-action
perform_action: update.install
target:
entity_id: "[[[return variables.sensor]]]"
styles:
grid:
- grid-template-columns: 1fr 1.8fr 1fr;
- grid-template-rows: repeat(2, 50%);
- gap: 0px 0px;
- grid-template-areas: "\"i n upload\" \"i s upload\""
card:
- padding: 5px
icon:
- width: 2em
name:
- justify-self: start
- font-size: 0.70em
- font-weight: 900
- text-decoration: underline
state:
- justify-self: start
- font-size: 0.6em
exclude: []
show_empty: true
card_param: cards
- type: vertical-stack
cards:
- type: custom:button-card
show_name: false
show_icon: false
show_state: false
styles:
grid:
- grid-template-areas: "\"card1 card2\" "
- grid-template-columns: 1fr 1fr
- grid-template-rows: 1fr
card:
- margin-top: 20px
- padding: 5px 0px 5px 10px
- background: rgba(0,0,255,0.1)
- border: 1px solid blue
- border-radius: 5px
- box-shadow: 0px -1px 15px blue
custom_fields:
card1:
- width: 90%
card2:
- align-self: top
- height: 100%
custom_fields:
card1:
card:
type: custom:mushroom-title-card
title: ZigBee2MQTT
subtitle: >-
v{{
state_attr('update.zigbee2mqtt_proxy_update','installed_version')
}}
alignment: start
card_mod:
style: |
.header {
padding: 0px !important;
}
.header div {
margin: 0px !important
}
card2:
card:
type: markdown
content: >-
{% set
maj=integration_entities('mqtt')|select('search','update.')|select('is_state','on')|list%}
{% set
total=integration_entities('mqtt')|select('search','update.')|list|count|int(2)
%} {% set maj_count = maj|count|int(2) %} {% if maj_count == 0
%} <ha-alert alert-type="success" title="{{maj_count}} sur
{{total}} " > {% elif maj_count >= 1 %} <ha-alert
alert-type="warning" title="{{maj_count}} mise a jour sur
{{total}} " ></ha-alert> {% else %} {% endif %}
card_mod:
style: |
:host {
--ha-card-margin: 0px;
--ha-card-background: #00000000 !important;
--ha-card-border-color: #00000000 !important;
}
ha-markdown.no-header {
padding: 0px !important;
margin: 0px !important;
}
- type: custom:auto-entities
card:
square: false
type: grid
columns: 2
filter:
include:
- domain: update
integration: mqtt
state: "on"
options:
show_name: true
show_icon: true
show_entity_picture: true
variables:
url: |
[[[
return entity.attributes.release_url
]]]
sensor: |
[[[
let name = Object.values(entity)
return name[0]
]]]
type: custom:button-card
name: |
[[[
return entity.attributes.friendly_name.replace('Home Assistant','HA').replace('Update','')
]]]
state_display: |
[[[ if(entity.state== "on" & entity.attributes.in_progress == false)
return 'v' + entity.attributes.installed_version +' - v' + entity.attributes.latest_version
else if(entity.state== "off")
return helpers.localize(entity) +' - v'+ entity.attributes.installed_version
else
return "instal - "+entity.attributes.in_progress+"%"
]]]
show_state: true
tap_action:
action: url
url_path: |
[[[
return variables.url
]]]
custom_fields:
upload:
card:
show_icon: true
type: custom:button-card
size: 2em
icon: |
[[[
if(entity.state == "off")
return ""
if(entity.attributes.in_progress == false)
return 'mdi:upload-circle'
else return 'mdi:rotate-right'
]]]
styles:
card:
- padding: 0px
- margin-top: 0px
- background: none
- border: none
icon:
- animation: |
[[[
if(entity.attributes.in_progress == false)
return ''
else return 'rotating 1s linear infinite'
]]]
- color: |
[[[
if(entity.state == 'on')
return 'rgba(255, 182, 56, 1)'
else return 'green'
]]]
- left: 15%
tap_action:
action: perform-action
perform_action: update.install
target:
entity_id: "[[[return variables.sensor]]]"
styles:
grid:
- grid-template-columns: 1fr 1.8fr 1fr;
- grid-template-rows: repeat(2, 50%);
- gap: 0px 0px;
- grid-template-areas: "\"i n upload\" \"i s upload\""
card:
- padding: 5px
icon:
- width: 2em
name:
- justify-self: start
- font-size: 0.70em
- font-weight: 900
- text-decoration: underline
state:
- justify-self: start
- font-size: 0.6em
exclude: null
show_empty: true
card_param: cards
- type: vertical-stack
cards:
- type: custom:auto-entities
card:
square: false
type: grid
title: Add-ons et autres
columns: 2
filter:
include:
- domain: update
state: "on"
options:
show_name: true
show_icon: true
show_entity_picture: true
variables:
url: |
[[[
return entity.attributes.release_url
]]]
sensor: |
[[[
let name = Object.values(entity)
return name[0]
]]]
type: custom:button-card
name: |
[[[
return entity.attributes.friendly_name.replace('Home Assistant','HA').replace('Update','')
]]]
state_display: |
[[[ if(entity.state== "on")
return 'v' + entity.attributes.installed_version +' - v' + entity.attributes.latest_version
else if(entity.state== "off")
return helpers.localize(entity) +' - v'+ entity.attributes.installed_version
else
return "instal - "+entity.attributes.in_progress+"%"
]]]
show_state: true
tap_action:
action: url
url_path: |
[[[
return variables.url
]]]
custom_fields:
upload:
card:
show_icon: true
type: custom:button-card
size: 2em
icon: |
[[[
if(entity.state == "off")
return ""
if(entity.attributes.in_progress == false)
return 'mdi:upload-circle'
else return 'mdi:rotate-right'
]]]
styles:
card:
- padding: 0px
- margin-top: 0px
- background: none
- border: none
icon:
- animation: |
[[[
if(entity.attributes.in_progress == false)
return ''
else return 'rotating 1s linear infinite'
]]]
- color: |
[[[
if(entity.state == 'on')
return 'rgba(255, 182, 56, 1)'
else return 'green'
]]]
- left: 15%
tap_action:
action: perform-action
perform_action: update.install
target:
entity_id: "[[[return variables.sensor]]]"
styles:
grid:
- grid-template-columns: 1fr 1.8fr 1fr;
- grid-template-rows: repeat(2, 50%);
- gap: 0px 0px;
- grid-template-areas: "\"i n upload\" \"i s upload\""
card:
- padding: 5px
icon:
- width: 2em
name:
- justify-self: start
- font-size: 0.70em
- font-weight: 900
- text-decoration: underline
state:
- justify-self: start
- font-size: 0.6em
exclude:
- name: Home*
- integration: hacs
- integration: mqtt
show_empty: true
card_param: cards
sort:
method: domain
ignore_case: false
ip: false
reverse: false
numeric: false
- type: markdown
content: >-
{%set
rejet=['update.home_assistant_core_update','update.home_assistant_operating_system_update','update.home_assistant_supervisor_update']%}
{% set
total=integration_entities('hassio')|select('search','update.')|reject('in',rejet)|list
%}
{% set maj=total|select('is_state','on')|list|count%}
{% set maj_count = total|count %}
{% if maj== 0 %} <ha-alert alert-type="success" title="{{maj}} sur
{{maj_count}} " > {% elif maj >= 1 %} <ha-alert alert-type="warning"
title="{{maj}} mise a jour sur {{maj_count}} " ></ha-alert> {% else %}
{% endif %}
card_mod:
style: |
:host {
--ha-card-background: #00000000 !important;
--ha-card-border-color: #00000000 !important;
}
Bonjour, et merci pour la carte.
Je n’ai pas cette entité : sensor.home_assistant_core_cpu_percent,
c’est un calcul perso ou autre ?
ButtonCardJSTemplateError: TypeError: Cannot read properties of undefined (reading 'state') in 'if(states["sensor.home_assistant_core_cpu_percent"].state == "unavailable") return ' rotating r...'
Merci.
@WarC0zes Merci, effectivement ça fonctionne mieux
Tu aurais ton code complet ?
J’ai mis à jour mon post: Maj de HACS version 1.34, vers la version 2.0. procédure d'installation? - #72 par mrgrlscz
Merci!
Je parlais surtout de ta carte complete, mais je vais fouiller dans le post pour pas t’embeter avec ca
re-MAJ du messagen, normalement y’a tout ^^
C’est top merci beaucoup!