https://github.com/toringer/home-assistant-sporet
Home Assistant integration for monitoring cross-country ski trail conditions from Sporet.no - track grooming status and trail conditions
https://github.com/toringer/home-assistant-sporet
cross-country custom-integration home-assistant
Last synced: 5 months ago
JSON representation
Home Assistant integration for monitoring cross-country ski trail conditions from Sporet.no - track grooming status and trail conditions
- Host: GitHub
- URL: https://github.com/toringer/home-assistant-sporet
- Owner: toringer
- License: mit
- Created: 2025-12-02T19:07:02.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-12-28T20:10:30.000Z (6 months ago)
- Last Synced: 2025-12-31T13:16:54.488Z (5 months ago)
- Topics: cross-country, custom-integration, home-assistant
- Language: Python
- Homepage:
- Size: 253 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/toringer/home-assistant-sporet)
[](https://github.com/toringer/home-assistant-sporet/actions/workflows/hassfest.yaml)
[](https://github.com/toringer/home-assistant-sporet/actions/workflows/validate_hacs.yaml)
[](https://github.com/toringer/home-assistant-sporet)
[](https://github.com/toringer/home-assistant-sporet)
[](https://github.com/toringer/home-assistant-sporet)
# Sporet.no - Home Assistant Integration
A Home Assistant custom component for monitoring cross-country ski trail conditions from [Sporet.no](https://sporet.no/).
## Features
- Monitor ski trail slope status
- Track trail preparation time
- View preparation quality across slope segments
- Automatic updates every 15 minutes
## Installation
### HACS (Recommended)
1. Open HACS in your Home Assistant instance
2. Click on "Integrations"
3. Click the three dots in the top right corner
4. Select "Custom repositories"
5. Add this repository URL: `https://github.com/yourusername/home-assistant-sporet`
6. Select "Integration" as the category
7. Click "Add"
8. Find "Sporet" in the HACS integration list and click "Download"
9. Restart Home Assistant
### Manual Installation
1. Download the `custom_components/sporet` folder from this repository
2. Copy the entire `sporet` folder to your Home Assistant `custom_components` directory:
- Path: `/custom_components/sporet/`
3. Restart Home Assistant
## Configuration
### Prerequisites
Before setting up the integration, you need:
1. **Ski Trail Slope ID**: Find this at [sporet.no](https://sporet.no/)
- Navigate to your desired ski trail
- Select a slope in the map
- Click the `Share` button
- Extract the slope id from the copied URL
2. **Bearer Token**:
- Log in to sporet.no
- Open the network anaylser in the developer tools of the browser
- Find the `details` traffic, find the `authorization` attribute in the header section
- Copy the token
> [!IMPORTANT]
> Make sure you copy the entire token!
>
> Some browsers might truncate the Bearer Token when you copy it. Look for a switch to
> "display raw headers" or similar which will ensure the entire string is available.
Another option is to right click on one of the requests to `https://api.sporet.no` and look for
**Copy Request Headers**, or **Copy as Curl** or something similar. Paste the result into
a plain text file and find the line starting with `Authorization:`. Copy the entire line and
paste it into the Bearer Token field below.
### Setup Steps
1. In Home Assistant, go to **Settings** → **Devices & Services**
2. Click **+ Add Integration**
3. Search for "Sporet"
4. Enter your configuration:
- **Bearer Token**: Your API authentication token
5. Click **Submit**
The integration will validate your credentials.
After the main entry is created, you can add slopes and segments.
1. Go to **Settings** → **Devices & Services**
2. Find the "Sporet" integration
3. Click the "+" sign next to "Add entry" in the Sporet Integration
4. Add a Slope - either a "Share" link from the Slope or Segment or just the ID number
The integration will create sensors for the specified slope.
## Sensors
The integration creates three sensors for each configured slope:
### 1. Prepped Time
- **Entity ID**: `sensor._prepped_time`
- **Description**: Timestamp of when the trail was last prepared
- **Device Class**: Timestamp
- **Example**: `2025-12-01T09:06:12Z`
### 2. Prep Symbol
- **Entity ID**: `sensor._prep_symbol`
- **Description**: Numeric code indicating overall trail condition
- **Values**:
- `30`: Good condition
- `50`: Fair condition
- `70`: Poor condition or not groomed
- Other values as defined by Sporet
- **Example**: `30`
### 3. Prep Symbol Parts
- **Entity ID**: `sensor._prep_symbol_parts`
- **Description**: Shows the lowest prep symbol value across all route segments
- **Attributes**: Contains `parts` array with detailed breakdown by segment
- **Example**: `30` (lowest value from all segments)
### Additional Attributes
Each sensor includes additional attributes with detailed route information:
- `slope_id`: The route identifier
- `slope_name`: Name of the ski trail route
- `destination_name`: Name of the destination area
- `county`: County name
- `municipal`: Municipality name
- `country`: Country
- `prepped_by`: Organization responsible for grooming
- `hasClassic`: Boolean - Classic skiing available
- `hasSkating`: Boolean - Skating skiing available
- `hasFloodlight`: Boolean - Floodlight available
- `isScooterTrail`: Boolean - Scooter trail
- `routelength`: Total length of the route in meters
- `totalElevationGain`: Total elevation gain in meters
- `totalElevationLoss`: Total elevation loss in meters
- `parts`: (prep_symbol_parts sensor only) Array of segment-level prep symbols with percentages
## Updating Bearer Token
If your bearer token expires or needs to be updated:
1. Go to **Settings** → **Devices & Services**
2. Find the "Sporet" integration
3. Click **Configure**
4. Enter your new bearer token
5. Click **Submit**
The integration will reload with the new token without losing your configuration.
## Example Automation
### Notify when trail is freshly groomed
```yaml
automation:
- alias: "Notify when trail is groomed"
trigger:
- platform: state
entity_id: sensor.sjusjoen_ljosheim_kort_prepped_time
condition:
- condition: template
value_template: >
{{ (now() - states.sensor.sjusjoen_ljosheim_kort_prepped_time.state | as_datetime).total_seconds() < 3600 }}
action:
- service: notify.mobile_app
data:
title: "Trail Groomed!"
message: "Ljøsheim trail segment was just groomed."
```
### Display trail condition in Lovelace
```yaml
type: entities
title: Ski Trail Status
entities:
- entity: sensor.heistadmoen_10_km_prepped_time
name: Last Groomed
- entity: sensor.heistadmoen_10_km_prep_symbol
name: Overall Condition
- entity: sensor.heistadmoen_10_km_prep_symbol_parts
name: Worst Segment Condition
```
## API Details
The integration uses the Sporet public API:
- **Endpoint**: `https://api.sporet.no/loypeapi/public/skiroutes/{slope_id}/details`
- **Authentication**: Bearer token in Authorization header
- **Update Interval**: 900 seconds (15 minutes)
- **Method**: GET
## Troubleshooting
### Cannot Connect Error
- Verify your internet connection
- Check if sporet.no is accessible
- Ensure the API endpoint is not blocked by your firewall
### Invalid Auth Error
- Verify your bearer token is correct
- Check if the token has expired
- Regenerate a new token from sporet.no
### Route Not Found Error
- Verify the slope ID exists on sporet.no
- Check the slope ID is correct
- Make a manual API call to verify the route exists
### Enable Debug Logging
Add to your `configuration.yaml`:
```yaml
logger:
default: info
logs:
custom_components.sporet: debug
```
## Development
This integration includes a development container for easy testing:
1. Open the project in VS Code
2. Install the "Remote - Containers" extension
3. Click "Reopen in Container" when prompted
4. The development Home Assistant instance will start automatically
5. Access at `http://localhost:8123`
## Support
For issues, feature requests, or contributions:
- GitHub Issues: [Create an issue](https://github.com/yourusername/home-assistant-sporet/issues)
- Discussions: [Join the discussion](https://github.com/yourusername/home-assistant-sporet/discussions)
## License
This project is licensed under the MIT License - see the LICENSE file for details.
## Credits
- Data provided by [Sporet.no](https://sporet.no/)
- Integration developed for Home Assistant