Sports Standings and Scores

Sorry that there is such a stress in the other topic teamtracker.

No problem. I thought about it today. Just create a group that has all your favorites in it Then iterate over that groups entities. So I will add this in the documentation, simple post here:

Just create a group using the group helper or using YAML if you prefer. FOr example in YAML:

group:
  team_favorities:
      name: Team Favorities
      entities:
          - sensor.detroit_lions
          - sensor.detroit_pistons
          - sensor.detroit_red_wings
          - sensor.detroit_tigers

Then an example using auto-entities could be this.

type: custom:auto-entities
unique: true
show_empty: false
card:
  type: custom:layout-card
  layout_type: masonry
card_param: cards
filter:
  template: |
    {%- for team in state_attr('group.team_favorities','entity_id') -%}
      {%- if state_attr(team, "team_homeaway") == "home" -%}
        {{{"type": "custom:teamtracker-card",
          "entity": team,
           "home_side": "right"}}},
      {%- endif -%}
    {%- endfor -%}
  exclude:
    - entity_id: '*team_tracker*'
sort:
  method: attribute
  attribute: date

Because this has the IF that filters out only the home teams, if two favorites are playing eachother, only the home team is listed. Tested right now by adding the Avalanche in the group and it lists Wings v Avalanche only once even though both are favorites.

Ok, I have create a helper with the typ group (sensor.nhl_favoriten)

but this code don`t work:

type: custom:auto-entities
unique: true
show_empty: false
card:
  type: custom:layout-card
  layout_type: masonry
card_param: cards
filter:
  template: |
    {%- for team in state_attr('sensor.nhl_favoriten','entity_id') -%}
      {%- if state_attr(team, "team_homeaway") == "home" -%}
        {{{"type": "custom:teamtracker-card",
          "entity": team,
           "home_side": "right"}}},
      {%- endif -%}
    {%- endfor -%}
  exclude:
    - entity_id: '*team_tracker*'
sort:
  method: attribute
  attribute: date

If I go to develloper tools I see this:

What make I wrong?

I donā€™t use helpers because I cannot see. Can you grab screenshot of helper? It looks like there are no entities. Mine is like this:

YOu would create a Group in Help choosing ā€œSensor groupā€.
Then add members which would be the teams you wish like ā€œsensor.seattle_krakenā€.

I think I see the issue, it is totally unclear what to ā€œchooseā€ for the last field to me ā€“ Please use YAML to configure

ok, I have now use yaml and create the group. Now it works.

But how can I add the markdown code:

                        - type: markdown
                          content: >-
                            <table> <tr> <td> Red Wings (Seider)

                            <img src =
                            'https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/det.png'
                            height='80'></img>  </td> <td> Senators
                            (StĆ¼tzle) <img src =
                            'https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/ott.png'
                            height='80'></img> </td> </tr> <tr> <td> Oilers
                            (Draiseitl)  <img src =
                            'https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/edm.png'
                            height='80'></img> </td> <td> Kraken (Grubauer)
                            <img src =
                            'https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/sea.png'
                            height='80'></img>  </td> </tr> </table>
                        - type: markdown
                          content: |-
                            Link um Athleten/Teamname herauszufinden:

                            NHL: https://www.espn.co.uk/nhl/teams

after this code:

                    - attributes:
                        label: Favoriten
                        icon: mdi:star
                      card:
                        type: custom:auto-entities
                        unique: true
                        show_empty: false
                        card:
                          type: custom:layout-card
                          layout_type: masonry
                        card_param: cards
                        filter:
                          template: |
                            {%- for team in state_attr('group.nhl_favorities','entity_id') -%}
                              {%- if state_attr(team, "team_homeaway") == "home" -%}
                                {{{"type": "custom:teamtracker-card",
                                  "entity": team,
                                    "home_side": "right"}}},
                              {%- endif -%}
                            {%- endfor -%}
                          exclude:
                            - entity_id: '*team_tracker*'
                        sort:
                          method: attribute
                          attribute: date

I need a picture of what you are trying to display. THe auto-entities will create a card for each entity in the list of entities in your group. WHat else are you trying to display and where?

Sorry, I woult like to display this to boxes on the end:

It is only two markdown boxes

A whole new set of cards. If you look at that code it is displaying a card for each home team in your array of favorites. The core is here:

{{{"type": "custom:teamtracker-card",
 "entity": team,
"home_side": "right"}}},

Create another card that uses type: markdown in the same way.

Now, that said ā€¦ are you looking more for a ā€œplayerā€ tracker?
I was contemplating this and I think I could do way more.
As a matter of fact, I was thinking of doing a fantasy view.
Is that what you are looking for?

I think Iā€™m just indenting it wrong. this is my code.

                    - attributes:
                        label: Favoriten
                        icon: mdi:star
                      card:
                        type: custom:auto-entities
                        unique: true
                        show_empty: false
                        card:
                          type: custom:layout-card
                          layout_type: masonry
                        card_param: cards
                        filter:
                          template: >
                            {%- for team in
                            state_attr('group.team_favorities','entity_id') -%}
                              {%- if state_attr(team, "team_homeaway") == "home" -%}
                                {{{"type": "custom:teamtracker-card",
                                  "entity": team,
                                    "home_side": "right"}}},
                              {%- endif -%}
                            {%- endfor -%}
                          exclude:
                            - entity_id: '*team_tracker*'
                        sort:
                          method: attribute
                          attribute: date
                          type: markdown
                          content: >+
                            <table> <tr> <td> 
                            Red Wings (Seider)
                            <img src ='https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/det.png' height='80'></img>  </td> 
                            <td> Senators
                            (StĆ¼tzle) <img src ='https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/ott.png' height='80'></img> </td> </tr> 
                            <tr> <td> 
                            Oilers (Draiseitl)  <img src ='https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/edm.png' height='80'></img> </td> 
                            <td> Kraken (Grubauer)
                            <img src ='https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/sea.png' height='80'></img>  </td> </tr> </table>

But the markdown don`t display

