JayBlackedOut / hass-nhlapi

NHL Stats API Integration Into Home Assistant
67 stars 18 forks source link

Track Multiple teams #2

Closed adamhunt08 closed 5 years ago

adamhunt08 commented 5 years ago

Describe the bug Tracking two teams. Currently using the conference finals to test. Have created two sensors but both cards with the differing team sensors are showing the same home/away results. I am aware that the team_ids are incorrect for my descriptions.

To Reproduce create two sensors with two different teams. change device id in configuration.yaml to correct device id. create two entity cards to show two different teams

Expected behavior see correct information about both teams

Screenshots image

image

image

Home Assistant Information

Configuration `####NHL Sensor####

Log Add the relevent Home Assistant log entries, if any.

Additional context Add any other context about the problem here.

JayBlackedOut commented 5 years ago

Hi @adamhunt08 , I've been away for the past month. I'll try to take a look at this today. Unfortunately, with the playoffs now over, I don't think I'll be able to replicate this. I imagine it's an issue with the sensor script only allowing the creation of one sensor in Home Assistant. I'm going to peer over the code of sensors that allow multiple instances and try to adapt the script. Thanks for reporting this!

dennyreiter commented 5 years ago

I think you'll need to create separate sensors for each team. This is what I have:

sensor:
  - platform: nhl_api
    team_id: 5
    name: 'NHL Pittsburgh Penguins'

  - platform: nhl_api
    team_id: 6
    name: 'NHL Boston Bruins'

  - platform: nhl_api
    team_id: 21
    name: 'NHL Colorado Avalanche'

  - platform: nhl_api
    team_id: 54
    name: 'NHL Vegas Knights'

  - platform: template
    sensors:
      nhl_pittsburgh_penguins_away_team:
        friendly_name_template: '{{ states.sensor.nhl_pittsburgh_penguins.attributes.away_name }}'
        value_template: '{{ states.sensor.nhl_pittsburgh_penguins.attributes.away_score }}'
        entity_picture_template: '{{ states.sensor.nhl_pittsburgh_penguins.attributes.away_logo }}'
      nhl_pittsburgh_penguins_home_team:
        friendly_name_template: '{{ states.sensor.nhl_pittsburgh_penguins.attributes.home_name }}'
        value_template: '{{ states.sensor.nhl_pittsburgh_penguins.attributes.home_score }}'
        entity_picture_template: '{{ states.sensor.nhl_pittsburgh_penguins.attributes.home_logo }}'

      nhl_boston_bruins_away_team:
        friendly_name_template: '{{ states.sensor.nhl_boston_bruins.attributes.away_name }}'
        value_template: '{{ states.sensor.nhl_boston_bruins.attributes.away_score }}'
        entity_picture_template: '{{ states.sensor.nhl_boston_bruins.attributes.away_logo }}'
      nhl_boston_bruins_home_team:
        friendly_name_template: '{{ states.sensor.nhl_boston_bruins.attributes.home_name }}'
        value_template: '{{ states.sensor.nhl_boston_bruins.attributes.home_score }}'
        entity_picture_template: '{{ states.sensor.nhl_boston_bruins.attributes.home_logo }}'

      nhl_colorado_avalanche_away_team:
        friendly_name_template: '{{ states.sensor.nhl_colorado_avalanche.attributes.away_name }}'
        value_template: '{{ states.sensor.nhl_colorado_avalanche.attributes.away_score }}'
        entity_picture_template: '{{ states.sensor.nhl_colorado_avalanche.attributes.away_logo }}'
      nhl_colorado_avalanche_home_team:
        friendly_name_template: '{{ states.sensor.nhl_colorado_avalanche.attributes.home_name }}'
        value_template: '{{ states.sensor.nhl_colorado_avalanche.attributes.home_score }}'
        entity_picture_template: '{{ states.sensor.nhl_colorado_avalanche.attributes.home_logo }}'

      nhl_vegas_knights_away_team:
        friendly_name_template: '{{ states.sensor.nhl_vegas_knights.attributes.away_name }}'
        value_template: '{{ states.sensor.nhl_vegas_knights.attributes.away_score }}'
        entity_picture_template: '{{ states.sensor.nhl_vegas_knights.attributes.away_logo }}'
      nhl_vegas_knights_home_team:
        friendly_name_template: '{{ states.sensor.nhl_vegas_knights.attributes.home_name }}'
        value_template: '{{ states.sensor.nhl_vegas_knights.attributes.home_score }}'
        entity_picture_template: '{{ states.sensor.nhl_vegas_knights.attributes.home_logo }}'
JayBlackedOut commented 5 years ago

@dennyreiter That seems to be what @adamhunt08 has as well. Can you confirm that you didn't run into the same issue as described above with your set up?

dennyreiter commented 5 years ago

Maybe I'm reading it wrong, but doesn't he just have sensors named 'away_team' and 'home_team' defined twice? Mine have unique sensor names. I'd like to tell you definitively that they worked, but I have slept a couple days since the last game :) I do have a Lovelace view that shows a card for each team and it only showed the teams on the card for the team playing.

JayBlackedOut commented 5 years ago

You're absolutely right! He gave the same name to the "bolts" and "pens" away_team and home_team template sensors. Issue closed. Thanks for the help!

adamhunt08 commented 5 years ago

User error sounds about right for me. Thank you both for your help.

nutsofamily commented 3 years ago

Hi Denny what does your lovelace card looklike? Thanks

dennyreiter commented 3 years ago

I just use an entity card for each team currently. It's on my list to jazz it up.

card:
  type: entities
  show_header_toggle: false
  entities:
    - entity: sensor.nhl_vegas_golden_knights
    - entity: sensor.nhl_vegas_golden_knights_away_team
    - entity: sensor.nhl_vegas_golden_knights_home_team
nutsofamily commented 3 years ago

Thanks!

nutsofamily commented 3 years ago

Hi I love this. How do I write into my config if i want to list current standings. Be nice to have it update after each game. Noob please.

JayBlackedOut commented 3 years ago

Hi I love this. How do I write into my config if i want to list current standings. Be nice to have it update after each game. Noob please.

Hi there. Glad you like it. That's not a feature of this component nor within the scope of what it is to accomplish. It is only meant to track a team from game to game, not in the standings.

nutsofamily commented 3 years ago

Ok thanks. It would be cool to have a card populate standings.

dennyreiter commented 3 years ago

If you use Node Red, I have a kludgy system worked out for it.