Skip to content

FaserF/ha-dieliga

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

47 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DieLiga Home Assistant Integration 🏐

The dieliga sensor provides information about your sports league from DieLiga, compatible with scoreboard systems based on "dieLiga" (tested with Volleyball-Freizeit Ost).

Features ✨

  • Modern Architecture: Uses DataUpdateCoordinator for efficient API polling.
  • Scoreboard: See your team's current position or the league name.
  • Schedule: Track upcoming games and season progress (percentage of completed games).
  • Notifications: Get alerts for rank changes and game reminders via Home Assistant automations.

Installation πŸ› οΈ

1. Using HACS (Recommended)

  1. Open HACS in your Home Assistant instance.
  2. Click the three dots in the top right corner and select Custom repositories.
  3. Add Repository: https://github.com/FaserF/ha-dieliga
  4. Category: Integration
  5. Click Add.
  6. Search for "die Liga" and click Download.

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

2. Manual Installation

  1. Download the latest Release.
  2. Extract the ZIP file.
  3. Copy the custom_components/dieliga folder to your <config>/custom_components/ directory.
  4. Restart Home Assistant.

Configuration βš™οΈ

  1. Go to Settings -> Devices & Services.
  2. Click Add Integration.
  3. Search for "die Liga".

Open your Home Assistant instance and start setting up a new integration.

Configuration Variables

Variable Description
Base URL The URL of the DieLiga instance (e.g., https://www.ost.volleyball-freizeit.de).
Liga ID The numeric ID of your league. Found in the URL of your league's schedule page (e.g., 1031).
Team Name (Optional) Your team's name exactly as it appears on the website. Used for filtering the schedule and showing your rank.

Sensors & Platforms πŸš€

The integration provides the following entities to keep you up to date:

Platform Entity Description
sensor Scoreboard πŸ† Your team's current position in the league or the league name.
sensor Schedule πŸ“… The progress of the season (%) and a full list of matches in attributes.
calendar Match Calendar πŸ—“οΈ All upcoming matches displayed directly in your Home Assistant calendar.
binary_sensor Match Today ⚑ Turns on if your team has a game today. perfect for automation triggers!

Tip

Pro Tip: The Match Today sensor is disabled by default to keep your setup clean. You can manually enable it under Settings -> Devices & Services -> dieLiga -> Entities. πŸ› οΈ

Automations πŸ€–

Below are several examples of how you can use the sensor data in your automations.

1. Basic: Rank Change Notification

This automation sends a notification whenever your team's position in the league table changes.

alias: "dieLiga: Notify Rank Change"
trigger:
  platform: state
  entity_id: sensor.dieliga_scoreboard_myteam
condition:
  # Ensure the state is a number (position) and has actually changed
  - condition: template
    value_template: "{{ trigger.from_state.state != trigger.to_state.state }}"
action:
  service: notify.mobile_app_myphone
  data:
    title: "League Update! 🏐"
    message: >
      Your team is now in position {{ states('sensor.dieliga_scoreboard_myteam') }}.
2. Intermediate: Match Day Reminder (1 day before)

Sends a reminder at 8 PM the day before a game.

alias: "dieLiga: Game Tomorrow Reminder"
trigger:
  platform: time
  at: "20:00:00"
condition:
  - condition: template
    value_template: >
      {% set games = state_attr('sensor.dieliga_schedule_myteam', 'games') %}
      {% if games %}
        {% set next_game = games | selectattr('state', 'ne', 'Completed') | first %}
        {% if next_game %}
          {{ (strptime(next_game.date, '%Y-%m-%d').date() - now().date()).days == 1 }}
        {% else %}
          false
        {% endif %}
      {% else %}
        false
      {% endif %}
action:
  service: notify.mobile_app_myphone
  data:
    title: "Match Day Tomorrow! 🏐"
    message: >
      Reminder: You play against {{ state_attr('sensor.dieliga_schedule_myteam', 'games')[0].team_a_name if state_attr('sensor.dieliga_schedule_myteam', 'games')[0].team_b_name == 'My Team Name' else state_attr('sensor.dieliga_schedule_myteam', 'games')[0].team_b_name }} tomorrow!
3. Advanced: Post-Match Result Notification

This automation triggers when the season progress increases (meaning a game was completed) and sends the result of the last game.

alias: "dieLiga: Post-Match Result"
trigger:
  platform: state
  entity_id: sensor.dieliga_schedule_myteam
condition:
  # Only trigger if the completed percentage increased
  - condition: template
    value_template: "{{ trigger.to_state.state | int > trigger.from_state.state | int }}"
action:
  - set_variable:
      last_game: >
        {% set games = state_attr('sensor.dieliga_schedule_myteam', 'games') %}
        {{ games | selectattr('state', 'eq', 'Completed') | list | last }}
  - service: notify.mobile_app_myphone
    data:
      title: "Game Result 🏐"
      message: >
        Result for {{ last_game.team_a_name }} vs {{ last_game.team_b_name }}:
        {{ last_game.team_a_sets }} : {{ last_game.team_b_sets }} sets.
4. Dashboard: Next 3 Matches (Markdown)

You can use this template in a manual markdown card to see your upcoming schedule.

type: markdown
content: >
  ### Upcoming Matches 🏐
  | Date | Opponent | Time |
  | :--- | :--- | :--- |
  {% set games = state_attr('sensor.dieliga_schedule_myteam', 'games') | selectattr('state', 'ne', 'Completed') | list %}
  {% for game in games[:3] %}
  | {{ game.date }} | {{ game.team_b_name if game.team_a_name == 'My Team Name' else game.team_a_name }} | {{ game.time }} |
  {% endfor %}

Bug Reporting πŸ›

Please open an issue on GitHub. For debugging, add this to your configuration.yaml:

logger:
  logs:
    custom_components.dieliga: debug

Developers πŸ’»

Tests can be run using pytest:

pip install pytest pytest-homeassistant-custom-component
pytest

About

Homeassistant integration for "dieLiga" based ranking sites

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors

Languages