Closed dafunkydan closed 2 months ago
First, 0.4.4 has issues with the key's, try 0.4.4.4 (dev release) Then, the API key header that I am sending is {"Authorization": [API_KEY]} which does not contain Bearer, can you try it without Bearer? For automating, the only solution I can think of is that you use the service call and add a template into it, this will then download the .rt locally in www/gtfs2 and you could connect to that via http:/IPD/local/gtfs2/file.rt
Any chance your realtime is covered with this one? https://gtfs.de/de/realtime/
Just noticed that you can just add the word 'Bearer' as well into the field for the API key....maybe that could help too?
First: Wow, you are Lightning Fast! 🚀 Second: Thank you so much for your support, highly appreciate it!! Now:
try 0.4.4.4 (dev release)
Done. What changed: The Entitites no longer render unavailable when turning on RT Data 👍
the API key header that I am sending is {"Authorization": [API_KEY]} which does not contain Bearer, can you try it without Bearer? Just noticed that you can just add the word 'Bearer' as well into the field for the API key....maybe that could help too?
I tried it in the Integration with X-API or API Key, with and without Prefix (no Quotes, just plain API Key, either with or without leading "Bearer "). Unfortunatly always same outcome:
- departure: '13:52:00'
departure_realtime: '-'
I'm not sure how to interpret the Debuglog, in Case this might be helpful please see Attachment debuglog.txt
For automating, the only solution I can think of is that you use the service call and add a template into it, this will then download the .rt locally in www/gtfs2 and you could connect to that via http:/IPD/local/gtfs2/file.rt
That might be a doable Solution! 👍 But lets put that aside, i will check this after i got it to work using manually updated API Keys.
Any chance your realtime is covered with this one? https://gtfs.de/de/realtime/
Unfortunatly not 😢
From tyhe logs I cannot see an error so it seems (?) to work. Can you try and use the service call and tick it to also receive readable output ? Then at least you can see if the key/logic works. Not receiving rt data can have multiple reasons...data missing (usually) or data format (less usual) or not the corrcet source.
Can you send me the link to the rt source ? EDIT...where I can get the API key I mean...the link is in the log
use the service call and tick it to also receive readable output ?
Sure! If i try it with Prefix Bearer:
service: gtfs2.update_gtfs_rt_local
data:
url: https://gtfs-rt-sandbox-dds.rnv-online.de/tripupdates/decoded
api_key_location: header
accept: false
debug_output: true
file: GTFS-Static-RNV1
api_key: >-
Bearer
****redacted****
I get Failed to call service gtfs2.update_gtfs_rt_local. Unknown error
Without that Prefix it runs through, but all files in \config\www\gtfs2\ are empty.
Can you send me the link to the rt source ?
Sure! Ill send you in a couple of minutes everything needed, or at least what i do have 😄
As i couldnt find any Adress for you, i think i found you HAs' Forum - Check your PNs there! 😎
Issue closed with 0.4.4.7
This would be the service call based on your sensor colelcting the token...add it to automation or so
service: gtfs2.update_gtfs_rt_local
data:
api_key: |
Bearer {{ state_attr('sensor.rnv_gtfs_rt_api_key','access_token') }}
url: https://gtfs-rt-sandbox-dds.rnv-online.de/tripupdates/
file: rnv
debug_output: true
api_key_location: header
accept: false
And from the gtfs2 integration to refer to the local file instead of the external sandbox
This would be the service call based on your sensor colelcting the token...add it to automation or so
In Case somebody wants to get started with RNVs (Mannheim, Ludwigshafen, Heidelberg) Realtime Data: In Order to get an API Key (hourly changing), you need to register for API at: https://www.opendata-oepnv.de/ht/de/organisation/verkehrsunternehmen/rnv/openrnv/start
They will send you an Email containing Information like this:
clientID=****yourClientID****
tenantID=****yourTenantID****
clientSecret=-****yourClientSecret****
resource=****yourResource****
hostname=https://gtfs-rt-sandbox-dds.rnv-online.de
Now, in order to create an API Key, you can set up a Sensor like this:
- platform: rest
name: RNV GTFS-RT API Key
resource: "https://login.microsoftonline.com/****yourTenantID****/oauth2/token"
method: POST
scan_interval: 3300
headers:
Content-Type: "application/x-www-form-urlencoded"
payload: "grant_type=client_credentials&client_id=****yourClientID****&client_secret=-****yourClientSecret****&resource=****yourResource****"
value_template: "{{ value_json.expires_on | int | timestamp_custom('%Y-%m-%d %H:%M:%S') }}"
json_attributes:
- not_before
- access_token
- token_type
This will get you an API Key valid for an Hour. The Key will be in the Attributes, the State of the Entity contains the Timestamp til when it is valid. From there you can continue with the Automation / Information one Post above:
service: gtfs2.update_gtfs_rt_local
You can easily put this API Refreshment in one big Automation - check if the API-Key is still valid - if not refresh it, and then continue with calling service: gtfs2.update_gtfs_rt_local
Describe the bug I am facing two Problems integrating my Local Transportations' Provider Realtime-Data:
Release used gtfs2: 0.4.4 HA: HAOS Core: 2024.4.3
Additional Path for static Zip-File: https://rnv-dds-prod-gtfs.azurewebsites.net/latest/gtfs.zip
Provided Realtime Query Information Sample from the Data Provider:
Querying the RT-Data with (Sample Key Expired):
Results in (Example stripped):
Debug Log when Configuring the Integration with Option API-Key / Header: