Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: list index out of range #1

Closed
tonyp opened this issue Mar 7, 2019 · 2 comments
Closed

IndexError: list index out of range #1

tonyp opened this issue Mar 7, 2019 · 2 comments
Assignees

Comments

@tonyp
Copy link

tonyp commented Mar 7, 2019

I get a list index out of range error:

[2019-03-07 12:34:19] [DEBUG] (MainThread) https://synology-ip:5001 "GET /webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&method=List&version=1&_sid=token HTTP/1.1" 200 None
[2019-03-07 12:34:19] [INFO] (MainThread) info_response status_code 200
[2019-03-07 12:34:19] [INFO] (MainThread) Synology Info Camera Id 1 Name Xiaofang1 IP 192.168.x.x
[2019-03-07 12:34:19] [INFO] (MainThread) CameraMotionEventHandler  poll_event 1 Main Entrance
[2019-03-07 12:34:19] [INFO] (MainThread) Start getting last camera event for camera 1 Main Entrance
[2019-03-07 12:34:19] [DEBUG] (MainThread) Starting new HTTPS connection (1): tonyyy.duckdns.org:5001
/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
[2019-03-07 12:34:19] [DEBUG] (MainThread) https://synology-ip:5001 "GET /webapi/entry.cgi?api=SYNO.SurveillanceStation.Event&method=List&version=4&locked=0&reason=2&limit=1&cameraIds=1&_sid=token HTTP/1.1" 200 None
[2019-03-07 12:34:19] [INFO] (MainThread) event_response status_code 200
Traceback (most recent call last):
  File "/synology_surveillance_motion_mqtt_gifs.py", line 290, in <module>
    main()
  File "/synology_surveillance_motion_mqtt_gifs.py", line 281, in main
    camera_handler.poll_event()
  File "/synology_surveillance_motion_mqtt_gifs.py", line 210, in poll_event
    event_id = syno_last_event(self.base_url, self.camera["id"], self.sid)
  File "/synology_surveillance_motion_mqtt_gifs.py", line 125, in syno_last_event
    if event_data["data"]["events"][0]["cameraId"] == camera_id:
IndexError: list index out of range

My config.json:

{
  "mqtt_server": "192.168.x.x",
  "mqtt_port": 1883,
  "mqtt_user": "homeassistant",
  "mqtt_pwd": "pw",
  "mqtt_base_topic": "synology/cameras/gifs",
  "ffmpeg_working_folder": "./gifs",
  "synology_base_api_url": "https://synology-ip:5001",
  "synology_user": "user",
  "synology_password": "pw",
  "synology_cameras": [
    {
      "id": 1,
      "skip_first_n_secs": 5,
      "max_length_secs": 5,
      "scale": 320,
      "topic_name": "Main Entrance"
    }
  ]
}

Any hints what I am doing wrong?

@fabtesta
Copy link
Owner

fabtesta commented Mar 7, 2019

@fabtesta fabtesta self-assigned this Mar 7, 2019
@fabtesta
Copy link
Owner

fabtesta commented Mar 7, 2019

@tonyp I have closed the issue adding a length check on events array response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants