+1 to show the league logo as the entity picture!
Has anyone been able to get it working with multiple teams since the update? I have one team working fine, but before i could track multiple teams. My config is below. Thanks in advance
#NHL Sensor#
sensor:
- platform: nhl_api
name: nhl_sensor_mtl
team_id: 8
- platform: nhl_api
name: nhl_sensor_tor
team_id: 10
template:
- sensor:
- unique_id: mtl_away_team
name: >
{{state_attr('sensor.nhl_sensor_mtl','away_name')}}
state: >
{{state_attr('sensor.nhl_sensor_mtl','away_score')}}
picture: >
{{state_attr('sensor.nhl_sensor_mtl','away_logo')}}
- sensor:
- unique_id: mtl_home_team
name: >
{{state_attr('sensor.nhl_sensor_mtl','home_name')}}
state: >
{{state_attr('sensor.nhl_sensor_mtl','home_score')}}
picture: >
{{state_attr('sensor.nhl_sensor_mtl','home_logo')}}
- sensor:
- unique_id: tor_away_team
name: >
{{state_attr('sensor.nhl_sensor_tor','away_name')}}
state: >
{{state_attr('sensor.nhl_sensor_tor','away_score')}}
picture: >
{{state_attr('sensor.nhl_sensor_tor','away_logo')}}
- sensor:
- unique_id: tor_home_team
name: >
{{state_attr('sensor.nhl_sensor_tor','home_name')}}
state: >
{{state_attr('sensor.nhl_sensor_tor','home_score')}}
picture: >
{{state_attr('sensor.nhl_sensor_tor','home_logo')}}
Whatās not working? Do the 2 sensors render?
Try this:
template:
- sensor:
- unique_id: away_team
name: '{{ states.sensor.nhl_sensor.attributes.get("away_name", "") }}'
state: '{{ states.sensor.nhl_sensor.attributes.get("away_score", "") }}'
picture: '{{ states.sensor.nhl_sensor.attributes.get("away_logo", "") }}'
- sensor:
- unique_id: home_team
name: '{{ states.sensor.nhl_sensor.attributes.get("home_name", "") }}'
state: '{{ states.sensor.nhl_sensor.attributes.get("home_score", "") }}'
picture: '{{ states.sensor.nhl_sensor.attributes.get("home_logo", "") }}'
Sorry shouldāve been more clear. The trackers for montreal work great but the toronto ones do not show up as entities. Ill give your solution a try
@michaeldooley97 I just set mine up for two teams today with the Kings and Ducks using your code and it seems to be working fine for both teams. For whatever reason, my instance isnāt liking @jayblackedoutās template code (99% sure itās a user error). But both teams and the respective visitors for the scheduled games this week are showing up fine.
Good to know, thanks for testing! I might just start over and set it up again
@michaeldooley97 absolutely! Itās worked great for both games (Ducks and Kings) the last two nights for how you have it formatted. The challenge, like what youāve already raised, is that when it clears from the previous game it sets the sensors to āunknownā rather than ā0ā or a ā-ā. So, those I set the state manually for today because Iām in and out of it. Iām not too experienced with templates, so Iām using this to play around and learn it as well.
I also added āPeriodā and āTime Remainingā (which is for the period, not the whole game) to the card/sensor line up:
template:
- sensor:
- unique_id: 'ducks_cur_period'
state: >
{{state_attr('sensor.nhl_ducks', 'current_period')}}
- unique_id: 'ducks_time_remain'
state: >
{{state_attr('sensor.nhl_ducks','time_remaining')}}
Notes for reference on the card:
o Period icon is: mdi:hockey-puck and the timer is mdi:timer-outline to save people time in looking for them. I set those on the card itself since those donāt need to change.
o The time and period will automatically set (what you see on my Ducks card) when it recognized that the game is today and then update live when the game is going so that if I check it, itāll reflect whatās going on.
o For my Kings card, I entered the ā-ā for time/period and the ā0ā for score manually in Developer Tools just to clean it up as I was bouncing in and out of it earlier, otherwise it reads āunknownā for all four. Iāll play with it later to see how to change the default to the ā-ā (time/period) and ā0ā (team scores) when the game isnāt going.
Hope that helps!
Added: just for clarity and for whoever sees this later, the Ducks are playing the Wild on 10/15/21 and then the Kings are playing them on 10/16/21. Just to avoid confusion, I didnāt do anything special, thatās @jayblackedoutās integration that pulled that data automatically, so that side is definitely functioning right.
To get rid of the āunknownā state in your template sensors, change:
state: >
{{state_attr('sensor.nhl_ducks', 'current_period')}}
to
state: >
{{ states.sensor.nhl_ducks.attributes.get("current_period", "-") }}
Replicate for your other template sensors using the correct attribute and substitute the dash for whatever you want to use as a default state instead of unknown.
@jayblackedout, thanks. I tried that code for setting the defaults when I first set it up and again today with your example. It returns the sensor output on the card as āunavailableā.
Not sure why that isā¦ Well at least itās somewhat working the way you want.
I am encountering an issue where the sensor stops updating its attributes. It will say itās end of the first, but itās actually already 3/4 into the second period. The home assistant log has warnings about the sensor taking over 10 seconds, so Iām not sure if itās just become hung and stopped updating or if the sensor update would actually timeout and be retried successfully without a log entry. Restarting home assistant will cause the sensor to be updated correctly.
2021-10-18 20:36:50 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.nhl_mtl is taking over 10 seconds
I just set this up the other day. On my setup the logos stopped showing. My team is playing tonight so Iāll check back and see if everything else is still in order.
Yea I donāt think itās working correctly. Iāll have to do some digging but the main card just says a game is in progress but no score or time and no logo. Iām not sure what is supposed to be showing and will look above to check other screenshots when Iām off mobile.
Check out the GitHub repository linked in the original post.
What am I checking out? No open issues and the last update was 14 days ago. Which means having installed it only a couple days ago I must be on current version.
You mentioned you were looking for screenshots. I have a section on the frontend with template examples.
Ah cool Iāll look thx
Would be cool to get some other events like penalties and be able to track if your team is on the PK or PP.
Agreed. I would also love this and some more enhancements.
Iād love for ALL sports to have something.
Iāll see what the NHLās API offers and put it on the backlog. Iām limiting the scope of my project to the NHL though. Iām only one person and it is already difficult to find time to update this component.