{"action":"created","comment":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments/101473689","pull_request_review_id":22202171,"id":101473689,"diff_hunk":"@@ -0,0 +1,152 @@\n+\"\"\"\n+Support for aurora forecast data sensor.\n+\n+For more details about this platform, please refer to the documentation at\n+https://home-assistant.io/components/binary_sensor.aurora/\n+\"\"\"\n+import logging\n+from datetime import timedelta\n+import requests\n+import voluptuous as vol\n+from homeassistant.util import Throttle\n+from homeassistant.components.binary_sensor \\\n+    import (BinarySensorDevice, PLATFORM_SCHEMA)\n+from homeassistant.const import (CONF_NAME)\n+import homeassistant.helpers.config_validation as cv\n+\n+CONF_THRESHOLD = \"forecast_threshold\"\n+\n+_LOGGER = logging.getLogger(__name__)\n+\n+DEFAULT_NAME = 'Aurora Visibility'\n+DEFAULT_SENSOR_CLASS = \"visible\"\n+DEFAULT_THRESHOLD = 75\n+\n+MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=5)\n+\n+PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({\n+    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,\n+    vol.Optional(CONF_THRESHOLD, default=DEFAULT_THRESHOLD): cv.positive_int,\n+})\n+\n+\n+def setup_platform(hass, config, add_devices, discovery_info=None):\n+    \"\"\"Set up the aurora sensor.\"\"\"\n+    if None in (hass.config.latitude, hass.config.longitude):\n+        _LOGGER.error(\"Lat. or long. not set in Home Assistant config\")\n+        return False\n+\n+    name = config.get(CONF_NAME)\n+    threshold = config.get(CONF_THRESHOLD)\n+\n+    try:\n+        aurora_data = AuroraData(\n+            hass.config.latitude,\n+            hass.config.longitude,\n+            threshold\n+        )\n+        aurora_data.update()\n+    except requests.exceptions.HTTPError as error:\n+        _LOGGER.error(error)\n+        return False\n+\n+    add_devices([AuroraSensor(aurora_data, name)], True)\n+\n+\n+class AuroraSensor(BinarySensorDevice):\n+    \"\"\"Implementation of an aurora sensor.\"\"\"\n+\n+    def __init__(self, aurora_data, name):\n+        \"\"\"Initialize the sensor.\"\"\"\n+        self.aurora_data = aurora_data\n+        self._name = name\n+        self.update()","path":"homeassistant/components/binary_sensor/aurora.py","position":63,"original_position":63,"commit_id":"2115397c57131ed4634716d9bdfb6d8c507fa4a0","original_commit_id":"2115397c57131ed4634716d9bdfb6d8c507fa4a0","user":{"login":"pvizeli","id":15338540,"avatar_url":"https://avatars.githubusercontent.com/u/15338540?v=3","gravatar_id":"","url":"https://api.github.com/users/pvizeli","html_url":"https://github.com/pvizeli","followers_url":"https://api.github.com/users/pvizeli/followers","following_url":"https://api.github.com/users/pvizeli/following{/other_user}","gists_url":"https://api.github.com/users/pvizeli/gists{/gist_id}","starred_url":"https://api.github.com/users/pvizeli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pvizeli/subscriptions","organizations_url":"https://api.github.com/users/pvizeli/orgs","repos_url":"https://api.github.com/users/pvizeli/repos","events_url":"https://api.github.com/users/pvizeli/events{/privacy}","received_events_url":"https://api.github.com/users/pvizeli/received_events","type":"User","site_admin":false},"body":"not needed, remove it","created_at":"2017-02-16T09:19:32Z","updated_at":"2017-02-16T09:20:27Z","html_url":"https://github.com/home-assistant/home-assistant/pull/6003#discussion_r101473689","pull_request_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/6003","_links":{"self":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments/101473689"},"html":{"href":"https://github.com/home-assistant/home-assistant/pull/6003#discussion_r101473689"},"pull_request":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/6003"}}},"pull_request":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/6003","id":106228748,"html_url":"https://github.com/home-assistant/home-assistant/pull/6003","diff_url":"https://github.com/home-assistant/home-assistant/pull/6003.diff","patch_url":"https://github.com/home-assistant/home-assistant/pull/6003.patch","issue_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/6003","number":6003,"state":"open","locked":false,"title":"Add aurora sensor","user":{"login":"walkerdb","id":7026330,"avatar_url":"https://avatars.githubusercontent.com/u/7026330?v=3","gravatar_id":"","url":"https://api.github.com/users/walkerdb","html_url":"https://github.com/walkerdb","followers_url":"https://api.github.com/users/walkerdb/followers","following_url":"https://api.github.com/users/walkerdb/following{/other_user}","gists_url":"https://api.github.com/users/walkerdb/gists{/gist_id}","starred_url":"https://api.github.com/users/walkerdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/walkerdb/subscriptions","organizations_url":"https://api.github.com/users/walkerdb/orgs","repos_url":"https://api.github.com/users/walkerdb/repos","events_url":"https://api.github.com/users/walkerdb/events{/privacy}","received_events_url":"https://api.github.com/users/walkerdb/received_events","type":"User","site_admin":false},"body":"**Description:**\r\nAdd binary sensor that changes state when auroras are likely visible at your location\r\n\r\nUses 30-minute aurora forecast data provided by the NOAA. See [here](http://www.swpc.noaa.gov/products/aurora-30-minute-forecast) for more details. \r\n\r\n**Related issue (if applicable):** fixes #<home-assistant issue number goes here>\r\n\r\n**Pull request in [home-assistant.github.io](https://github.com/home-assistant/home-assistant.github.io) with documentation (if applicable):** home-assistant/home-assistant.github.io#2049\r\n\r\n**Example entry for `configuration.yaml` (if applicable):**\r\n```yaml\r\nbinary_sensor:\r\n  - platform: aurora\r\n```\r\n\r\n**Checklist:**\r\n\r\nIf user exposed functionality or configuration variables are added/changed:\r\n  - [x] Documentation added/updated in [home-assistant.github.io](https://github.com/home-assistant/home-assistant.github.io)\r\n\r\nIf the code communicates with devices, web services, or third-party tools:\r\n  - [x] Local tests with `tox` run successfully. **Your PR cannot be merged unless tests pass**\r\n  - [x] New dependencies have been added to the `REQUIREMENTS` variable ([example][ex-requir]).\r\n  - [x] New dependencies are only imported inside functions that use them ([example][ex-import]).\r\n  - [x] New dependencies have been added to `requirements_all.txt` by running `script/gen_requirements_all.py`.\r\n  - [x] New files were added to `.coveragerc`.\r\n\r\n[ex-requir]: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/keyboard.py#L16\r\n[ex-import]: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/keyboard.py#L51\r\n","created_at":"2017-02-15T01:42:20Z","updated_at":"2017-02-16T09:20:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c149438d47cf4081c865977c3c52c2223be04924","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/6003/commits","review_comments_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/6003/comments","review_comment_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments{/number}","comments_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/6003/comments","statuses_url":"https://api.github.com/repos/home-assistant/home-assistant/statuses/2115397c57131ed4634716d9bdfb6d8c507fa4a0","head":{"label":"walkerdb:dev","ref":"dev","sha":"2115397c57131ed4634716d9bdfb6d8c507fa4a0","user":{"login":"walkerdb","id":7026330,"avatar_url":"https://avatars.githubusercontent.com/u/7026330?v=3","gravatar_id":"","url":"https://api.github.com/users/walkerdb","html_url":"https://github.com/walkerdb","followers_url":"https://api.github.com/users/walkerdb/followers","following_url":"https://api.github.com/users/walkerdb/following{/other_user}","gists_url":"https://api.github.com/users/walkerdb/gists{/gist_id}","starred_url":"https://api.github.com/users/walkerdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/walkerdb/subscriptions","organizations_url":"https://api.github.com/users/walkerdb/orgs","repos_url":"https://api.github.com/users/walkerdb/repos","events_url":"https://api.github.com/users/walkerdb/events{/privacy}","received_events_url":"https://api.github.com/users/walkerdb/received_events","type":"User","site_admin":false},"repo":{"id":79766482,"name":"home-assistant","full_name":"walkerdb/home-assistant","owner":{"login":"walkerdb","id":7026330,"avatar_url":"https://avatars.githubusercontent.com/u/7026330?v=3","gravatar_id":"","url":"https://api.github.com/users/walkerdb","html_url":"https://github.com/walkerdb","followers_url":"https://api.github.com/users/walkerdb/followers","following_url":"https://api.github.com/users/walkerdb/following{/other_user}","gists_url":"https://api.github.com/users/walkerdb/gists{/gist_id}","starred_url":"https://api.github.com/users/walkerdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/walkerdb/subscriptions","organizations_url":"https://api.github.com/users/walkerdb/orgs","repos_url":"https://api.github.com/users/walkerdb/repos","events_url":"https://api.github.com/users/walkerdb/events{/privacy}","received_events_url":"https://api.github.com/users/walkerdb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/walkerdb/home-assistant","description":":house_with_garden: Open-source home automation platform running on Python 3","fork":true,"url":"https://api.github.com/repos/walkerdb/home-assistant","forks_url":"https://api.github.com/repos/walkerdb/home-assistant/forks","keys_url":"https://api.github.com/repos/walkerdb/home-assistant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/walkerdb/home-assistant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/walkerdb/home-assistant/teams","hooks_url":"https://api.github.com/repos/walkerdb/home-assistant/hooks","issue_events_url":"https://api.github.com/repos/walkerdb/home-assistant/issues/events{/number}","events_url":"https://api.github.com/repos/walkerdb/home-assistant/events","assignees_url":"https://api.github.com/repos/walkerdb/home-assistant/assignees{/user}","branches_url":"https://api.github.com/repos/walkerdb/home-assistant/branches{/branch}","tags_url":"https://api.github.com/repos/walkerdb/home-assistant/tags","blobs_url":"https://api.github.com/repos/walkerdb/home-assistant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/walkerdb/home-assistant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/walkerdb/home-assistant/git/refs{/sha}","trees_url":"https://api.github.com/repos/walkerdb/home-assistant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/walkerdb/home-assistant/statuses/{sha}","languages_url":"https://api.github.com/repos/walkerdb/home-assistant/languages","stargazers_url":"https://api.github.com/repos/walkerdb/home-assistant/stargazers","contributors_url":"https://api.github.com/repos/walkerdb/home-assistant/contributors","subscribers_url":"https://api.github.com/repos/walkerdb/home-assistant/subscribers","subscription_url":"https://api.github.com/repos/walkerdb/home-assistant/subscription","commits_url":"https://api.github.com/repos/walkerdb/home-assistant/commits{/sha}","git_commits_url":"https://api.github.com/repos/walkerdb/home-assistant/git/commits{/sha}","comments_url":"https://api.github.com/repos/walkerdb/home-assistant/comments{/number}","issue_comment_url":"https://api.github.com/repos/walkerdb/home-assistant/issues/comments{/number}","contents_url":"https://api.github.com/repos/walkerdb/home-assistant/contents/{+path}","compare_url":"https://api.github.com/repos/walkerdb/home-assistant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/walkerdb/home-assistant/merges","archive_url":"https://api.github.com/repos/walkerdb/home-assistant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/walkerdb/home-assistant/downloads","issues_url":"https://api.github.com/repos/walkerdb/home-assistant/issues{/number}","pulls_url":"https://api.github.com/repos/walkerdb/home-assistant/pulls{/number}","milestones_url":"https://api.github.com/repos/walkerdb/home-assistant/milestones{/number}","notifications_url":"https://api.github.com/repos/walkerdb/home-assistant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/walkerdb/home-assistant/labels{/name}","releases_url":"https://api.github.com/repos/walkerdb/home-assistant/releases{/id}","deployments_url":"https://api.github.com/repos/walkerdb/home-assistant/deployments","created_at":"2017-01-23T03:30:13Z","updated_at":"2017-01-23T03:30:19Z","pushed_at":"2017-02-16T00:02:34Z","git_url":"git://github.com/walkerdb/home-assistant.git","ssh_url":"git@github.com:walkerdb/home-assistant.git","clone_url":"https://github.com/walkerdb/home-assistant.git","svn_url":"https://github.com/walkerdb/home-assistant","homepage":"https://home-assistant.io","size":52123,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"home-assistant:dev","ref":"dev","sha":"5895f431b405ed696f9637155046c46c759f149d","user":{"login":"home-assistant","id":13844975,"avatar_url":"https://avatars.githubusercontent.com/u/13844975?v=3","gravatar_id":"","url":"https://api.github.com/users/home-assistant","html_url":"https://github.com/home-assistant","followers_url":"https://api.github.com/users/home-assistant/followers","following_url":"https://api.github.com/users/home-assistant/following{/other_user}","gists_url":"https://api.github.com/users/home-assistant/gists{/gist_id}","starred_url":"https://api.github.com/users/home-assistant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/home-assistant/subscriptions","organizations_url":"https://api.github.com/users/home-assistant/orgs","repos_url":"https://api.github.com/users/home-assistant/repos","events_url":"https://api.github.com/users/home-assistant/events{/privacy}","received_events_url":"https://api.github.com/users/home-assistant/received_events","type":"Organization","site_admin":false},"repo":{"id":12888993,"name":"home-assistant","full_name":"home-assistant/home-assistant","owner":{"login":"home-assistant","id":13844975,"avatar_url":"https://avatars.githubusercontent.com/u/13844975?v=3","gravatar_id":"","url":"https://api.github.com/users/home-assistant","html_url":"https://github.com/home-assistant","followers_url":"https://api.github.com/users/home-assistant/followers","following_url":"https://api.github.com/users/home-assistant/following{/other_user}","gists_url":"https://api.github.com/users/home-assistant/gists{/gist_id}","starred_url":"https://api.github.com/users/home-assistant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/home-assistant/subscriptions","organizations_url":"https://api.github.com/users/home-assistant/orgs","repos_url":"https://api.github.com/users/home-assistant/repos","events_url":"https://api.github.com/users/home-assistant/events{/privacy}","received_events_url":"https://api.github.com/users/home-assistant/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/home-assistant/home-assistant","description":":house_with_garden: Open-source home automation platform running on Python 3","fork":false,"url":"https://api.github.com/repos/home-assistant/home-assistant","forks_url":"https://api.github.com/repos/home-assistant/home-assistant/forks","keys_url":"https://api.github.com/repos/home-assistant/home-assistant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/home-assistant/home-assistant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/home-assistant/home-assistant/teams","hooks_url":"https://api.github.com/repos/home-assistant/home-assistant/hooks","issue_events_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/events{/number}","events_url":"https://api.github.com/repos/home-assistant/home-assistant/events","assignees_url":"https://api.github.com/repos/home-assistant/home-assistant/assignees{/user}","branches_url":"https://api.github.com/repos/home-assistant/home-assistant/branches{/branch}","tags_url":"https://api.github.com/repos/home-assistant/home-assistant/tags","blobs_url":"https://api.github.com/repos/home-assistant/home-assistant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/home-assistant/home-assistant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/home-assistant/home-assistant/git/refs{/sha}","trees_url":"https://api.github.com/repos/home-assistant/home-assistant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/home-assistant/home-assistant/statuses/{sha}","languages_url":"https://api.github.com/repos/home-assistant/home-assistant/languages","stargazers_url":"https://api.github.com/repos/home-assistant/home-assistant/stargazers","contributors_url":"https://api.github.com/repos/home-assistant/home-assistant/contributors","subscribers_url":"https://api.github.com/repos/home-assistant/home-assistant/subscribers","subscription_url":"https://api.github.com/repos/home-assistant/home-assistant/subscription","commits_url":"https://api.github.com/repos/home-assistant/home-assistant/commits{/sha}","git_commits_url":"https://api.github.com/repos/home-assistant/home-assistant/git/commits{/sha}","comments_url":"https://api.github.com/repos/home-assistant/home-assistant/comments{/number}","issue_comment_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/comments{/number}","contents_url":"https://api.github.com/repos/home-assistant/home-assistant/contents/{+path}","compare_url":"https://api.github.com/repos/home-assistant/home-assistant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/home-assistant/home-assistant/merges","archive_url":"https://api.github.com/repos/home-assistant/home-assistant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/home-assistant/home-assistant/downloads","issues_url":"https://api.github.com/repos/home-assistant/home-assistant/issues{/number}","pulls_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls{/number}","milestones_url":"https://api.github.com/repos/home-assistant/home-assistant/milestones{/number}","notifications_url":"https://api.github.com/repos/home-assistant/home-assistant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/home-assistant/home-assistant/labels{/name}","releases_url":"https://api.github.com/repos/home-assistant/home-assistant/releases{/id}","deployments_url":"https://api.github.com/repos/home-assistant/home-assistant/deployments","created_at":"2013-09-17T07:29:48Z","updated_at":"2017-02-16T07:14:08Z","pushed_at":"2017-02-16T09:12:34Z","git_url":"git://github.com/home-assistant/home-assistant.git","ssh_url":"git@github.com:home-assistant/home-assistant.git","clone_url":"https://github.com/home-assistant/home-assistant.git","svn_url":"https://github.com/home-assistant/home-assistant","homepage":"https://home-assistant.io","size":52308,"stargazers_count":5862,"watchers_count":5862,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1662,"mirror_url":null,"open_issues_count":423,"forks":1662,"open_issues":423,"watchers":5862,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/6003"},"html":{"href":"https://github.com/home-assistant/home-assistant/pull/6003"},"issue":{"href":"https://api.github.com/repos/home-assistant/home-assistant/issues/6003"},"comments":{"href":"https://api.github.com/repos/home-assistant/home-assistant/issues/6003/comments"},"review_comments":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/6003/comments"},"review_comment":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/6003/commits"},"statuses":{"href":"https://api.github.com/repos/home-assistant/home-assistant/statuses/2115397c57131ed4634716d9bdfb6d8c507fa4a0"}}}}
{"actor":{"display_login":"pvizeli"}}