Yes:

type: vertical-stack
cards:
  - type: custom:auto-entities
    unique: true
    show_empty: false
    card:
      type: custom:layout-card
      layout_type: masonry
    card_param: cards
    filter:
      template: |
        {%- for team in state_attr('group.team_favorities','entity_id') -%}
          {%- if state_attr(team, "team_homeaway") == "home" -%}
            {{{"type": "custom:teamtracker-card",
              "entity": team,
               "home_side": "right"}}},
          {%- endif -%}
        {%- endfor -%}
      exclude:
        - entity_id: '*team_tracker*'
    sort:
      method: attribute
      attribute: date
  - type: markdown
    content: >+
      <table> <tr> <td> 
      Red Wings (Seider)
      <img src ='https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/det.png' height='80'></img>  </td> 
      <td> Senators
      (StĆ¼tzle) <img src ='https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/ott.png' height='80'></img> </td> </tr> 
      <tr> <td> 
      Oilers (Draiseitl)  <img src ='https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/edm.png' height='80'></img> </td> 
      <td> Kraken (Grubauer)
      <img src ='https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/sea.png' height='80'></img>  </td> </tr> </table>

You need a container to put the cards in. In my case I put them into a vertical-stack

Ok but my problem ist, to put this in you dashboard code.

This is my new code:

