{"action":"created","comment":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments/128265066","pull_request_review_id":50928220,"id":128265066,"diff_hunk":"@@ -0,0 +1,1140 @@\n+\"\"\"\n+Connection to Tahoma API.\n+\n+Connection to Somfy Tahoma REST API\n+\"\"\"\n+\n+import json\n+import requests\n+\n+from homeassistant.exceptions import HomeAssistantError\n+\n+BASE_URL = 'https://www.tahomalink.com/enduser-mobile-web/externalAPI/json/'\n+BASE_HEADERS = {'User-Agent': 'mine'}\n+\n+\n+class TahomaApi:\n+    \"\"\"Connection to Tahoma API.\"\"\"\n+\n+    def __init__(self, userName, userPassword, **kwargs):\n+        \"\"\"Initalize the Tahoma protocol.\n+\n+        :param userName: Tahoma username\n+        :param userPassword: Password\n+        :param kwargs: Ignore, only for unit test reasons\n+        \"\"\"\n+        self.__devices = {}\n+        self.__gateway = {}\n+        self.__location = {}\n+        self.__cookie = \"\"\n+        self.__loggedIn = False\n+        self.__username = userName\n+        self.__password = userPassword\n+        self.login()\n+\n+    def login(self):\n+        \"\"\"Login to Tahoma API.\"\"\"\n+        if self.__loggedIn:\n+            return\n+        login = {'userId': self.__username, 'userPassword': self.__password}\n+        header = BASE_HEADERS.copy()\n+        request = requests.post(BASE_URL + 'login',\n+            data=login, headers=header, timeout=10)\n+\n+        try:\n+            result = request.json()\n+        except ValueError as e:\n+            raise HomeAssistantError(\n+                    \"Not a valid result for login, \" +\n+                    \"protocol error: \" + request.status_code + ' - ' +\n+                    request.reason + \"(\" + e + \")\")\n+\n+        if 'error' in result.keys():\n+            raise HomeAssistantError(\"Could not login: \" + result['error'])\n+\n+        if request.status_code != 200:\n+            raise HomeAssistantError(\n+                    \"Could not login, HTTP code: \" +\n+                    str(request.status_code) + ' - ' + request.reason)\n+\n+        if 'success' not in result.keys() or not result['success']:\n+            raise HomeAssistantError(\"Could not login, no success\")\n+\n+        cookie = request.headers.get(\"set-cookie\")\n+        if cookie is None:\n+            raise HomeAssistantError(\"Could not login, no cookie set\")\n+\n+        self.__cookie = cookie\n+        self.__loggedIn = True\n+        return self.__loggedIn\n+\n+    def getUser(self):\n+        \"\"\"Get the user informations from the server.\n+\n+        :return: a dict with all the informations\n+        :rtype: dict\n+\n+        raises ValueError in case of protocol issues\n+\n+        :Example:\n+\n+        >>> \"creationTime\": <time>,\n+        >>> \"lastUpdateTime\": <time>,\n+        >>> \"userId\": \"<email for login>\",\n+        >>> \"title\": 0,\n+        >>> \"firstName\": \"<First>\",\n+        >>> \"lastName\": \"<Last>\",\n+        >>> \"email\": \"<contact email>\",\n+        >>> \"phoneNumber\": \"<phone>\",\n+        >>> \"mobilePhone\": \"<mobile>\",\n+        >>> \"locale\": \"<two char country code>\"\n+\n+        :Warning:\n+\n+        The type and amount of values in the dictionary can change any time.\n+        \"\"\"\n+        header = BASE_HEADERS.copy()\n+        header['Cookie'] = self.__cookie\n+\n+        request = requests.get(BASE_URL + 'getEndUser', headers=header,\n+                                timeout=10)\n+\n+        if request.status_code != 200:\n+            self.__loggedIn = False\n+            self.login()\n+            self.getUser()\n+            return\n+\n+        try:\n+            result = request.json()\n+        except ValueError:\n+            raise HomeAssistantError(\n+                \"Not a valid result for getEndUser, protocol error!\")\n+\n+        return result['endUser']\n+\n+    def getSetup(self):\n+        \"\"\"Load the setup from the server.\n+\n+        Loads the configuration from the server, nothing will\n+        be returned. After loading the configuration the devices\n+        can be obtained through getDevice and getDevices.\n+        Also location and gateway will be set through this\n+        method.\n+\n+        raises ValueError in case of protocol issues\n+\n+        :Seealso:\n+\n+        - getDevice\n+        - getDevices\n+        - location\n+        - gateway\n+        \"\"\"\n+        header = BASE_HEADERS.copy()\n+        header['Cookie'] = self.__cookie\n+\n+        request = requests.get(BASE_URL + 'getSetup', headers=header,\n+                                timeout=10)","path":"homeassistant/components/tahoma_api.py","position":138,"original_position":138,"commit_id":"f4d1d5b994798841d06c58ff0fbacc1d332c6205","original_commit_id":"f4d1d5b994798841d06c58ff0fbacc1d332c6205","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars0.githubusercontent.com/u/6697940?v=4","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"continuation line over-indented for visual indent","created_at":"2017-07-19T14:36:30Z","updated_at":"2017-07-19T14:36:31Z","html_url":"https://github.com/home-assistant/home-assistant/pull/8338#discussion_r128265066","pull_request_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/8338","_links":{"self":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments/128265066"},"html":{"href":"https://github.com/home-assistant/home-assistant/pull/8338#discussion_r128265066"},"pull_request":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/8338"}}},"pull_request":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/8338","id":128790812,"html_url":"https://github.com/home-assistant/home-assistant/pull/8338","diff_url":"https://github.com/home-assistant/home-assistant/pull/8338.diff","patch_url":"https://github.com/home-assistant/home-assistant/pull/8338.patch","issue_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/8338","number":8338,"state":"open","locked":false,"title":"Added new platform somfy tahoma covers and senors","user":{"login":"philklei","id":591869,"avatar_url":"https://avatars1.githubusercontent.com/u/591869?v=4","gravatar_id":"","url":"https://api.github.com/users/philklei","html_url":"https://github.com/philklei","followers_url":"https://api.github.com/users/philklei/followers","following_url":"https://api.github.com/users/philklei/following{/other_user}","gists_url":"https://api.github.com/users/philklei/gists{/gist_id}","starred_url":"https://api.github.com/users/philklei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philklei/subscriptions","organizations_url":"https://api.github.com/users/philklei/orgs","repos_url":"https://api.github.com/users/philklei/repos","events_url":"https://api.github.com/users/philklei/events{/privacy}","received_events_url":"https://api.github.com/users/philklei/received_events","type":"User","site_admin":false},"body":"## Description:\r\n\r\nAdded tahoma plattform to home assistant\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#3002\r\n\r\n## Example entry for `configuration.yaml` (if applicable):\r\n```yaml\r\nsensor:\r\n  - platform: tahoma\r\n\r\n#tahoma\r\ntahoma:\r\n  username: \"<your.tahoma.login.email>\"\r\n  password: \"<your.tahoma.login.password>!\"\r\n  exclude: [BridgeHUEComponent, HueLampHUEComponent, PodComponent]\r\n\r\ncover:\r\n  platform: tahoma\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\nIf the code does not interact with devices:\r\n  - [ ] Local tests with `tox` run successfully. **Your PR cannot be merged unless tests pass**\r\n  - [ ] Tests have been added to verify that the new code works.\r\n\r\n[ex-requir]: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/keyboard.py#L14\r\n[ex-import]: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/keyboard.py#L54\r\n","created_at":"2017-07-04T12:18:53Z","updated_at":"2017-07-19T14:36:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"66d112e80cde5265f9cacf07e5b95a2184fb5be6","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/8338/commits","review_comments_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/8338/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/8338/comments","statuses_url":"https://api.github.com/repos/home-assistant/home-assistant/statuses/f4d1d5b994798841d06c58ff0fbacc1d332c6205","head":{"label":"philklei:tahoma-plattform","ref":"tahoma-plattform","sha":"f4d1d5b994798841d06c58ff0fbacc1d332c6205","user":{"login":"philklei","id":591869,"avatar_url":"https://avatars1.githubusercontent.com/u/591869?v=4","gravatar_id":"","url":"https://api.github.com/users/philklei","html_url":"https://github.com/philklei","followers_url":"https://api.github.com/users/philklei/followers","following_url":"https://api.github.com/users/philklei/following{/other_user}","gists_url":"https://api.github.com/users/philklei/gists{/gist_id}","starred_url":"https://api.github.com/users/philklei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philklei/subscriptions","organizations_url":"https://api.github.com/users/philklei/orgs","repos_url":"https://api.github.com/users/philklei/repos","events_url":"https://api.github.com/users/philklei/events{/privacy}","received_events_url":"https://api.github.com/users/philklei/received_events","type":"User","site_admin":false},"repo":{"id":95631465,"name":"home-assistant","full_name":"philklei/home-assistant","owner":{"login":"philklei","id":591869,"avatar_url":"https://avatars1.githubusercontent.com/u/591869?v=4","gravatar_id":"","url":"https://api.github.com/users/philklei","html_url":"https://github.com/philklei","followers_url":"https://api.github.com/users/philklei/followers","following_url":"https://api.github.com/users/philklei/following{/other_user}","gists_url":"https://api.github.com/users/philklei/gists{/gist_id}","starred_url":"https://api.github.com/users/philklei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philklei/subscriptions","organizations_url":"https://api.github.com/users/philklei/orgs","repos_url":"https://api.github.com/users/philklei/repos","events_url":"https://api.github.com/users/philklei/events{/privacy}","received_events_url":"https://api.github.com/users/philklei/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/philklei/home-assistant","description":":house_with_garden: Open-source home automation platform running on Python 3","fork":true,"url":"https://api.github.com/repos/philklei/home-assistant","forks_url":"https://api.github.com/repos/philklei/home-assistant/forks","keys_url":"https://api.github.com/repos/philklei/home-assistant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/philklei/home-assistant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/philklei/home-assistant/teams","hooks_url":"https://api.github.com/repos/philklei/home-assistant/hooks","issue_events_url":"https://api.github.com/repos/philklei/home-assistant/issues/events{/number}","events_url":"https://api.github.com/repos/philklei/home-assistant/events","assignees_url":"https://api.github.com/repos/philklei/home-assistant/assignees{/user}","branches_url":"https://api.github.com/repos/philklei/home-assistant/branches{/branch}","tags_url":"https://api.github.com/repos/philklei/home-assistant/tags","blobs_url":"https://api.github.com/repos/philklei/home-assistant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/philklei/home-assistant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/philklei/home-assistant/git/refs{/sha}","trees_url":"https://api.github.com/repos/philklei/home-assistant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/philklei/home-assistant/statuses/{sha}","languages_url":"https://api.github.com/repos/philklei/home-assistant/languages","stargazers_url":"https://api.github.com/repos/philklei/home-assistant/stargazers","contributors_url":"https://api.github.com/repos/philklei/home-assistant/contributors","subscribers_url":"https://api.github.com/repos/philklei/home-assistant/subscribers","subscription_url":"https://api.github.com/repos/philklei/home-assistant/subscription","commits_url":"https://api.github.com/repos/philklei/home-assistant/commits{/sha}","git_commits_url":"https://api.github.com/repos/philklei/home-assistant/git/commits{/sha}","comments_url":"https://api.github.com/repos/philklei/home-assistant/comments{/number}","issue_comment_url":"https://api.github.com/repos/philklei/home-assistant/issues/comments{/number}","contents_url":"https://api.github.com/repos/philklei/home-assistant/contents/{+path}","compare_url":"https://api.github.com/repos/philklei/home-assistant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/philklei/home-assistant/merges","archive_url":"https://api.github.com/repos/philklei/home-assistant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/philklei/home-assistant/downloads","issues_url":"https://api.github.com/repos/philklei/home-assistant/issues{/number}","pulls_url":"https://api.github.com/repos/philklei/home-assistant/pulls{/number}","milestones_url":"https://api.github.com/repos/philklei/home-assistant/milestones{/number}","notifications_url":"https://api.github.com/repos/philklei/home-assistant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/philklei/home-assistant/labels{/name}","releases_url":"https://api.github.com/repos/philklei/home-assistant/releases{/id}","deployments_url":"https://api.github.com/repos/philklei/home-assistant/deployments","created_at":"2017-06-28T05:22:13Z","updated_at":"2017-06-28T05:22:20Z","pushed_at":"2017-07-19T14:36:09Z","git_url":"git://github.com/philklei/home-assistant.git","ssh_url":"git@github.com:philklei/home-assistant.git","clone_url":"https://github.com/philklei/home-assistant.git","svn_url":"https://github.com/philklei/home-assistant","homepage":"https://home-assistant.io","size":65161,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"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":"2e17d0926a52d3e57a7dc8cc5bffca1af8e35561","user":{"login":"home-assistant","id":13844975,"avatar_url":"https://avatars3.githubusercontent.com/u/13844975?v=4","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://avatars3.githubusercontent.com/u/13844975?v=4","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-07-19T14:33:12Z","pushed_at":"2017-07-19T14:36:14Z","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":66985,"stargazers_count":7435,"watchers_count":7435,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2251,"mirror_url":null,"open_issues_count":438,"forks":2251,"open_issues":438,"watchers":7435,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/8338"},"html":{"href":"https://github.com/home-assistant/home-assistant/pull/8338"},"issue":{"href":"https://api.github.com/repos/home-assistant/home-assistant/issues/8338"},"comments":{"href":"https://api.github.com/repos/home-assistant/home-assistant/issues/8338/comments"},"review_comments":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/8338/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/8338/commits"},"statuses":{"href":"https://api.github.com/repos/home-assistant/home-assistant/statuses/f4d1d5b994798841d06c58ff0fbacc1d332c6205"}}}}
{"actor":{"display_login":"houndci-bot"}}