Closed DravenSA closed 1 year ago
You should be able to do what you want using a combination of a template to create a binary sensor and a conditional card. I already do this based on the game state, but you could just as easily do it based on the opponent name.
{{ states.sensor.team_tracker.attributes.opponent_name != "Grizzlies"}}
to set the value, but you could get more sophisticated to also check the state, include a time delay, or check some other indicator that you watched the game. The beauty of using a template is you can customize it to whatever you want.Oh wow, templates and binary sensors are very much out of my wheelhouse, but i guess it is something for me to look into, might be the end of the season before i get it right LOL. Thanks I will have a go, Can you recommend a starting place where to start learning about them Templates?
I will see if I can post some examples tonight. Should be enough to get you started
Here's the yaml to create a template that creates a binary sensor that will be Off if the opponent name is Grizzlies and On if it's something else.
- binary_sensor:
- name: "show_scoreboard_except_grizzlies"
state: >
{% if state_attr("sensor.YOUR_SENSOR_NAME", "opponent_name") == "Grizzlies" %}
Off
{% else %}
On
{% endif %}
Put it in your template.yaml
file or in the template:
section of your configuration.yaml
file. Reboot and you should see a binary sensor called binary_sensor.show_scoreboard_except_grizzlies
.
Then create a conditional card that displays your card only if the value is On. You can either use the GUI or the Manual code editor. Here's the YAML if you use the Manual code editor.
type: conditional
conditions:
- entity: binary_sensor.show_scoreboard_except_grizzlies
state: 'on'
card:
type: custom:teamtracker-card
entity: sensor.YOUR_SENSOR_NAME
outline: true
outline_color: lightgray
show_league: true
Once you get that working, you can make the if statement in the binary sensor more complex to look at other things like the sensor is state is PRE, IN, or POST, time since the game start, etc.
Here's a link to more information on Templates
OMG this is fantastic, I managed to fumble around with a condition card, and i got that to work but obviously only if the Grizz were the main team, then I started reading the templates page last night to try and get something to work if the Grizz were the opponents on another "watched" team, slowly i was beginning to understand a little, but nothing that would have made leaps and bounds in the direction i want to go in.
So i really really appreciate you taking the time out and sending this code, I will try and implement it this evening.
I think i get the concept of the binary sensor to say if oppents is Grizz AND state is PRE, then show the card, but if opponent is Grizz and state is IN or POST, dont show the card , that way i will know when the next match will be played without going to the NBA site,
Then I am hoping to use the IN and POST to display the state of the match, so incase i miss the PRE section I will at least have a visual that the Match was played.
Big hopes for me, but a fun project and a learning one none the less.
So truly a big thank you for pointing me in the right direction and giving me a starting bloke i can hopefully grow on.
Glad I could help. Good luck.
BTW, the Template tab under Developer Tools is a great place to test out your template code if you aren’t already using it.
Closing as resolved.
I love that integration, as it is impossible to watch each match of the teams I want to follow.
Would it be possible to to NOT see a score of your favourite time, EG i watch NBA, and the only matches i watch are the Grizzlies, and because i live in a different time zone, i have to watch it as a replay.
so although i want to keep a track of the scores of other teams like the Mavericks, if they play the Grizzlies, then that score would show up.
So maybe if i could add the Grizzlies, but have an option to HIDE SCORE, then I can still keep a track of who and when they are playing, but wont be spoiled with th final result until i have watched the match.
Obviously the Card would need to have something on it to UNHIDE SCORE, after the match has been watched.
Thanks for all the work put in.
LOL and now i have written all this i realise you are one of the same person