{"id":24744350,"url":"https://github.com/faserf/ha-bahnvorhersage","last_synced_at":"2025-03-22T22:29:18.050Z","repository":{"id":274241209,"uuid":"922328100","full_name":"FaserF/ha-bahnvorhersage","owner":"FaserF","description":"bahnvorhersage.de Homeassistant fetching","archived":false,"fork":false,"pushed_at":"2025-02-02T10:50:30.000Z","size":143,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-02T11:26:58.625Z","etag":null,"topics":["bahn","hacs-integration","homeassistant"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FaserF.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"faserf","custom":"https://paypal.me/FaserF"}},"created_at":"2025-01-25T22:46:07.000Z","updated_at":"2025-02-02T10:49:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"0d397254-5434-4eef-9c8f-60dcee3049ce","html_url":"https://github.com/FaserF/ha-bahnvorhersage","commit_stats":null,"previous_names":["faserf/ha-bahnvorhersage"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FaserF%2Fha-bahnvorhersage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FaserF%2Fha-bahnvorhersage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FaserF%2Fha-bahnvorhersage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FaserF%2Fha-bahnvorhersage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FaserF","download_url":"https://codeload.github.com/FaserF/ha-bahnvorhersage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245028221,"owners_count":20549476,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bahn","hacs-integration","homeassistant"],"created_at":"2025-01-28T02:18:02.836Z","updated_at":"2025-03-22T22:29:18.039Z","avatar_url":"https://github.com/FaserF.png","language":"Python","funding_links":["https://github.com/sponsors/faserf","https://paypal.me/FaserF"],"categories":[],"sub_categories":[],"readme":"[![hacs_badge](https://img.shields.io/badge/HACS-CUSTOM-41BDF5.svg?style=for-the-badge)](https://github.com/hacs/integration)\n\n# Deprecation notice\nThe backend API owner does not allow API fetching in intervals, therefore this integration needs to be shut down and wont work anymore. More details are explained [here](https://github.com/FaserF/ha-bahnvorhersage/issues/1). Please use [ha-db_infoscreen](https://github.com/FaserF/ha-db_infoscreen) instead.\n\n# Bahnvorhersage Homeassistant Sensor\nThe `bahnvorhersage` sensor will give you the prediction departure time of the next trains for the given start \u0026 destination combination, containing many more attribute informations.\n\nThis integration works great side-by-side with [ha-db_infoscreen](https://github.com/FaserF/ha-db_infoscreen).\nThis is a superior to [ha-deutschebahn](https://github.com/FaserF/ha-deutschebahn).\n\n\u003cimg src=\"https://gitlab.com/bahnvorhersage/bahnvorhersage_frontend/-/raw/main/public/img/icons/android-chrome-512x512.png\" alt=\"Logo\" width=\"300px\"\u003e\n\n\u003cimg src=\"images/sensor.png\" alt=\"Station Sensor\" width=\"300px\"\u003e\n\n## Installation\n### 1. Using HACS (recommended way)\n\nThis integration is NO official HACS Integration right now.\n\nOpen HACS then install the \"bahnvorhersagen\" integration or use the link below.\n\n[![Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=FaserF\u0026repository=ha-bahnvorhersage\u0026category=integration)\n\nIf you use this method, your component will always update to the latest version.\n\n### 2. Manual\n\n- Download the latest zip release from [here](https://github.com/FaserF/ha-bahnvorhersage/releases/latest)\n- Extract the zip file\n- Copy the folder \"bahnvorhersage\" from within custom_components with all of its components to `\u003cconfig\u003e/custom_components/`\n\nwhere `\u003cconfig\u003e` is your Home Assistant configuration directory.\n\n\u003e__NOTE__: Do not download the file by using the link above directly, the status in the \"master\" branch can be in development and therefore is maybe not working.\n\n## Configuration\n\nGo to Configuration -\u003e Integrations and click on \"add integration\". Then search for \"bahnvorhersage\".\n\n[![Open your Home Assistant instance and start setting up a new integration.](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start/?domain=bahnvorhersage)\n\n### Configuration Variables\n\n| Key                        | Type    | Required | Default | Description |\n|----------------------------|---------|----------|---------|-------------|\n| `start_station`            | string  | Yes      | -       | The starting station* |\n| `destination_station`      | string  | Yes      | -       | The destination station* |\n| `next_departures`          | int     | No       | 2       | Number of upcoming departures to show |\n| `update_interval`          | int     | No       | 3       | Update interval in seconds |\n| `hide_low_delay`           | boolean | No       | False   | Hide trains with low delays |\n| `show_stopovers`           | boolean | No       | False   | Shop stopover details (not recommended due to performance decreasement) |\n| `drop_late_trains`         | boolean | No       | False   | Exclude very late trains |\n| `search_for_arrival`       | boolean | No       | False   | Search for arrival times instead of departure times |\n| `only_regional`            | boolean | No       | False   | Only show regional trains |\n| `bike`                     | boolean | No       | False   | Show bike-friendly trains |\n| `offset`                   | string  | No       | 00:00   | Time offset for departure search |\n| `ignored_traintypes`       | list    | No       | []      | List of train types to ignore |\n\n*: Please check your station on [https://bahnvorhersage.de](https://bahnvorhersage.de) on how to write it. It is important to choose the correct way of spaces and/or \"-\" symbols. If your station is not supported there, I can also not support it here, but you could then give [ha-db_infoscreen](https://github.com/FaserF/ha-db_infoscreen) a try instead.\n\n## Automation Examples for Home Assistant\n\n### 1. Predict Next Departure delay\nThis automation sends a push notification with the next predicted departure delay from **Start** to **Destination**.\n\n```yaml\nalias: \"Next Train predicted Departure Delay Notification\"\ntrigger:\n  - platform: time\n    at: \"07:00:00\"\ncondition: []\naction:\n  - service: notify.mobile_app_your_smartphone\n    data:\n      title: \"Train Forecast with prediction\"\n      message: \u003e\n        The next train from {{ state_attr('sensor.start_to_destination_bahnvorhersage', 'start_station') }}\n        to {{ state_attr('sensor.start_to_destination_bahnvorhersage', 'destination_station') }}\n        has an estimated predicted departure delay {{ state_attr('sensor.start_to_destination_bahnvorhersage', 'next_departures')[0]['departureDelayPrediction']['predictions'] }}.\n        Estimated arrival delay: {{ state_attr('sensor.start_to_destination_bahnvorhersage', 'next_departures')[0]['arrivalDelayPrediction']['predictions'] }}.\nmode: single\n```\n\n### 2. Notify on Next Departure\nThis automation sends a push notification with the next scheduled departure from **Start** to **Destination**.\n\n```yaml\nalias: \"Next Train Departure Notification\"\ntrigger:\n  - platform: time\n    at: \"07:00:00\"\ncondition: []\naction:\n  - service: notify.mobile_app_your_smartphone\n    data:\n      title: \"Train Forecast\"\n      message: \u003e\n        The next train from {{ state_attr('sensor.start_to_destination_bahnvorhersage', 'start_station') }}\n        to {{ state_attr('sensor.start_to_destination_bahnvorhersage', 'destination_station') }}\n        departs at {{ state_attr('sensor.start_to_destination_bahnvorhersage', 'next_departures')[0]['departure'] }}.\n        Estimated arrival: {{ state_attr('sensor.start_to_destination_bahnvorhersage', 'next_departures')[0]['arrival'] }}.\nmode: single\n```\n\n### 3. Delay Warning for the Next Train\nThis automation sends a warning notification if the predicted departure delay exceeds 2 minutes.\n\n```yaml\nalias: \"Train Delay Warning\"\ntrigger:\n  - platform: template\n    value_template: \u003e\n      {% set delay_predictions = state_attr('sensor.start_to_destination_bahnvorhersage', 'next_departures')[0]['departureDelayPrediction']['predictions'] %}\n      {{ (delay_predictions | sum / delay_predictions | length) \u003e 2 }}\ncondition: []\naction:\n  - service: notify.mobile_app_your_smartphone\n    data:\n      title: \"Train Delay Alert\"\n      message: \u003e\n        The train from {{ state_attr('sensor.start_to_destination_bahnvorhersage', 'start_station') }}\n        to {{ state_attr('sensor.start_to_destination_bahnvorhersage', 'destination_station') }} is expected to be delayed.\n        Average predicted delay: {{ (state_attr('sensor.start_to_destination_bahnvorhersage', 'next_departures')[0]['departureDelayPrediction']['predictions'] | sum / state_attr('sensor.start_to_destination_bahnvorhersage', 'next_departures')[0]['departureDelayPrediction']['predictions'] | length) | round(1) }} minutes.\nmode: single\n```\n\n### 4. Announce Train Departure on Smart Speaker\nThis automation announces the next departure time using a smart speaker like Google Home or Amazon Echo.\n\n```yaml\nalias: \"Announce Next Train Departure\"\ntrigger:\n  - platform: time_pattern\n    minutes: \"/5\"  # Check every 5 minutes\ncondition: []\naction:\n  - service: tts.google_translate_say\n    entity_id: media_player.living_room_speaker\n    data:\n      message: \u003e\n        The next train from {{ state_attr('sensor.start_to_destination_bahnvorhersage', 'start_station') }}\n        to {{ state_attr('sensor.start_to_destination_bahnvorhersage', 'destination_station') }}\n        departs at {{ state_attr('sensor.start_to_destination_bahnvorhersage', 'next_departures')[0]['departure'] }}\n        from platform {{ state_attr('sensor.start_to_destination_bahnvorhersage', 'next_departures')[0]['departurePlatform'] }}.\nmode: single\n```\n\n## API Data\n### Accessing their data\nThe bahnvorhersage.de data is being accessed with the [API](https://bahnvorhersage.de/api/journeys) and a POST request\n\n```json\n{\n    \"start\": \"Start Station\",\n    \"destination\": \"Destination\",\n    \"date\": \"25.01.2025 12:00\",\n    \"search_for_arrival\": false,\n    \"only_regional\": false,\n    \"bike\": false\n}\n```\n\n### JSON Format\nThe API returns data in the following json format usually:\n\n```json\n[{\n    \"legs\": [{\n        \"origin\": {\n            \"id\": \"1234567\",\n            \"name\": \"Start\",\n            \"location\": {\n                \"id\": \"1234567\",\n                \"latitude\": 12.345678,\n                \"longitude\": 12.345678\n            },\n            \"products\": null,\n            \"type\": \"station\"\n        },\n        \"destination\": {\n            \"id\": \"1234567\",\n            \"name\": \"Destination\",\n            \"location\": {\n                \"id\": \"1234567\",\n                \"latitude\": 12.345678,\n                \"longitude\": 12.345678\n            },\n            \"products\": null,\n            \"type\": \"station\"\n        },\n        \"departure\": \"2025-01-25T12:02:00+01:00\",\n        \"departurePlatform\": \"5\",\n        \"arrival\": \"2025-01-25T13:04:00+01:00\",\n        \"arrivalPlatform\": \"3\",\n        \"cancelled\": false,\n        \"direction\": \"München-Pasing\",\n        \"stopovers\": [{\n            \"stop\": {\n                \"id\": \"1234567\",\n                \"name\": \"Zorneding\",\n                \"location\": {\n                    \"id\": \"1234567\",\n                    \"latitude\": 12.345678,\n                    \"longitude\": 12.345678\n                },\n                \"products\": null,\n                \"type\": \"station\"\n            },\n            \"arrival\": null,\n            \"plannedArrival\": null,\n            \"arrivalPlatform\": \"5\",\n            \"departure\": \"2025-01-25T12:02:00+01:00\",\n            \"plannedDeparture\": \"2025-01-25T12:02:00+01:00\",\n            \"departurePlatform\": \"5\",\n            \"cancelled\": false,\n            \"type\": \"stopover\"\n        },\n        [...]\n        {\n            \"stop\": {\n                \"id\": \"1234567\",\n                \"name\": \"Starnberg\",\n                \"location\": {\n                    \"id\": \"1234567\",\n                    \"latitude\": 12.345678,\n                    \"longitude\": 12.345678\n                },\n                \"products\": null,\n                \"type\": \"station\"\n            },\n            \"arrival\": \"2025-01-25T14:04:00+01:00\",\n            \"plannedArrival\": \"2025-01-25T14:04:00+01:00\",\n            \"arrivalPlatform\": \"3\",\n            \"departure\": null,\n            \"plannedDeparture\": null,\n            \"departurePlatform\": \"3\",\n            \"cancelled\": false,\n            \"type\": \"stopover\"\n        }],\n        \"plannedDeparture\": \"2025-01-25T13:02:00+01:00\",\n        \"plannedDeparturePlatform\": \"5\",\n        \"departureDelayPrediction\": {\n            \"predictions\": [0.00047, 0.00084, 0.00777, 0.32811, 0.29321, 0.12286, 0.05807, 0.04459, 0.03696, 0.02058, 0.01624, 0.01396, 0.01007, 0.00752, 0.00457, 0.00473, 0.00366, 0.00221, 0.00247, 0.00234, 0.00293, 0.00199, 0.00233, 0.00223, 0.00122, 0.00194, 0.00125, 0.00071, 0.00074, 0.00069, 0.00047, 0.0005, 0.00127, 0.0005],\n            \"offset\": 3,\n            \"type\": \"delayPrediction\"\n        },\n        \"plannedArrival\": \"2025-01-25T14:04:00+01:00\",\n        \"plannedArrivalPlatform\": \"3\",\n        \"arrivalDelayPrediction\": {\n            \"predictions\": [0.00043, 0.00112, 0.01883, 0.20492, 0.12529, 0.10636, 0.08477, 0.06242, 0.05973, 0.02657, 0.02752, 0.02364, 0.01864, 0.01251, 0.00584, 0.01028, 0.01035, 0.00974, 0.00533, 0.00509, 0.00918, 0.0388, 0.02247, 0.0193, 0.04173, 0.02942, 0.00706, 0.00305, 0.00247, 0.00305, 0.00129, 0.00099, 0.00127, 0.00053],\n            \"offset\": 3,\n            \"type\": \"delayPrediction\"\n        },\n        \"line\": {\n            \"id\": \"s-6662\",\n            \"name\": \"S 1\",\n            \"operator\": {\n                \"type\": \"operator\",\n                \"id\": \"db-regio-ag-s-bahn-munchen\",\n                \"name\": \"DB Regio AG S-Bahn München\"\n            },\n            \"isRegio\": true,\n            \"productName\": \"S\",\n            \"mode\": \"train\",\n            \"fahrtNr\": \"6662\",\n            \"adminCode\": \"800725\",\n            \"type\": \"line\"\n        },\n        \"tripId\": \"2|#VN#1#ST#1737574886#PI#\",\n        \"type\": \"leg\"\n    }],\n    \"price\": null,\n    \"refreshToken\": \"1234###\",\n    \"type\": \"journey\"\n}]\n```\n\n## Bug reporting\nOpen an issue over at [github issues](https://github.com/FaserF/ha-bahnvorhersage/issues). Please prefer sending over a log with debugging enabled.\n\nTo enable debugging enter the following in your configuration.yaml\n\n```yaml\nlogger:\n    logs:\n        custom_components.bahnvorhersage: debug\n```\n\nYou can then find the log in the HA settings -\u003e System -\u003e Logs -\u003e Enter \"bahnvorhersage\" in the search bar -\u003e \"Load full logs\"\n\n## Thanks to\nThe data is coming from the [bahnvorhersage.de](https://bahnvorhersage.de/) website.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaserf%2Fha-bahnvorhersage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffaserf%2Fha-bahnvorhersage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaserf%2Fha-bahnvorhersage/lists"}