Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable card title #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ game_background: true
type: 'custom:kb-steam-card'
```

to adjust the card title you can use the `title` attribute:

```yaml
type: 'custom:kb-steam-card'
entities: sensor.steam_
title: Steam Friends
```

## Stay in touch

- Author - [Neil Kalman](https://github.com/thatkookooguy)
Expand Down
2 changes: 1 addition & 1 deletion dist/kb-steam-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const J=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
<ha-card>
${this.config.entity?this.createEntityCard(this.hass.states[this.config.entity]):this.createEntitiesCard(this.config.entities)}
</ha-card>
`}setConfig(t){if(!t.entities&&!t.entity)throw new Error("You need to define either a single entity or an entities field");this.config=t}getCardSize(){return this.config.entities?this.config.entities.length+1:2}_toggle(t){this.hass.callService("homeassistant","toggle",{entity_id:t.entity_id})}createEntitiesCard(t){if("string"==typeof t){const e=[];Object.values(this.hass.states).forEach((s=>{s.entity_id.startsWith(t)&&e.push(s.entity_id)})),t=e}if(this.config.online_only){const e=[];t.forEach((t=>{const s=this.hass.states[t];s&&s.state&&"offline"!==s.state&&e.push(t)})),t=e}return[M` <div class="card-header"><div class="name">Steam Friends</div></div> `,...t.map(((e,s)=>{const i=this.hass.states[e];return i?M`
`}setConfig(t){if(!t.entities&&!t.entity)throw new Error("You need to define either a single entity or an entities field");this.config=t}getCardSize(){return this.config.entities?this.config.entities.length+1:2}_toggle(t){this.hass.callService("homeassistant","toggle",{entity_id:t.entity_id})}createEntitiesCard(t){var e,s;if("string"==typeof t){const e=[];Object.values(this.hass.states).forEach((s=>{s.entity_id.startsWith(t)&&e.push(s.entity_id)})),t=e}if(this.config.online_only){const e=[];t.forEach((t=>{const s=this.hass.states[t];s&&s.state&&"offline"!==s.state&&e.push(t)})),t=e}const i=null!==(e=(s=this.config).title)&&void 0!==e?e:s.title="Steam Friends";return[M` <div class="card-header"><div class="name">${i}</div></div> `,...t.map(((e,s)=>{const i=this.hass.states[e];return i?M`
<div
class="kb-steam-multi kb-clickable ${s===t.length-1?"kb-last":""} ${i.state}"
@click=${()=>this.handlePopup(i)}
Expand Down
Loading