type: custom:mod-card
card_mod:
  style:
    tabbed-card $: |
      mwc-tab {
        background: var(--ha-card-background, var(--card-background-color, white) );
        border-color: var(--ha-card-border-color, var(--divider-color, #e0e0e0) );
        border-width: 2px;
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
        border-style: solid;
        overflow: hidden;
        width: 25%;
      }
      mwc-tab[active] {
        background: #EBFFD8 !important;
      }
card:
  type: custom:tabbed-card
  styles:
    '--mdc-theme-primary': green
    '--mdc-tab-text-label-color-default': silver
    '--mdc-typography-button-font-size': 12px
  tabs:
    - attributes:
        label: NHL
        icon: mdi:hockey-puck
      card:
        type: custom:mod-card
        card_mod:
          style:
            tabbed-card $: |
              mwc-tab {
                background: var(--ha-card-background, var(--card-background-color, white) );
                border-color: var(--ha-card-border-color, var(--divider-color, #e0e0e0) );
                border-width: 2px;
                border-top-left-radius: 20px;
                border-top-right-radius: 20px;
                border-style: solid;
                overflow: hidden;
                width: 25%;
              }
              mwc-tab[active] {
                background: #EBFFD8 !important;
              }
        card:
          type: custom:tabbed-card
          styles:
            '--mdc-theme-primary': green
            '--mdc-tab-text-label-color-default': silver
            '--mdc-typography-button-font-size': 12px
          tabs:
            - attributes:
                label: Games
                icon: mdi:hockey-sticks
              card:
                type: custom:mod-card
                card_mod:
                  style:
                    tabbed-card $: |
                      mwc-tab {
                        background: var(--ha-card-background, var(--card-background-color, white) );
                        border-color: var(--ha-card-border-color, var(--divider-color, #e0e0e0) );
                        border-width: 2px;
                        border-top-left-radius: 20px;
                        border-top-right-radius: 20px;
                        border-style: solid;
                        overflow: hidden;
                        width: 25%;
                      }
                      mwc-tab[active] {
                        background: #EBFFD8 !important;
                      }
                card:
                  type: custom:tabbed-card
                  styles:
                    '--mdc-theme-primary': green
                    '--mdc-tab-text-label-color-default': silver
                    '--mdc-typography-button-font-size': 12px
                  tabs:
                    - attributes:
                        label: Favoriten
                        icon: mdi:star
                      type: vertical-stack
                      cards:
                        - type: custom:auto-entities
                          unique: true
                          show_empty: false
                          card:
                            type: custom:layout-card
                            layout_type: masonry
                          card_param: cards
                          filter:
                            template: |
                              {%- for team in state_attr('group.team_favorities','entity_id') -%}
                                {%- if state_attr(team, "team_homeaway") == "home" -%}
                                  {{{"type": "custom:teamtracker-card",
                                    "entity": team,
                                     "home_side": "right"}}},
                                {%- endif -%}
                              {%- endfor -%}
                            exclude:
                              - entity_id: '*team_tracker*'
                          sort:
                            method: attribute
                            attribute: date
                        - type: markdown
                          content: >+
                            <table> <tr> <td> 
                            Red Wings (Seider)
                            <img src ='https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/det.png' height='80'></img>  </td> 
                            <td> Senators
                            (StĆ¼tzle) <img src ='https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/ott.png' height='80'></img> </td> </tr> 
                            <tr> <td> 
                            Oilers (Draiseitl)  <img src ='https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/edm.png' height='80'></img> </td> 
                            <td> Kraken (Grubauer)
                            <img src ='https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/sea.png' height='80'></img>  </td> </tr> </table>
                    - attributes:
                        label: POSTGAME
                        icon: mdi:hockey-sticks
                      card:
                        type: custom:decluttering-card
                        template: game_stats
                        variables:
                          - sport: NHL
                          - status: POST
                    - attributes:
                        label: Live
                        icon: mdi:hockey-puck
                      card:
                        type: custom:decluttering-card
                        template: game_stats
                        variables:
                          - sport: NHL
                          - status: IN
                    - attributes:
                        label: PREGAME
                        icon: mdi:map-clock-outline
                      card:
                        type: custom:decluttering-card
                        template: game_stats
                        variables:
                          - sport: NHL
                          - status: PRE
            - attributes:
                label: Standings
                icon: mdi:ballot
              card:
                type: custom:mod-card
                card_mod:
                  style:
                    tabbed-card $: |
                      mwc-tab {
                        background: var(--ha-card-background, var(--card-background-color, white) );
                        border-color: var(--ha-card-border-color, var(--divider-color, #e0e0e0) );
                        border-width: 2px;
                        border-top-left-radius: 20px;
                        border-top-right-radius: 20px;
                        border-style: solid;
                        overflow: hidden;
                        width: 25%;
                      }
                      mwc-tab[active] {
                        background: #EBFFD8 !important;
                      }
                card:
                  type: custom:tabbed-card
                  styles:
                    '--mdc-theme-primary': green
                    '--mdc-tab-text-label-color-default': silver
                    '--mdc-typography-button-font-size': 12px
                  tabs:
                    - attributes:
                        label: Divisional
                      card:
                        type: custom:stack-in-card
                        mode: vertical
                        cards:
                          - type: custom:decluttering-card
                            template: nhl_settings
                            variables:
                              - title: Eastern Atlantic
                              - entity: sensor.nhl_east_atlantic
                              - sort: >-
                                  x.stats.find(y=>y.shortDisplayName ==
                                  'PTS').value
                          - type: custom:decluttering-card
                            template: nhl_settings
                            variables:
                              - title: Eastern Metropolitan
                              - entity: sensor.nhl_east_metropolitan
                              - sort: >-
                                  x.stats.find(y=>y.shortDisplayName ==
                                  'PTS').value
                          - type: custom:decluttering-card
                            template: nhl_settings
                            variables:
                              - title: West Central
                              - entity: sensor.nhl_west_central
                              - sort: >-
                                  x.stats.find(y=>y.shortDisplayName ==
                                  'PTS').value
                          - type: custom:decluttering-card
                            template: nhl_settings
                            variables:
                              - title: West Pacific
                              - entity: sensor.nhl_west_pacific
                              - sort: >-
                                  x.stats.find(y=>y.shortDisplayName ==
                                  'PTS').value
                    - attributes:
                        label: Conference
                      card:
                        type: custom:stack-in-card
                        mode: vertical
                        cards:
                          - type: custom:decluttering-card
                            template: nhl_settings
                            variables:
                              - title: Eastern
                              - entity: sensor.nhl_east_*
                              - sort: >-
                                  x.stats.find(y=>y.shortDisplayName ==
                                  'PTS').value
                          - type: custom:decluttering-card
                            template: nhl_settings
                            variables:
                              - title: Western
                              - entity: sensor.nhl_west_*
                              - sort: >-
                                  x.stats.find(y=>y.shortDisplayName ==
                                  'PTS').value
                    - attributes:
                        label: Overall
                      card:
                        type: custom:decluttering-card
                        template: nhl_settings
                        variables:
                          - title: Overall
                          - entity: sensor.nhl_*_*
                          - sort: x.stats.find(y=>y.shortDisplayName == 'PTS').value
                    - attributes:
                        label: Playoffs
                      card:
                        type: custom:stack-in-card
                        mode: vertical
                        cards:
                          - type: custom:decluttering-card
                            template: nhl_settings
                            variables:
                              - title: Eastern
                              - entity: sensor.nhl_east_*
                              - sort: x.stats[5].value * -1
                          - type: custom:decluttering-card
                            template: nhl_settings
                            variables:
                              - title: Western
                              - entity: sensor.nhl_west_*
                              - sort: x.stats[5].value * -1

But with this code display only this:

Although I havenā€™t made any more changes to the code, a few boxes now appear. But my text from markdown is still missing.

I have this in my group.yaml

  team_favorities:
      name: NHL Favoriten
      entities:
          - sensor.detroit_red_wings
          - sensor.ottawa_senators
          - sensor.edmonton_oilers
          - sensor.seattle_kraken
          - sensor.san_jose_sharks
          - sensor.new_york_rangers
          - sensor.los_vegas_golden_knights

But now I don`t see:

  • sensor.ottawa_senators
  • sensor.seattle_kraken

Why are the two teams and the markdown are missing?

Team favorites sensor was likely created with no ā€œentity_idā€.
This means when you changed it, it likely got a new name ā€¦ like in your case:

sensor.nhl_favoriten_2

Check and see if this happened.

Also one note, I see ā€œsensor.los_vegas_golden_knightsā€ you may have named it that way but in reality it is ā€œLas Vegasā€ not ā€œLos Vegasā€. Although you can name it whatever you like.

Also another note ā€¦ if you have the home/away setting in place and they are only an away team, they may not appear. It depends on where you apply the home/away filter. I added my favorites at a higher level because I wanted to show all the sports. I canā€™t do home/away for example for the NCAAM basketball because I do not believe they have home/away status as they play at a neutral site.

In looking at yours, you are applying the home/away filter with the if inside. I would bet that the missing games are because they were away games? Please check. That would make sense I think, if a favorite is playing a non-favorite and the game is an away game for the favorite, they would likely not appear.

I only tested:

Fav (home) v. Non-Fav (away)
Fav (home) v Fav (away)

I did not test:

Non-Fav (home) v. Fav (away)

It is probably this one that is missing.

This would be a semi-complicated template to think through.

  1. Fav team @ home ā†’ show it
  2. Fav team @ away, check if the opponent is also a Fav team
    ā†’ If yes, donā€™t show it because it will be shown in because of rule #1 above
    ā†’ If no, show it

It is possible that setting auto-entities to provide only unique entries might do it

No the sensor is group.team_favorities:

The Name from the Golden Knights are in your senaor.yaml on github:

- platform: teamtracker
  league_id: NHL
  team_id: VGK
  name: Los Vegas Golden Knights

Yes you are right, the missing are away teams. I donĀ“t see that because Iā€™m only now noticing that the game pairings are displayed the other way around, the away team is always at the front.


All displaye are Home Teams:

And Game Sharks and Oilers are both favorietes.

But Why my markdown card are not displayed?

I have no idea about the markdown card, likely bad indenting. If you implement like this (removing home/away if and adding just unique: true) this may work:

            - attributes:
                label: FAVORITES
                icon: mdi:heart
              card:
                type: custom:stack-in-card
                mode: horizontal
                columns: 4
                cards:
                  - type: custom:auto-entities
                    unique: true
                    show_empty: false
                    card:
                      type: custom:layout-card
                      layout_type: masonry
                    card_param: cards
                    filter:
                      template: >
                        {%- for team in
                        state_attr('group.team_favorities','entity_id') -%}
                            {{{"type": "custom:teamtracker-card",
                              "entity": team,
                               "home_side": "right"}}},
                        {%- endfor -%}
                      exclude:
                        - entity_id: '*team_tracker*'
                      unique: true
                    sort:
                      method: attribute
                      attribute: date

Of course, change to your group sensor name. I am not clear this will work though as I do not have many favorites in one sport, I have one per sport. So mine never play eachother (unless the Red Wings decide to become a baseball team!)

UPDATE: I added the Kraken and Senators to my favorites and now I see this:

So it looks to me as the unique works. The real question now is if I add the Penguins or the Stars do I get two entries. If so, then this will still not work.

UPDATE: Yes this will not work either, the only way is like I wrote above in a complicated template:

With the modified code, the missing games are now displayed. But as you said, if two favorites play against each other now, they will be shown twice.
Iā€™m not sure what you mean by the only way is like I wrote above in a complicated template

And why are the home team right. I think the home team must be left. In the favorites I can change it. But not in Pregame, Live and Postgame.

Home teams are normally on the right.
Look at the data ā€¦ it is like ā€œSEA @ DALā€ which is home team right.
You can change it and make it home team left, it is in the template.

The reason why it is a hugely complicated template is really evident if you look at it.
You are only providing a list of team sensors.
Nothing knows who is playing who.

You have to take all your favorites, look up who they are playing and if they are playing another favorite, donā€™t display (one of) the games. That data is not readily available and has be be analyzed from the sensor and then it does not have the other sensorā€™s name, if has like I said ā€œSEA @ DALā€.

So you need to do something to look up ā€œDALā€ and find what ā€œDALā€ is, then get the fact that itā€™s name is ā€œsensor.dallas_starsā€ ā€¦ then you need to check if ā€œsensor.dallas_starsā€ is in your favorites then if yes, display only one game.

This is very difficult at best and likely will never work without adding more things.

Like what if you have a favorite whose name is ā€œDALā€ ā€¦ but that is for NFL and not NHL. You would need to be sure you only look into things that are in the same sport.

I am not planning to invest that must time for now for this. At the moment, you can get every game (which includes duplicates) or only home games (which excludes a favorite Away playing a non-favorite Home). That is all

Oh sorry, here in Germany are the home team left. But now I know it, it is different in USA.

Of course I can understand that they wonā€™t invest so much time in it. Then Iā€™ll leave it at me with the doublet.

At the very top of the TAML, you would have this:

  game_stats:
    card:
      type: custom:auto-entities
      unique: true
      show_empty: false
      card:
        type: custom:layout-card
        layout_type: masonry
      card_param: cards
      filter:
        template: |
          {%- for team in integration_entities("teamtracker") -%}
            {%- if state_attr(team, "league") == "[[sport]]" -%}
            {%- if states(team) == "[[status]]" -%}
            {%- if state_attr(team, "team_homeaway") == "home" -%}
              {{{"type": "custom:teamtracker-card",
                "entity": team,
                 "home_side": "right"}}},
            {%- endif -%}
            {%- endif -%}
            {%- endif -%}
          {%- endfor -%}
        exclude:
          - entity_id: '*team_tracker*'
      sort:
        method: attribute
        attribute: date

Just change home_side to ā€œleftā€

Yes I found it for the favorites. But not for Pregame, Live and Postgame.