Skip to content

Commit

Permalink
fix issue #1
Browse files Browse the repository at this point in the history
Cacher titre by Davxci
Ajout possibilité de cacher le titre plus simplement, ajout exemple dans readme
  • Loading branch information
tagcashdev committed Nov 22, 2022
1 parent 272fd19 commit 97e0d1b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
12 changes: 5 additions & 7 deletions hatc-gauge-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ class HatcGaugeCard extends LitElement {
h['icon'] = (typeof hTitle.icon !== 'undefined') ? hTitle.icon : icon;
}else{
h['name'] = hTitle;
if(hTitle === '' || hTitle === false || hTitle === 'hide'){
h['icon'] = hTitle;
}
}

var heTitle = showTitleEntity ? hassEntity.attributes.friendly_name : '';
Expand All @@ -174,6 +177,7 @@ class HatcGaugeCard extends LitElement {
g['maxvalue'] = (typeof hGauge['max_value'] !== 'undefined') ? hGauge['max_value'] : '100';

g['state'] = (typeof hGauge['state'] !== 'undefined') ? hGauge['state'] : true;
console.log("heIcon", heIcon);
g['icon'] = (typeof hGauge['icon'] !== 'undefined') ? hGauge['icon'] : (heIcon !== '' && heIcon !== false && heIcon !== 'hide') ? heIcon : icon;

// Severity config
Expand Down Expand Up @@ -216,7 +220,7 @@ class HatcGaugeCard extends LitElement {
g['unitofmeasurement'] = heUnitOfMeasurement;
g['maxvalue'] = '100';
g['state'] = true;
g['icon'] = heIcon;
g['icon'] = (heIcon !== '' && heIcon !== false && heIcon !== 'hide') ? heIcon : icon;

textstateColor= 'white';
}
Expand All @@ -243,7 +247,6 @@ class HatcGaugeCard extends LitElement {
var hIconHTML = (hE.heIcon !== '' && hE.heIcon !== false && hE.heIcon !== 'hide') ? html`<ha-icon style="${h.fontsize} color:${h.iconcolor};" .icon="${hE.heIcon}"></ha-icon>` : '';
var hNameHTML = (h.name !== '' && h.name !== false && h.name !== 'hide') ? html`<div style="${h.fontsize} color:${h.color};" class="name">${h.name}</div>` : '';
var gStateHTML = (g.state !== '' && g.state !== false && g.state !== 'hide') ? html`${hE.heState}${hE.heUnitOfMeasurement}` : '';
console.log(g.icon);
var gIconHTML = (g.icon !== '' && g.icon !== false && g.icon !== 'hide') ? html`<ha-icon style="--mdc-icon-size: ${g.iconsize}; color:${g.iconcolor};" .icon="${g.icon}"></ha-icon>` : '';

var percent = calcPercent(hE.heState, g.maxvalue);
Expand Down Expand Up @@ -315,7 +318,6 @@ class HatcGaugeCard extends LitElement {
}

_handlePopup(e) {
console.log('this.config.tap_action', this.config.tap_action);
var tap_action = this.config.tap_action || {};
if (this.config.entity) {
if (typeof this.config.tap_action === 'undefined') {
Expand All @@ -330,16 +332,13 @@ class HatcGaugeCard extends LitElement {
}
}
}

console.log("tap_action", tap_action);
e.stopPropagation();
handleClick(this, this.hass, tap_action, this.config.entity);
}
}

_handleEntities(e, entity) {
var ent = entity || {};

if (!ent['tap_action']) {
ent = {
tap_action: {
Expand All @@ -348,7 +347,6 @@ class HatcGaugeCard extends LitElement {
}
}
}

e.stopPropagation();
handleClick(this, this.hass, this.config.tap_action, false);
}
Expand Down
Binary file added img/cacher-titre.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 24 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Si vous aimez mon travail likez, abonnez-vous au repo :) Et si vous souhaitez co
#### Title Options
| Name | Type | Requis | Default | Description | Options |
| ---- | ---- | ------ | ------- | ----------- | ------- |
| name | string | Optionnel | - | Titre de la carte | - |
| name | string | Optionnel | - | Titre de la carte | false, string |
| text-align | string | Optionnel | left | Allignement du titre de la carte | left, center, right |
| font-size | string | Optionnel | 22px | Taille du texte du titre de la carte | px, em |
| text-color | string | Optionnel | var(--secondary-text-color) | Couleur du titre de la carte, à noter que severity permet de changer la couleur du texte automatiquement en fonction des couleurs choisi dans l'option severity | severity, red, #ff0000, rgb(255,0,0), var(--color) |
Expand Down Expand Up @@ -142,6 +142,29 @@ title:
```
![Titre options](https://github.com/tagcashdev/hatc-gauge-card/blob/main/img/titre-options.png)
#### Cacher le titre
Solution n°1
```yaml
type: custom:hatc-gauge-card
entity: sensor.temperature_moyenne_hall_d_entree
title:
name: false
icon: false
```
Solution n°2 (à partir de la V0.5.3.2)
```yaml
type: custom:hatc-gauge-card
entity: sensor.temperature_moyenne_hall_d_entree
title: false
```
![Titre options](https://github.com/tagcashdev/hatc-gauge-card/blob/main/img/cacher-titre.png)
#### Gauge options
```yaml
Expand Down

0 comments on commit 97e0d1b

Please sign in to comment.