vasqued2 / ha-teamtracker-card

A Home Assistant frontend custom card that will display real-time updates for teams tracked with the ha-teamtracker integration. Has custom in-game layouts for football, baseball, basketball, hockey, soccer, golf, tennis, racing, and mma.
GNU General Public License v3.0
71 stars 16 forks source link

Home team placement for soccer games #14

Closed RobertD502 closed 1 year ago

RobertD502 commented 1 year ago

Discussed in https://github.com/vasqued2/ha-teamtracker-card/discussions/11

Originally posted by **RobertD502** October 25, 2022 First of all, thanks for all the great work! I was wondering what your thoughts were about reversing the side which teams are shown on the card for soccer games. As it stands, the away team is placed on the left-hand side which is opposite of how it should be - I realize leagues such as the NFL place the away team on the left and the home team on the right. As you can see below, Real Madrid is the away team and should be placed on the right-hand side: ![image](https://user-images.githubusercontent.com/52541649/197879060-54ec11b1-579f-4a82-8ac9-b8e82a1ca09f.png) This is the ESPN page showing the correct placement: ![image](https://user-images.githubusercontent.com/52541649/197879130-8364debd-0515-4762-94cb-25ca700b037a.png) Perhaps placement can be set to follow this standard based on the sport type returned by ESPN's API?
vasqued2 commented 1 year ago

Thanks for pointing this out.

Right now, the card puts whatever team you set up the sensor for first, and whoever they are playing second. So in your case, Real Madrid is always going to appear on the left whether they are home or away.

Based on what I am reading, team order based on Home/Away varies based on country, sport, and maybe even league. And even so, different sources may still have different style guidelines. So I'm not going to do anything to automatically order the teams based on their Home/Away status.

One possibility might be to use a configuration option to let you specify if you want the Home team to always be placed on the left or the right for that particular card. I'll leave this open while I look into other possibilities and see what it would take to add the config option.

RobertD502 commented 1 year ago

Apologies for creating the issue - I figured starting a discussion thread was more appropriate, but I wasn't sure if you'd seen it.

Just to clarify, I wasn't suggesting moving the side for all sports, just soccer. When it comes to soccer, the Home team is always on the left side with the visiting team on the right. I'll admit I haven't sniffed out the ESPN API yet, but if a sports category is returned in the response, placement can be carried out if the response lists soccer as the category.

Edit: Looks like the sport key could be used to evaluate the condition just for soccer along with the team_homeaway key: image

vasqued2 commented 1 year ago

No worries. You're right, I likely would have missed the discussion thread. Doesn't hurt anything being here.

Dated, but this is what I was referring to about different sources treating it differently. I frankly haven't paid attention recently to know if they've changed or if there are still differences from different sources, and if it's just MLS because it's American soccer or all soccer on those channels.

In the end, I want it to (1) be config driven so I don't swap things around for everyone on upgrade, but rather let them opt in and (2) handle the next situation when someone outside of the US, Canada, and Japan want all their sports swapped, not just soccer.

I'm working on adding athlete-based sports like golf and tennis now, and that's forcing me to replace a lot of the sensor values w/ variables so it's a natural first step to make everything variable-based, which I will need to do in order to enable this.

RobertD502 commented 1 year ago

Yeah I completely recognize how much of a pain adding features to a custom component can be. The source you have linked I wouldn't follow, especially since I can tell you from personal experience that soccer has listed the Home team on the left for decades and the component is specific to ESPN (Home team for soccer is always listed on the left at ESPN). Regardless, I understand if this isn't in your scope/plans, but I appreciate the discussion.

vasqued2 commented 1 year ago

The Team-Order-Flexibility branch has my first cut of the changes to allow the user to specify a side for the home team on the card configuration.

Because of the amount of hard-coding in the original card, this actually required a lot of restructuring under the covers so I'm going to watch the changes across several sports for a while before officially pushing it out.

If you want to try it early, you can manually install the ha-teamtracker-card.js file. If you do, let me know if you have any problems with it.

Use home_side: left or home_side: right in the card configuration to force the home team to one side or the other.

Here's a sample:

  - type: custom:teamtracker-card
    entity: sensor.test11
    outline: true
    outline_color: lightgray
    show_league: true
    home_side: right
RobertD502 commented 1 year ago

Thanks for doing that! The leagues are on break at the moment with the World Cup about to start, but I'll try it out with the World Cup!

RobertD502 commented 1 year ago
image

Works Great!

vasqued2 commented 1 year ago

Good to hear. Different info will show during and after the game that should swap sides too based on the sport (i.e. scores, possession indicators, timeouts). I believe I've caught everything but be on the lookout for anything that doesn't swap sides like it should during and after games too. Thanks!

vasqued2 commented 1 year ago

Was able to test multiple sports today and it seems to be working across all of them. Released v0.5.2 which supports the home_side config option. Thanks for the suggestion. Let me know if you notice anything wonky.