UK transport, API limit reached

Hi,

I have been using the UK Transport component, which is working great :slight_smile:

The only issue I’m having is the amount of API requests, I have only one bus sensor set up and running, but by 21:30 I had reached 80% of the 1000 limit, and by 23:30 I had received an ‘App limit violation’ notice.

Does anyone know how to limit the amount of requests?

Thanks in advance,

Will

Maybe this helps…

You can check the usage per hour on the transportAPI developer stats page. If there are more than 40 requests an hour something is amiss

Thanks for the help guys, I’ve checked the stats and there is a sudden jump in the number of requests part way through the day, I’ve attached screenshots.

Also no requests before 10am… Doesn’t look like standard usage - whats your config like?

Standard looks like:

image

The transport sensor was set up the previous evening, I also thought it was strange that there were no requests earlier. heres my config.

- platform: uk_transport
  app_id: ***********
  app_key: ************************
  queries:
    - mode: bus
      origin: 090079362845
      destination: Keswick

Looks ok :ok_hand:Still getting odd behaviour shown in the stats?

I’ve had it disabled, will try again just before midnight, will have a 24hr test to see what happens.

Still getting over api limit warnings, strange patterns in HA history

I don’t understand how that could occur, since API calls are throttled. Unless anyone else is experiencing this it must be related to your setup some how

No idea what is causing it, I’ve disabled it for now, until I find some time to dig into it.

Btw there is no penalty for breaching the limit, just mute the emails

I’ve started getting a similar issue reaching the limits. Is it possible to add an interval option for the compoment and then start using the new homeassistant.update_entity feature in 0.81 to check periodically? This way I could check only when needed.

I haven’t used it but isn’t scan_interval is what you are looking for? It came in with 0.81 I believe.

I think scan_interval has been around for a while but I don’t think all components support it (I could be wrong), it’s homeassistant.update_entity that was introduced in 0.81.

1 Like

Use scan_interval, set to something long like 10000 then use an automation to update_entity

1 Like

Ah so scan_interval can be used, doesn’t show this in the docs. Does this apply to all sensors then?

Yes it applies to all sensors. Same advice as here

How do you use update_entity on the UK Transport platform?

I have:

  - platform: uk_transport
    app_id: !secret uk_transport_app_id
    app_key: !secret uk_transport_api
    queries:
      - mode: train
        origin: XXX
        destination: XXX      
    scan_interval: 10000

and then I have several template sensors based on that, such as:

  - platform: template
    sensors:
      next_train_status:
        friendly_name: 'Next train status'
        entity_id: sensor.next_train_to_XXX
        value_template: '{{states.sensor.next_train_to_XXX.attributes.next_trains[0].status}}'

      next_trains_scheduled:
        friendly_name: 'Next train scheduled'
        entity_id: sensor.next_train_to_XXX
        value_template: '{{states.sensor.next_train_to_XXX.attributes.next_trains[0].scheduled}}'

If I update one of these template sensors using the update_entity service it doesn’t seem to update. Is this because the underlying platform isn’t being updated? If so how do I force the uk_transport platfrom to update?

EDIT: I am basing my assertion that it isn’t updating on this ‘more info’ panel but there are no trains on this route today so maybe I am mistaken. Maybe the “42 minutes” ago is telling me the last time it changed rather than the last time it was updated? I’ll wait until tomorrow when this line has trains again and see what happens.

As an aside though, why is it showing “LATE”?

image

This would be via an automation, something like the following:

- id: '1541955482859'
  alias: Update Transport
  trigger:
    minutes: '/5'
    seconds: 00
    platform: time
  action:
  - data:
      entity_id: sensor.buses_route
    service: homeassistant.update_entity

This will check ever 5 mins.

1 Like