Skip to content

Commit

Permalink
add new show_title:false support
Browse files Browse the repository at this point in the history
  • Loading branch information
ironsheep committed Sep 26, 2020
1 parent 4a906f2 commit a986696
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 23 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,17 @@ If you don't use HACS please change the url accordingly.
## Configuration
| Name | Type | Default | Description |
| ------------- | ------ | ------------------ | ----------------------------------------------------------------------- |
| type | string | **Required** | `custom:rpi-monitor-card` |
| entity | string | **Required** | Entity State |
| name | string | none | Overrides default title of the card. (Default: RPi Monitor {FQDN}) |
| name_prefix | string | 'RPi monitor' | Overrides default name prefix(Default: 'RPi Monitor') |
| card_style | string | 'glance' or 'full' | Card layout desired for this RPi. (Default is full) |
| temp_scale | string | 'C' or 'F' | Show Temperature in Celsius (C) or Fahrenheit (F). (Default is C) |
| fs_severity | object | none | A list of severity values. See [Severity Coloring](#severity-coloring). |
| temp_severity | object | none | A list of severity values. See [Severity Coloring](#severity-coloring). |
| Name | Type | Default | Description |
| ------------- | ------- | ------------------ | ----------------------------------------------------------------------- |
| type | string | **Required** | `custom:rpi-monitor-card` |
| entity | string | **Required** | Entity State |
| name | string | none | Overrides default title of the card. (Default: RPi Monitor {FQDN}) |
| name_prefix | string | 'RPi monitor' | Overrides default name prefix(Default: 'RPi Monitor') |
| card_style | string | 'glance' or 'full' | Card layout desired for this RPi. (Default is full) |
| temp_scale | string | 'C' or 'F' | Show Temperature in Celsius (C) or Fahrenheit (F). (Default is C) |
| fs_severity | object | none | A list of severity values. See [Severity Coloring](#severity-coloring). |
| temp_severity | object | none | A list of severity values. See [Severity Coloring](#severity-coloring). |
| show_title | boolean | true | Show / hide the Title for this card. (Default is show - 'true') |

### Threashold Monitoring

Expand Down
21 changes: 11 additions & 10 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@ If you don't use HACS please change the url accordingly.
## Configuration
| Name | Type | Default | Description |
| ------------- | ------ | ------------------ | ----------------------------------------------------------------------- |
| type | string | **Required** | `custom:rpi-monitor-card` |
| entity | string | **Required** | Entity State |
| name | string | none | Overrides default title of the card. (Default: RPi Monitor {FQDN}) |
| name_prefix | string | 'RPi monitor' | Overrides default name prefix(Default: 'RPi Monitor') |
| card_style | string | 'glance' or 'full' | Card layout desired for this RPi. (Default is full) |
| temp_scale | string | 'C' or 'F' | Show Temperature in Celsius (C) or Fahrenheit (F). (Default is C) |
| fs_severity | object | none | A list of severity values. See [Severity Coloring](#severity-coloring). |
| temp_severity | object | none | A list of severity values. See [Severity Coloring](#severity-coloring). |
| Name | Type | Default | Description |
| ------------- | ------- | ------------------ | ----------------------------------------------------------------------- |
| type | string | **Required** | `custom:rpi-monitor-card` |
| entity | string | **Required** | Entity State |
| name | string | none | Overrides default title of the card. (Default: RPi Monitor {FQDN}) |
| name_prefix | string | 'RPi monitor' | Overrides default name prefix(Default: 'RPi Monitor') |
| card_style | string | 'glance' or 'full' | Card layout desired for this RPi. (Default is full) |
| temp_scale | string | 'C' or 'F' | Show Temperature in Celsius (C) or Fahrenheit (F). (Default is C) |
| fs_severity | object | none | A list of severity values. See [Severity Coloring](#severity-coloring). |
| temp_severity | object | none | A list of severity values. See [Severity Coloring](#severity-coloring). |
| show_title | boolean | true | Show / hide the Title for this card. (Default is show - 'true') |

### Threashold Monitoring

Expand Down
2 changes: 1 addition & 1 deletion src/const.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const CARD_VERSION = '1.2.4';
export const CARD_VERSION = '1.2.5';

/*
* EXAMPLE attributes
Expand Down
28 changes: 26 additions & 2 deletions src/rpi-monitor-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,19 @@ export class RPiMonitorCard extends LitElement {

const rpi_fqdn = this._getAttributeValueForKey(Constants.RPI_FQDN_KEY);
let cardName = 'RPi monitor ' + rpi_fqdn;

cardName = this._config.name_prefix != undefined ? this._config.name_prefix + ' ' + rpi_fqdn : cardName;
cardName = this._config.name != undefined ? this._config.name : cardName;

const showCardName = this._config.show_title != undefined ? this._config.show_title : true;
if (showCardName == false) {
cardName = '';
}

const last_heard_full_class = showCardName == false ? 'last-heard-full-notitle' : 'last-heard-full';

const last_heard_class = showCardName == false ? 'last-heard-notitle' : 'last-heard';

const card_timestamp_value = this._getRelativeTimeSinceUpdate();

if (this._useFullCard()) {
Expand All @@ -385,7 +395,7 @@ export class RPiMonitorCard extends LitElement {
>
<div id="states" class="card-content">
${fullRows}
<div id="card-timestamp" class="last-heard-full">${card_timestamp_value}</div>
<div id="card-timestamp" class=${last_heard_full_class}>${card_timestamp_value}</div>
</div>
</ha-card>
`;
Expand All @@ -406,7 +416,7 @@ export class RPiMonitorCard extends LitElement {
>
<div class="content">
${glanceRows}
<div id="card-timestamp" class="last-heard">${card_timestamp_value}</div>
<div id="card-timestamp" class=${last_heard_class}>${card_timestamp_value}</div>
</div>
</ha-card>
`;
Expand Down Expand Up @@ -1142,6 +1152,20 @@ export class RPiMonitorCard extends LitElement {
font-size: 12px;
color: var(--primary-text-color);
}
.last-heard-full-notitle {
position: absolute;
top: 3px;
right: 30px;
font-size: 12px;
color: var(--primary-text-color);
}
.last-heard-notitle {
position: absolute;
bottom: 5px;
right: 90px;
font-size: 12px;
color: var(--primary-text-color);
}
`;
}
}
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface RPiMonitorCardConfig extends LovelaceCardConfig {
temp_severity?: any;
temp_scale?: string;
name_prefix?: string;
show_title?: boolean;

show_warning?: boolean;
show_error?: boolean;
Expand Down

0 comments on commit a986696

Please sign in to comment.