Skons / hassio-addons

7 stars 4 forks source link

error: 'list index out of range' #57

Closed fbloemhof closed 11 months ago

fbloemhof commented 11 months ago

When using a radius of 9 or higher, DGP gives the error 'list index out of range'.

Using the example automation with adjusted radius:

automation:
- alias: Update gas stations
  trigger:
    - platform: time_pattern
      minutes: 5 #every 5 minute past whole
  action:
  - service: mqtt.publish
    data:
      topic: 'dgp/gas_stations'
      payload_template: '{"fuel_type":"euro95","radius":9,"latitude":{{ state_attr("person.skons", "latitude") }},"longitude":{{ state_attr("person.skons", "longitude") }}, "to_publish":3}'

The logging shows:

[2023-09-28 19:43:48] INFO    : Received payload '{"fuel_type":"euro95","radius":9,"latitude":xxx,"longitude":xxx, "to_publish":5}' on topic 'dgp/gas_stations'
[2023-09-28 19:43:50] ERROR   : Unable to process station_request payload '{'fuel_type': 'euro95', 'radius': 9, 'latitude': xxx, 'longitude': xxx, 'to_publish': 5}' with error: 'list index out of range'
[2023-09-28 19:43:50] INFO    : publishing status to mqtt
fbloemhof commented 11 months ago

Hm, it has something to do with my specific coordinates it seems.

fbloemhof commented 11 months ago

Using this automation, the addon is not responding?

service: mqtt.publish
data:
  topic: dgp/gas_stations
  payload: |-
      {
        "fuel_type": "euro95",
        "radius": 8,
        "latitude": 53.219383,
        "longitude": 6.566502,
        "to_publish": 3
      }

Whilst using this from your example it does, but doesn't find anything:

service: mqtt.publish
data:
  topic: dgp/gas_stations
  payload: |-
      {
        "fuel_type": "euro95",
        "radius": 8,
        "latitude": 6,
        "longitude": 53,
        "to_publish": 3
      }

What probably is caused because lat long are mixed up here (there are no gas stations in the Indian Ocean...).

[2023-09-28 20:00:00] INFO    : Received payload '{
  "fuel_type": "euro95",
  "radius": 8,
  "latitude": 6,
  "longitude": 53,
  "to_publish": 3
}' on topic 'dgp/gas_stations'
[2023-09-28 20:00:04] INFO    : There are '0' stations within range for fuel type 'euro95'

After swapping them back, the addon doesn't respond again...

fbloemhof commented 11 months ago

Started working again after restarting (or changing the log level?).