Skip to content

Commit

Permalink
v0.4.0 Release Candidate (#7)
Browse files Browse the repository at this point in the history
* Displays info from api_message when in NOT_FOUND state
* Updated README with new card examples for api_message
* Updated workflows so they pass
  • Loading branch information
vasqued2 authored Oct 2, 2022
1 parent 56524db commit bdfd057
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 31 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/hacs-validate.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
name: Validate
name: HACS Action

on:
workflow_dispatch:
push:
pull_request:
schedule:
- cron: "0 0 * * *"

jobs:
validate_hacs:
name: "HACS Validation"
runs-on: ubuntu-latest
hacs:
name: HACS Action
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v2"
- name: HACS Action
uses: "hacs/action@main"
with:
category: "plugin"
# validate_hassfest:
# name: "Hassfest Validation"
# runs-on: "ubuntu-latest"
# steps:
# - uses: "actions/checkout@v2"
# - uses: home-assistant/actions/hassfest@master
41 changes: 29 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@ This card was strongly based on the fantastic [ha-nfl-card](https://github.com/D
- For example, any teamtracker v0.2.x will be compatible with any teamtracker-card v0.2.y.
- Compatibility is not guaranteed across MAJOR or MINOR version numbers.

###    PRE Game Examples
### PRE Game Examples

<img width="409" alt="PRE-football" src="https://user-images.githubusercontent.com/17114183/187316418-86927b91-d4cb-4d6d-9125-13045a1b6c9a.png">
<img width="410" alt="PRE-hockey" src="https://user-images.githubusercontent.com/17114183/187316485-68bd6d2a-2784-4c4c-8793-045b83335cef.png">
<img width="409" alt="PRE-basketball" src="https://user-images.githubusercontent.com/17114183/187316566-27edc6c2-b68d-4b12-ae58-a56bb6a4db59.png">

### &nbsp;&nbsp;&nbsp;IN Game Examples
### IN Game Examples

![IN-baseball](https://user-images.githubusercontent.com/17114183/187316734-53688f9c-bd7a-44a1-b3a6-36894c5669c2.png)
<img width="409" alt="IN-soccer" src="https://user-images.githubusercontent.com/17114183/187316787-97aca588-56c3-4737-9df6-aef86fc0c503.png">
![IN-soccer-CLB](https://user-images.githubusercontent.com/17114183/193429458-6c19c6d3-e44e-49a6-9299-4cfed1480482.png)
![IN-football](https://user-images.githubusercontent.com/17114183/187316807-b694d4ad-a895-4047-a700-264b41f91adc.png)

### &nbsp;&nbsp;&nbsp;POST Game Examples
### POST Game Examples

![POST-football](https://user-images.githubusercontent.com/17114183/187316885-7bbff2de-0382-47be-b775-116a45b9b636.png)
![POST-soccer2](https://user-images.githubusercontent.com/17114183/187316901-d40f8e2f-b86d-4cab-9713-976402cd94fb.png)

### &nbsp;&nbsp;&nbsp;BYE and NOT FOUND (No Upcoming Game) Examples
### NOT_FOUND (No Upcoming Game, API Error) and BYE Examples

![NF-hockey](https://user-images.githubusercontent.com/17114183/187316958-617173d1-a6f2-4cf5-8abe-3a58ae40ff8e.png)
![NF-ncaaf](https://user-images.githubusercontent.com/17114183/187316966-495ca610-c28a-401d-a4a1-080445d98894.png)
![NoScheduledGames](https://user-images.githubusercontent.com/17114183/193429143-7af63cd3-d6e4-47f1-9014-cceeac4a886c.png)
![APIerror](https://user-images.githubusercontent.com/17114183/193429159-af48b6f7-f106-4999-bbfa-95865f0ff0d9.png)
![NF-football](https://user-images.githubusercontent.com/17114183/187316983-998527e7-c75d-421a-8833-d00e7ddb4ddc.png)

## HACS Installation
- In the HACS UI, click the 3 dots in the upper right
- Click 'Add Custom Repository'
- Fill in the repo url https://github.com/vasqued2/ha-teamtracker-card and choose 'Lovelace' category.
- install the custom card
- Add the following to your resources
- Install the custom card
- HACS should automatically add the following to your resources:
```
url: /hacsfiles/ha-teamtracker-card/ha-teamtracker-card.js
type: Javascript Module
Expand All @@ -52,7 +52,10 @@ url: /hacsfiles/ha-teamtracker-card/ha-teamtracker-card.js
type: Javascript Module
```

## Options
## Adding the Card to the Dashboard
Add a Manual card to the dashboard and enter the YAML to configure it as desired.

### Options
| Name | Description | Default | Required | Values |
| --- | --- | --- | --- | --- |
| `entity` | Name of ha-teamtracker sensor | `sensor.team_tracker` | Yes | Valid sensor |
Expand All @@ -61,7 +64,8 @@ type: Javascript Module
| `show_timeouts` | Specifies if timeout indicators should be shown. | `true` | No | `true` `false` |
| `show_rank` | Specifies if team rank should be shown. | `true` | No | `true` `false` |

## Examples
### Examples
#### Example 1
```
type: 'custom:teamtracker-card'
entity: sensor.team_tracker
Expand All @@ -71,6 +75,7 @@ outline_color: deeppink

![PINK-example](https://user-images.githubusercontent.com/17114183/187317324-f1a9764b-5443-46e5-b000-b9c61a7856ef.png)

#### Example 2
```
type: 'custom:teamtracker-card'
entity: sensor.team_tracker
Expand All @@ -80,8 +85,20 @@ outline_color: '#ffe500'

![OUTLINE-example](https://user-images.githubusercontent.com/17114183/187317354-496ed84a-fe27-496d-a75e-7163fcea3845.png)

#### Example 3
```
type: 'custom:teamtracker-card'
entity: sensor.team_tracker
outline: true
outline_color: lightgray
show_timeouts: false
show_rank: true
```

![RankNoTimeouts-dark](https://user-images.githubusercontent.com/17114183/193429227-5d4ec3fc-d934-4eb9-947e-b6bae89c88ff.png)


## Minimal Required Configuration
### Minimal Required Configuration
```
type: 'custom:teamtracker-card'
entity: sensor.team_tracker
Expand Down
40 changes: 32 additions & 8 deletions dist/ha-teamtracker-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ class TeamTrackerCard extends LitElement {
var gameDate = dateForm.toLocaleDateString('en-US', { day: '2-digit' });
var outColor = outlineColor;

var lastDate = ""
if (stateObj.attributes.api_message) {
lastDate = "API Error"
var apiTail = stateObj.attributes.api_message.substring(stateObj.attributes.api_message.length - 17)
if (apiTail.slice(-1) == "Z") {
lastDate = apiTail
var lastDateForm = new Date (apiTail)
lastDate = "through " + lastDateForm.toLocaleDateString('en-US')
}
}


var overUnder = '';
if (stateObj.attributes.overunder) {
overUnder = 'O/U: ' + stateObj.attributes.overunder;
Expand Down Expand Up @@ -108,10 +120,8 @@ class TeamTrackerCard extends LitElement {
if (stateObj.attributes.last_play) {
lastPlaySpeed = 18 + Math.floor(stateObj.attributes.last_play.length/40) * 5;
}
var nfTeamBG = stateObj.attributes.league_logo;
var nfTeam = stateObj.attributes.league_logo;
var nfTerm1 = stateObj.attributes.league + ": " + stateObj.attributes.team_abbr;
var nfTerm2 = 'No Upcoming Games'
var notFoundTeamBG = stateObj.attributes.league_logo;
var notFoundTeam = stateObj.attributes.league_logo;
var startTerm = 'Kickoff';
var probTerm = 'Win Probability';
var playClock = stateObj.attributes.clock;
Expand All @@ -131,6 +141,19 @@ class TeamTrackerCard extends LitElement {
if (this._config.show_rank == false) {
rankDisplay = 'none';
}

var notFoundTerm1 = stateObj.attributes.league + ": " + stateObj.attributes.team_abbr;
var notFoundTerm2 = ""
if (stateObj.attributes.api_message) {
notFoundTerm2 = "API Error"
var apiTail = stateObj.attributes.api_message.substring(stateObj.attributes.api_message.length - 17)
if (apiTail.slice(-1) == "Z") {
lastDate = apiTail
var lastDateForm = new Date (apiTail)
notFoundTerm2 = "No upcoming games through " + lastDateForm.toLocaleDateString('en-US')
}
}

//
// MLB Specific Changes
//
Expand Down Expand Up @@ -212,7 +235,7 @@ class TeamTrackerCard extends LitElement {
// NCAA Specific Changes
//
if (stateObj.attributes.league.includes("NCAA")) {
nfTeam = 'https://a.espncdn.com/i/espn/misc_logos/500/ncaa.png'
notFoundTeam = 'https://a.espncdn.com/i/espn/misc_logos/500/ncaa.png'
}

if (stateObj.state == 'POST') {
Expand Down Expand Up @@ -472,15 +495,16 @@ class TeamTrackerCard extends LitElement {
.name { font-size: 1.6em; margin-bottom: 4px; }
.line { height: 1px; background-color: var(--primary-text-color); margin:10px 0; }
.eos { font-size: 1.8em; line-height: 1.2em; text-align: center; width: 50%; }
.eos2 { font-size: 1.4em; line-height: 1.2em; text-align: center; width: 50%; display: inline; }
</style>
<ha-card>
<div class="card">
<img class="team-bg" src="${nfTeamBG}" />
<img class="team-bg" src="${notFoundTeamBG}" />
<div class="card-content">
<div class="team">
<img src="${nfTeam}" />
<img src="${notFoundTeam}" />
</div>
<div class="eos">${nfTerm1}<br />${nfTerm2}</div>
<div><span class="eos">${notFoundTerm1}</span><span class="eos2"><br /><br />${notFoundTerm2}</span></div>
</div>
</ha-card>
`;
Expand Down

0 comments on commit bdfd057

Please sign in to comment.