Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type: custom:button-card
- entity: '[[[ return variables.var_entity ]]]'
- tap_action:
- action: url
- url_path: |
- [[[
- return entity.attributes.event_url;
- ]]]
- show_icon: false
- show_name: false
- show_state: false
- styles:
- grid:
- - grid-template-areas: |
- "summary summary summary"
- "venue venue venue"
- "home time away"
- "status status status"
- "card card card"
- - grid-template-columns: 1fr min-content 1fr
- - grid-template-rows: min-content min-content 1fr min-content
- - align-items: center
- - justify-content: space-between
- card:
- - box-sizing: border-box
- - width: 302.5px
- - height: 375px
- - background-color: transparent
- - background-image: |
- [[[
- let teamColor = entity.attributes.team_colors[0];
- let opponentColor = entity.attributes.opponent_colors[0];
- return `radial-gradient(circle at 1% center, ${teamColor} 0%, ${teamColor} 10%, rgba(0,0,0,0.7) 70%),
- radial-gradient(circle at 99% center, ${opponentColor} 50%, ${opponentColor} 10%, rgba(0,0,0,0.7) 100%)`;
- ]]]
- - background-size: cover
- - background-position: center
- - background-repeat: no-repeat
- - border: solid 2px transparent
- - border-radius: 35px
- - padding: 15px 0px 0px 0px
- - margin: 0px 0px 0px 0px
- custom_fields:
- summary:
- card:
- type: custom:layout-card
- layout_type: custom:grid-layout
- layout:
- grid-template-areas: '"summary"'
- grid-template-columns: 1fr
- grid-template-rows: auto
- cards:
- - view_layout:
- grid-area: summary
- type: custom:button-card
- tap_action:
- action: url
- url_path: |
- [[[
- return entity.attributes.event_url;
- ]]]
- show_label: true
- show_name: true
- show_icon: false
- show_state: false
- name: |
- [[[
- return `${entity.attributes.team_name} v ${entity.attributes.opponent_name}`;
- ]]]
- label: |
- [[[
- let utcDate = new Date(entity.attributes.date);
- // Convert UTC date to Sydney time (AEST/AEDT)
- let aestDate = new Intl.DateTimeFormat("en-AU", {
- weekday: "long",
- day: "numeric",
- month: "long",
- year: "numeric",
- hour: "numeric",
- minute: "numeric",
- hour12: true,
- timeZone: "Australia/Sydney"
- }).format(utcDate);
- return aestDate.replace("AM", "AM AEST").replace("PM", "PM AEST");
- ]]]
- styles:
- card:
- - background: transparent
- padding: 0 0 0 0px
- margin: 0px
- border-radius: 0px
- - height: 40px
- name:
- - font-size: .9em
- font-weight: 700
- label:
- - font-size: .9em
- padding-top: 3px
- color: rgba(255,255,255,0.4)
- venue:
- card:
- type: custom:button-card
- show_label: true
- show_name: false
- show_icon: false
- show_state: false
- label: |
- [[[
- return entity.attributes.venue;
- ]]]
- styles:
- card:
- - background: transparent
- - padding: 0px
- - text-align: center
- - height: 30px
- label:
- - font-size: .9em
- - font-weight: 400
- - color: rgba(255,255,255,0.4)
- home_win_gap:
- card:
- type: custom:button-card
- show_label: true
- show_name: false
- show_icon: false
- show_state: false
- label: |
- [[[
- let teamScore = entity.attributes.team_score || 0;
- let oppScore = entity.attributes.opponent_score || 0;
- let diff = teamScore - oppScore;
- if (entity.state === "PRE") {
- return `${entity.attributes.team_record}`; // Just return the number
- }
- return (diff > 0) ? `+${diff}` : "";
- ]]]
- styles:
- card:
- - background: transparent
- - text-align: end
- - align-content: end
- - justify-content: end
- - padding: 0px 13px 10px 10px
- - margin: 0px 0px 0px 0px
- label:
- - font-size: |
- [[[
- return (entity.state === "PRE")
- ? ".7em"
- : ".9em";
- ]]]
- - font-weight: |
- [[[
- return (entity.state === "PRE")
- ? "400"
- : "600";
- ]]]
- - color: |
- [[[
- return (entity.state === "PRE")
- ? "grey"
- : "var(--label-badge-blue)";
- ]]]
- - text-align: end
- - align-content: end
- - justify-content: end
- away_win_gap:
- card:
- type: custom:button-card
- show_label: true
- show_name: false
- show_icon: false
- show_state: false
- label: |
- [[[
- let teamScore = entity.attributes.team_score || 0;
- let oppScore = entity.attributes.opponent_score || 0;
- let diff = oppScore - teamScore;
- if (entity.state === "PRE") {
- return `${entity.attributes.opponent_record}`; // Just return the number
- }
- return (["IN", "POST"].includes(entity.state) && diff > 0)
- ? `+${diff}`
- : "";
- ]]]
- styles:
- card:
- - background: transparent
- - text-align: start
- - padding: 0px 13px 10px 10px
- label:
- - font-size: |
- [[[
- return (entity.state === "PRE")
- ? ".7em"
- : ".9em";
- ]]]
- - font-weight: |
- [[[
- return (entity.state === "PRE")
- ? "400"
- : "600";
- ]]]
- - color: |
- [[[
- return (entity.state === "PRE")
- ? "grey"
- : "var(--label-badge-blue)";
- ]]]
- - text-align: start
- home:
- card:
- type: custom:button-card
- show_label: true
- show_name: true
- show_icon: false
- show_state: false
- tap_action:
- action: url
- url_path: |
- [[[
- return entity.attributes.event_url;
- ]]]
- name: |
- [[[
- let team_abbr = entity.attributes.team_abbr || "N/A";
- let logo_url = `/local/images/afl/${team_abbr.toLowerCase()}.svg`;
- // Manual override for missing images
- let known_logos = ["adel", "bl", "carl", "coll", "ess", "fre", "geel", "gcfc", "gws", "haw", "melb", "nmfc", "port", "rich", "stk", "syd", "wce", "wb"];
- if (!known_logos.includes(team_abbr.toLowerCase())) {
- logo_url = `/local/images/afl/gcfc.svg`; // Fallback image
- }
- return `<img src="${logo_url}" style="width:65px;height:65px;">`;
- ]]]
- label: |
- [[[
- return entity.state === "PRE" ? entity.attributes.team_abbr : entity.attributes.team_score;
- ]]]
- styles:
- card:
- - background: transparent
- - padding: 0px 0px 0px 0px
- - margin: '-30px 0px 10px 0px'
- - width: 110px
- - height: 170px
- - border-radius: 0px
- - filter: |
- [[[
- let homeScore = parseInt(entity.attributes.team_score, 10) || 0;
- let awayScore = parseInt(entity.attributes.opponent_score, 10) || 0;
- let isPostGame = entity.state === "POST";
- return isPostGame && homeScore < awayScore ? "opacity(1)" : "none";
- ]]]
- - align-content: start
- align-self: start
- justify-content: start
- justify-self: start
- name:
- - align-content: end
- align-self: end
- justify-content: center
- justify-self: center
- margin: 10px 0px -30px 0px
- filter: >-
- drop-shadow(1px 0 0 rgba(255,255,255,0.8)) drop-shadow(-1px 0
- 0 rgba(255,255,255,0.8)) drop-shadow(0 1px 0
- rgba(255,255,255,0.8)) drop-shadow(0 -1px 0
- rgba(255,255,255,0.8))
- label:
- - font-size: |
- [[[
- return entity.state === "PRE" ? "1em" : "2em";
- ]]]
- - font-weight: 700
- - padding-top: 50px
- - color: |
- [[[
- if (entity.state === "PRE") {
- return "white";
- }
- let homeScore = parseInt(entity.attributes.team_score, 10);
- let awayScore = parseInt(entity.attributes.opponent_score, 10);
- if (homeScore === awayScore) {
- return "white"; // Both scores white when tied
- }
- return (homeScore < awayScore)
- ? "rgba(255, 255, 255, 0.5)" // Dimmed if HOME wins
- : "white"; // Fully visible if HOME loses
- ]]]
- - align-content: end
- align-self: end
- justify-content: center
- justify-self: center
- font-family: Chromatic Gothic Semibold, sans-serif
- time:
- card:
- type: custom:button-card
- show_label: true
- show_name: false
- show_icon: false
- show_state: false
- tap_action:
- action: url
- url_path: |
- [[[
- return entity.attributes.event_url;
- ]]]
- label: |
- [[[
- if (entity.state && entity.state.toUpperCase() === "PRE") {
- return "VS"; // Show 'VS' instead of the time
- }
- let clock = entity.attributes.clock || "";
- // Handle custom quarter names
- let clockAdjustments = {
- "End of 3rd": "3QT",
- "Halftime": "HT",
- "End of 2nd": "QT",
- "Fulltime": "FT"
- };
- if (clockAdjustments[clock]) {
- return clockAdjustments[clock];
- }
- // Adjust format if clock includes a hyphen separator
- if (clock.includes(" - ")) {
- let [quarter, timeLeft] = clock.split(" - ");
- return `${timeLeft}<br>${quarter}`;
- }
- return clock;
- ]]]
- styles:
- card:
- - background: |
- [[[
- let clock = entity.attributes.clock || "";
- // Define states that should have a black background
- let blackBackgroundStates = ["QT", "HT", "3QT", "FT"];
- // Handle custom quarter names
- let clockAdjustments = {
- "End of 3rd": "3QT",
- "Halftime": "HT",
- "End of 2nd": "QT",
- "Fulltime": "FT"
- };
- if (clockAdjustments[clock]) {
- clock = clockAdjustments[clock];
- }
- if (blackBackgroundStates.includes(clock)) {
- return "rgba(75,75,80,0.2)";
- } else if (entity.state === "IN") {
- return "var(--label-badge-green)";
- } else if (entity.state === "POST") {
- return "rgba(75,75,80,0.2)";
- } else if (entity.state === "PRE") {
- return "transparent";
- }
- return "transparent";
- ]]]
- - padding: |
- [[[
- if (entity.state === "PRE") {
- return "0px 0px 0px 0px"; // No background color before the game starts
- } else if (entity.state === "IN") {
- return "8px 0px 8px 0px"; // Green when game is in progress
- } else if (entity.state === "POST") {
- return "8px 0px 8px 0px"; // Red after the game ends
- }
- return "transparent"; // Default to no background
- ]]]
- - margin: |
- [[[
- if (entity.state === "PRE") {
- return "5px 0px 0px 0px"; // No background color before the game starts
- } else if (entity.state === "IN") {
- return "5px 10px 0px 10px"; // Green when game is in progress
- } else if (entity.state === "POST") {
- return "5px 10px 0px 10px"; // Red after the game ends
- }
- return "transparent"; // Default to no background
- ]]]
- - width: |
- [[[
- if (entity.state === "PRE") {
- return "60px"; // No background color before the game starts
- } else if (entity.state === "IN") {
- return "60px"; // Green when game is in progress
- } else if (entity.state === "POST") {
- return "100px"; // Red after the game ends
- }
- return "transparent"; // Default to no background
- ]]]
- - border-radius: 5px
- - justify-content: center
- - align-content: end
- - align-self: end
- - justify-self: center
- - justify-content: center
- label:
- - font-size: |
- [[[
- if (entity.state === "PRE") {
- return ".8em"; // No background color before the game starts
- } else if (entity.state === "IN") {
- return "0.9em"; // Green when game is in progress
- } else if (entity.state === "POST") {
- return "0.8em"; // Red after the game ends
- }
- return "transparent"; // Default to no background
- ]]]
- - font-weight: 600
- away:
- card:
- type: custom:button-card
- show_label: true
- show_name: true
- show_icon: false
- show_state: false
- tap_action:
- action: url
- url_path: |
- [[[
- return entity.attributes.event_url;
- ]]]
- name: |
- [[[
- let team_abbr = entity.attributes.opponent_abbr || "N/A";
- let logo_url = `/local/images/afl/${team_abbr.toLowerCase()}.svg`;
- // Manual override for missing images
- let known_logos = ["adel", "bl", "carl", "coll", "ess", "fre", "geel", "gcfc", "gws", "haw", "melb", "nmfc", "port", "rich", "stk", "syd", "wce", "wb"];
- if (!known_logos.includes(team_abbr.toLowerCase())) {
- logo_url = `/local/images/afl/gcfc.svg`; // Fallback image
- }
- return `<img src="${logo_url}" style="width:65px;height:65px;">`;
- ]]]
- label: |
- [[[
- return entity.state === "PRE" ? entity.attributes.opponent_abbr : entity.attributes.opponent_score;
- ]]]
- styles:
- label:
- - font-size: |
- [[[
- return entity.state === "PRE" ? "1em" : "2em";
- ]]]
- - font-weight: 700
- - padding-top: 50px
- - color: |
- [[[
- if (entity.state === "PRE") {
- return "white";
- }
- let homeScore = parseInt(entity.attributes.team_score, 10);
- let awayScore = parseInt(entity.attributes.opponent_score, 10);
- if (homeScore === awayScore) {
- return "white"; // Both scores white when tied
- }
- return (homeScore > awayScore)
- ? "rgba(255, 255, 255, 0.5)" // Dimmed if AWAY wins
- : "white"; // Fully visible if AWAY loses
- ]]]
- - align-content: end
- align-self: end
- justify-content: center
- justify-self: center
- font-family: Chromatic Gothic Semibold, sans-serif
- name:
- - align-content: end
- align-self: end
- justify-content: center
- justify-self: center
- margin: 0px 0px -30px 0px
- padding: 0px
- filter: >-
- drop-shadow(1px 0 0 rgba(255,255,255,0.8)) drop-shadow(-1px 0
- 0 rgba(255,255,255,0.8)) drop-shadow(0 1px 0
- rgba(255,255,255,0.8)) drop-shadow(0 -1px 0
- rgba(255,255,255,0.8))
- card:
- - background: transparent
- - padding: 0px 0px 0px 0px
- - width: 110px
- - height: 170px
- - margin: '-30px 0px 10px 0px'
- - border-radius: 0px
- - opacity: |
- [[[
- let sensor = states['sensor.afl_ladder'];
- let index = parseInt(variables.var_index, 10);
- if (sensor?.attributes?.entries?.length > index) {
- let entry = sensor.attributes.entries[index].summary;
- let status = entry.match(/Status:\s*<\/strong>(.*?)<\/p>/)?.[1] || "N/A";
- return status === "POST" ? "0.5" : "1"; // Reduce opacity if game is finished
- }
- return "1"; // Default full opacity if data is unavailable
- ]]]
- - filter: |
- [[[
- let homeScore = parseInt(entity.attributes.team_score, 10) || 0;
- let awayScore = parseInt(entity.attributes.opponent_score, 10) || 0;
- let isPostGame = entity.state === "POST";
- return isPostGame && awayScore < homeScore ? "opacity(1)" : "none";
- ]]]
- status:
- card:
- type: custom:layout-card
- layout_type: custom:grid-layout
- layout:
- grid-template-areas: '"match_status"'
- grid-template-columns: 1fr
- grid-template-rows: auto
- cards:
- - view_layout:
- grid-area: match_status
- type: custom:button-card
- tap_action:
- action: url
- url_path: |
- [[[
- return entity.attributes.event_url;
- ]]]
- show_label: true
- show_name: false
- show_icon: false
- show_state: false
- label: |
- [[[
- let state = entity.state;
- let diff = entity.attributes.team_score - entity.attributes.opponent_score;
- if (state === 'PRE') {
- return `Bounce ${entity.attributes.kickoff_in}`;
- }
- else if (state === 'IN') {
- if (diff > 0) {
- return `${entity.attributes.team_name} lead by ${diff} ${diff === 1 ? "point" : "points"}`;
- } else if (diff < 0) {
- return `${entity.attributes.opponent_name} lead by ${Math.abs(diff)} ${Math.abs(diff) === 1 ? "point" : "points"}`;
- } else {
- return `Match tied`;
- }
- }
- else if (state === 'POST') {
- if (diff > 0) {
- return `${entity.attributes.team_name} won by ${diff} ${diff === 1 ? "point" : "points"}`;
- } else if (diff < 0) {
- return `${entity.attributes.opponent_name} won by ${Math.abs(diff)} ${Math.abs(diff) === 1 ? "point" : "points"}`;
- } else {
- return `Match tied`;
- }
- }
- else {
- return `Match tied`;
- }
- ]]]
- styles:
- card:
- - background: transparent
- padding: 0px
- margin: 0px
- height: 40px
- align-content: center
- justify-content: center
- label:
- - font-size: .9em
- font-weight: 700
- color: rgba(255,255,255,1)
- padding: 10px 0px 20px 0px
- margin: 0px
- card:
- card:
- type: custom:button-card
- tap_action:
- action: perform-action
- perform_action: script.kayo
- show_label: true
- show_name: false
- show_icon: false
- show_state: false
- label: Watch on Kayo
- styles:
- card:
- - background: rgba(0,0,0,0.4)
- - border-radius: 10px
- - padding: 0px 30px 0px 30px
- - margin: '-10px 0px 0px 30px'
- - text-align: center
- - height: 40px
- - width: 240px
- - align-content: center
- - align-self: center
- - justify-content: center
- - justify-self: center
- label:
- - font-size: .9em
- - font-weight: 400
- - color: rgba(255,255,255,0.6)
- card_mod:
- style: |
- :host {
- display: block;
- position: relative; margin: 0px 6px 0px 0px;
- }
- :host::before {
- content: "";
- position: absolute;
- inset: 0;
- border-radius: 30px;
- backdrop-filter: blur(50px);
- -webkit-backdrop-filter: blur(50px);
- z-index: -1;
- padding: .1rem;
- background: linear-gradient(60deg,
- rgba(255,255,255,0.0) 0%,
- rgba(255,255,255,0.2) 49%,
- rgba(255,255,255,0.2) 51%,
- rgba(255,255,255,0.0) 100%);
- -webkit-mask:
- linear-gradient(#fff 0 0) content-box,
- linear-gradient(#fff 0 0);
- -webkit-mask-composite: xor;
- mask-composite: exclude;
- z-index: 0; filter: saturate(140%);
- }
- :host::after {
- content: "";
- background: linear-gradient(180deg, rgba(255,255,255, 0.1) 20%, rgba(255,255,255, 0.0) 100%);
- position: absolute;
- inset: 0;
- border-radius: 30px;
- box-shadow: inset -8px 10px 15px rgba(0, 0, 0, 0.1);
- z-index: -1;
- -webkit-backdrop-filter:blur(30px) saturate(110%) brightness(90%);
- filter: drop-shadow(3px 3px 10px rgba(0, 0, 0, 0.2)); }
Advertisement
Add Comment
Please, Sign In to add comment