Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

MLB game scores custom component for Home Assistant

NotificationsYou must be signed in to change notification settings

SimplySynced/ha-mlb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This integration fetches data for a team's current/future games, and creates a sensor with attributes for the details of the game.

The integration is an updated version of theHA-NHL the which is based off the excellent pluginHA-NFL custom component by @zacs. Thank you for the template! This code has been updated to be used with the same ESPN data source but for the .

Sensor Data

State

The sensor is pretty simple: the main states arePRE,IN,POST orPOSTPONED, but there are attributes for pretty much all aspects of the game, when available. State definitions are as you'd expect:

  • PRE: The game is in pre-game state.
  • IN: The game is in progress.
  • POST: The game has completed.
  • POSTPONED: Your given team has had the game scheduled postponed. Note that attributes available are limited in this case (only abreviation, name, logo, and last updated time will be available).

Attributes

The attributes available will change based on the sensor's state, a small number are always available (team abbreviation, team name, and logo), but otherwise the attributes only populate when in the current state. The table below lists which attributes are available in which states.

NameValueRelevant States
dateDate and time of the gamePREINPOSTPOSTPONED
first_pitchHuman-readable string for how far away the game is (eg. "in 30 minutes" or "tomorrow")PREINPOSTPOSTPONED
inningThe current quarter of gameplayIN
venueThe name of the stadium where the game is being played (eg. "Wells Fargo Center")PREINPOSTPOSTPONED
locationThe city and state where the game is being played (eg. "Philadelphia, PA")PREINPOSTPOSTPONED
tv_networkThe TV network where you can watch the game (eg. "NBC" or "FOX"). Note that if there is a national feed, it will be listed here, otherwise the local affiliate will be listed.PREINPOSTPOSTPONED
oddsThe betting odds for the game (eg. "PHI -5.0")PRE
overunderThe over/under betting line for the total points scored in the game (eg. "3.2").PRE
team_abbrThe abbreviation for your team (ie.PHI for the Flyers).PREINPOSTPOSTPONED
team_idA numeric ID for your team, used to matchpossession above.PREINPOSTPOSTPONED
team_nameYour team's name (eg. "Flyers"). Note this does not include the city name.PREINPOSTPOSTPONED
team_recordYour team's current record (eg. "2-3").PREINPOSTPOSTPONED
team_homeawayYour team's home/away status. Eitherhome oraway.PREINPOSTPOSTPONED
team_logoA URL for a 500px wide PNG logo for the team.PREINPOSTPOSTPONED
team_colorsAn array with two hex colors. The first is your team's primary color, and the second is their secondary color. Unless you're the Browns, in which case they are the same.PREINPOSTPOSTPONED
team_scoreYour team's score. An integer.INPOST
opponent_abbrThe abbreviation for your opponent (ie.PHI for the Flyers).PREINPOSTPOSTPONED
opponent_idA numeric ID for your opponent, used to matchpossession above.PREINPOSTPOSTPONED
opponent_nameYour opponent's name (eg. "Seahawks"). Note this does not include the city name.PREINPOSTPOSTPONED
opponent_recordYour opponent's current record (eg. "2-3").PREINPOSTPOSTPONED
opponent_homeawayYour opponent's home/away status. Eitherhome oraway.PREINPOSTPOSTPONED
opponent_logoA URL for a 500px wide PNG logo for the opponent.PREINPOSTPOSTPONED
opponent_colorsAn array with two hex colors. The first is your opponent's primary color, and the second is their secondary color.PREINPOSTPOSTPONED
opponent_scoreYour opponent's score. An integer.INPOSTPOSTPONED
last_updateA timestamp for the last time data was fetched for the game. If you watch this in real-time, you should notice it updating every 10 minutes, except for during the game (and for the ~20 minutes pre-game) when it updates every 5 seconds.PREINPOSTPOSTPONED

Installation

Manually

Clone or download this repository and copy the "mlb" directory to your "custom_components" directory in your config directory

<config directory>/custom_components/mlb/...

HACS

  1. Open the HACS section of Home Assistant.
  2. Click the "..." button in the top right corner and select "Custom Repositories."
  3. In the window that opens paste this Github URL.
  4. In the window that opens when you select it click om "Install This Repository in HACS"

Configuration

You'll need to know your team ID, which is a 2- or 3-letter acronym (eg. "PHI" for Philadelphia or "NJ" for New Jersey). You can find yours athttps://www.espn.com/mlb/ in the top scores UI.

Via the "Configuration->Integrations" section of the Home Assistant UI

Look for the integration labeled "MLB" and enter your team's acronym in the UI prompt. You can also enter a friendly name. If you keep the default, your sensor will besensor.mlb, otherwise it will besensor.friendly_name_you_picked.

Manually in yourconfiguration.yaml file

To create a sensor instance add the following configuration to your sensor definitions using the team_id found above:

- platform: mlb  team_id: 'PHI'

After you restart Home Assistant then you should have a new sensor calledsensor.mlb in your system.

You can overide the sensor default name (sensor.mlb) to one of your choosing by setting thename option:

- platform: mlb  team_id: 'PHI'  name: Phillies

Using the configuration example above the sensor will then be called "sensor.Phillies".

About

MLB game scores custom component for Home Assistant

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp