{"action":"created","issue":{"url":"https://api.github.com/repos/balloob/pywemo/issues/8","labels_url":"https://api.github.com/repos/balloob/pywemo/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/balloob/pywemo/issues/8/comments","events_url":"https://api.github.com/repos/balloob/pywemo/issues/8/events","html_url":"https://github.com/balloob/pywemo/issues/8","id":75561769,"number":8,"title":"IndexError: list index out of range","user":{"login":"bastionJersey","id":6375545,"avatar_url":"https://avatars.githubusercontent.com/u/6375545?v=3","gravatar_id":"","url":"https://api.github.com/users/bastionJersey","html_url":"https://github.com/bastionJersey","followers_url":"https://api.github.com/users/bastionJersey/followers","following_url":"https://api.github.com/users/bastionJersey/following{/other_user}","gists_url":"https://api.github.com/users/bastionJersey/gists{/gist_id}","starred_url":"https://api.github.com/users/bastionJersey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bastionJersey/subscriptions","organizations_url":"https://api.github.com/users/bastionJersey/orgs","repos_url":"https://api.github.com/users/bastionJersey/repos","events_url":"https://api.github.com/users/bastionJersey/events{/privacy}","received_events_url":"https://api.github.com/users/bastionJersey/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-12T10:58:55Z","updated_at":"2015-05-13T08:28:32Z","closed_at":"2015-05-13T07:07:56Z","body":"Sometimes I get this error, and the device (a Wemo switch) doesn't toggle: \r\n\r\n`Traceback (most recent call last):\r\n  File \"/Users/adam/Dropbox/computer/wemotoggle.py\", line 4, in <module>\r\n    devices[0].toggle()\r\nIndexError: list index out of range`\r\n\r\nI call a simple shell script from within Applescript on sleep and wake of my Mac Mini, to turn the monitor on and off. This is the script I use: \r\n\r\n```\r\n#!/usr/bin/env python\r\nimport pywemo\r\ndevices = pywemo.discover_devices()\r\ndevices[0].toggle()\r\n```\r\n\r\nAt a guess there's no 0th element because it's not finding my device. It works a fair amount of the time, though. Is this a bug in pywemo, a problem with the Wemo switch, or do I need to add a loop to my shell script to keep calling discover_devices() until it finds one, then call toggle()."},"comment":{"url":"https://api.github.com/repos/balloob/pywemo/issues/comments/101571520","html_url":"https://github.com/balloob/pywemo/issues/8#issuecomment-101571520","issue_url":"https://api.github.com/repos/balloob/pywemo/issues/8","id":101571520,"user":{"login":"bastionJersey","id":6375545,"avatar_url":"https://avatars.githubusercontent.com/u/6375545?v=3","gravatar_id":"","url":"https://api.github.com/users/bastionJersey","html_url":"https://github.com/bastionJersey","followers_url":"https://api.github.com/users/bastionJersey/followers","following_url":"https://api.github.com/users/bastionJersey/following{/other_user}","gists_url":"https://api.github.com/users/bastionJersey/gists{/gist_id}","starred_url":"https://api.github.com/users/bastionJersey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bastionJersey/subscriptions","organizations_url":"https://api.github.com/users/bastionJersey/orgs","repos_url":"https://api.github.com/users/bastionJersey/repos","events_url":"https://api.github.com/users/bastionJersey/events{/privacy}","received_events_url":"https://api.github.com/users/bastionJersey/received_events","type":"User","site_admin":false},"created_at":"2015-05-13T08:28:32Z","updated_at":"2015-05-13T08:28:32Z","body":"That doesn't seem to make any difference; am I doing it wrong? (I tried small numbers like 10 to start with.)\r\n\r\n``devices = pywemo.discover_devices(1000000)``\r\n\r\nIn fact, it doesn't discover my device at all since yesterday. Running from the python interpreter in the terminal. \r\n\r\n```\r\n>>> devices = pywemo.discover_devices()\r\n>>> print devices\r\n[]\r\n>>> \r\n```\r\n\r\nI also have ouimeaux installed and 'wemo list' finds the switch. \r\n\r\n```\r\nwemo list\r\nSwitch: WeMo Switch\r\n```\r\n\r\nI've tried unplugging the switch and plugging it back in, but that doesn't help. Blasted switch is a mystery!"}}