Closed Droppisalt closed 11 months ago
Hi there, can you describe the issue? I also don't see how you are rendering sensors with entity ID sensor.montreal_canadiens
and sensor.toronto_maple_leafs
with the config you posted. You should be getting sensor.template_away_team
and sensor.template_home_team
.
Forgot to include my code to show it on my dashboard:
cards:
- type: entities
show_header_toggle: false
entities:
- entity: sensor.nhl_sensor
- entity: sensor.template_away_team
- entity: sensor.template_home_team
Result:
I also have no idea how I got those two sensors. I'll try to delete nhl_api and start from scratch
Started from scratch and still no luck. Now I've got no sensors at all
What version of Home Assistant are you running?
2023.8.1
Try restarting HA and then check the States table in the dev menu and let me know what you see.
Just did, and I see sensor.nhl_sensor
, sensor.montreal_canadiens
and sensor.toronto_maple_leafs
If I remove this from my configuration.yaml
file, I can remove sensor.montreal_canadiens
and sensor.toronto_maple_leafs
, but as as I as add it back and refresh my templates, they pop back in
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", "") }}'
Are you certain you only put:
- platform: nhl_api
team_id: 8
in your sensor file? I don't see any reason why those template sensors are rendering with those names. The unique id
field should dictate the entity ID. Maybe try the HA forums.
Closing
I experienced this issue just yesterday, when setting up my version of the frontend. Through a little digging, it appears the Unique_ID does not control the entity name when a Name is also available. This explains this Issue's behavior.
The Unique_ID will be recorded... somewhere... and persist, so the two entities created are proxies for home and away (if the home team is TOR when setting it up, all future home teams will be sensor.toronto_maple_leafs).
My simple fix was to rename the home and away entities to the names you intended them to have, such that the rest of the logic in the frontend works. This seems to solve the issue (though is inelegant).
Is this related to the template sensors or the nhl_api
sensor?
This is related to the template sensors
Seems to be similar to this one: https://github.com/JayBlackedOut/hass-nhlapi/issues/50
I'm using UI Lovelace Minimalist if that's useful to know.
Here is my code from my
configuration.yaml
:and here's my
sensor.yaml
: