neilimixamo / Home-Assistant-Quick-Look-Mobile

118 stars 6 forks source link

Replacing Upper Right Assist Card #32

Closed Michelone86 closed 4 months ago

Michelone86 commented 4 months ago

Hi @neilimixamo, I want to replace the assistant function. I managed to change the icon and start a script, working on the header file in the template section. However, I would like a number taken from a specific numerical entity to appear at the top right of the mail icon.

How can I do? Thank you!

Screenshot_20240520_181601_edit_663790113968761 Screenshot_20240520_181707_edit_663831612987495

neilimixamo commented 4 months ago

Yep, adding a mail counter is a nice idea, here is how to do it :

New header code ```yaml right_menu: card: type: custom:button-card icon: mdi:mail size: 80% styles: card: - overflow: visible - height: 4.2vh - width: 4.2vh - box-shadow: none - border-radius: 50% - background-color: transparent - cursor: none - --mdc-ripple-press-opacity: 0 custom_fields: badge: card: type: custom:button-card entity: counter.contatore_posta show_icon: false show_label: true show_name: false show_state: true styles: state: - font-size: 12px - font-weight: 500 - color: var(--text) - display: flex - justify-content: center - align-items: center card: - height: 2.5vh - width: 2.5vh - border-radius: 50% - border: solid - border-width: 1px - position: absolute - top: -4.5vh - right: -1.0vw - background: 'var(--badge-background)' - border-color: 'var(--badge-border-color)' - box-shadow: 'none' - cursor: none - --mdc-ripple-press-opacity: 0 - display: | [[[ if (states['counter.contatore_posta'].state == 0) { return 'none'; } else { return 'flex'; } ]]] tap_action: action: none #disables unwanted tap_action on the badge tap_action: action: toggle entity: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx ```

Just add your script entity at last line 👍

Michelone86 commented 4 months ago

Hi @neilimixamo, I tried your new code, I think there is something wrong or I made a mistake...

Screenshot_20240520_214849

neilimixamo commented 4 months ago

Did you copy-paste full code and add your script.entity at last line ? If yes, can you check what state is returning counter.contatore_posta in dev tools ?

Michelone86 commented 4 months ago

Hi @neilimixamo , everything works great, I copied the code wrong... thanks a lot!