Hello Anand,
No worries, thanks for taking the time
I just composed you a private message with bunch of debug data. Hopefully you get something out from it.
Hi @Ruohonjuuri,
Thanks for the logs and the details! Looks like the template code for UI Option-4 was fetching HSL sensor data from index-1 instead of 0. I can’t remember if that was intentional so that sensor state showed the next immediate option (index-0) and then the table showed all subsequent options (index-1 …).
But now I realise it maybe better to show all routes in the table as well. I have fixed this in the README.md. Please update the same and see if that fixes the issue for you.
Hello @anand-p-r
Thanks for you effort with this nice Custom Component
In the last days I’m getting this error:
Logger: homeassistant.setup
Source: setup.py:162
First occurred: 12:51:31 (1 occurrences)
Last logged: 12:51:31
Setup failed for custom integration hslhrt: Requirements for hslhrt not found: ['python_graphql_client==0.3.1'].
I think this is happening since last home assistant updates
Best regards and thanks again!
Hi @IsaTTeN
This should now be fixed with the latest release. Please give it a try and see.
Regards,
Anand.
Hi @anand-p-r ,
I already created an issue on Github, but thought I post here as well… It seems that currently the attributes (Arrival time and alike) are no longer added to a sensor? Is there something I could check/verify to help resolve this?
Hi,
it appears that this module is currently broken because device_state_attributes has been replaced by extra_state_attributes.
Workaround: replace line 105 of sensor.py from
def device_state_attributes(self):
to
def extra_state_attributes(self):
Hi, thanks this is very nice add-on. I have a question, how to show the title of the card? I use the option 4, and it doesn’t have topic for the list but looks like this:
I have title:
set
This feature seems to be currently broken as HSL API requires API key. Getting key was easy but any idea how to modify configuration to add it?
edit: managed to solve issue by adding my key to const.py and adding these lines to init.py.
headers = {"digitransit-subscription-key": DIGITRANSIT_APIKEY}
graph_client = GraphqlClient(endpoint=BASE_URL,headers=headers)
Thank you very much patoto! I got my integration working again.
For somebody else adding API-key and wondering if integration does not load anymore, please remember to add DIGITRANSIT_APIKEY, under import section:
from .const import (
BASE_URL, DESTINATION,DIGITRANSIT_APIKEY,
I confirm it works for me too. I took the API key from Firefox inspector, looking at the post action, and copied the value to const.py. Here is the whole thing as one patch, except for the api key.
diff --git a/__init__.py b/__init__.py
index 1cb9311..d894de4 100644
--- a/__init__.py
+++ b/__init__.py
@@ -11,6 +11,7 @@ from python_graphql_client import GraphqlClient
from .const import (
BASE_URL, DESTINATION,
+ DIGITRANSIT_APIKEY,
DOMAIN,
STOP_NAME,
STOP_GTFS,
@@ -38,7 +39,9 @@ from .const import (
PLATFORMS = ["sensor"]
-graph_client = GraphqlClient(endpoint=BASE_URL)
+headers = {"digitransit-subscription-key": DIGITRANSIT_APIKEY}
+graph_client = GraphqlClient(endpoint=BASE_URL,headers=headers)
+# graph_client = GraphqlClient(endpoint=BASE_URL)
def base_unique_id(gtfs_id, route=None, dest=None):
diff --git a/const.py b/const.py
index 2206f29..510e5c3 100644
--- a/const.py
+++ b/const.py
@@ -13,6 +13,7 @@ MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=1)
UNDO_UPDATE_LISTENER = "undo_update_listener"
BASE_URL = "https://api.digitransit.fi/routing/v1/routers/hsl/index/graphql"
+DIGITRANSIT_APIKEY = "<get this from browser development tools looking at the post action>"
NAME_CODE = "user_name_code"
STOP_CODE = "stop_code"
Hi,
Any way to restrict the amount of lines in ROUTES-table? There is a really long list of arrivals and I’m getting this error on HA-log.
Logger: homeassistant.components.recorder.db_schema
Source: components/recorder/db_schema.py:578
Integration: Recorder (documentation, issues)
State attributes for sensor.kytopolku_h3281_all exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
First time poster here.
I’ve used HASS for a couple of months now, still learning and struggling a bit with custom integrations because my background is not a coder, I’m more of a designer who likes to tinker. Figuring things out takes longer for me, so perhaps this is helpful to those who are on the same level.
I could not get this integration to work even with the latest Digitransit API instructions above - they were not explicit and clear to me. What goes and where exactly within those two files? What saved me was finding this fork: GitHub - fimathias/hslhrt-hass-custom: HASSIO Custom Integration for HSL HRT
You can provide your API when adding configuration parameters into the integration (see screenshot). That last field is actually empty without any description, I just added “Add your API key here” text to indicate where it goes. Kind of obvious, but again explicit instructions never hurt and they speed up the process when you don’t need to second guess yourself.
To get the API key:
- Registering here: https://portal-api.digitransit.fi/
- Go to Products → Digitransit Developer API → Subscribe
- After subscribing, you can find the (primary) API key under your profile
After that everything went smoothly, there was no need to edit configuration files manually. Thank you to the OP for making this integration possible in the first place!
I got an email from Digitransit that all external users will be removed from development API 11.12.2023. Does this mean that this integration will stop working?
I tried to look from https://portal-api.digitransit.fi/ to register for production APIs, but could not find a way to do that.
@Amppa I received an email as well, but mine said that quota restrictions will take effect on January 31, 2024. When you sign in, visit this page to check your API subscription: Products: Details - Digitransit API Management - developer portal