{"action":"created","comment":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments/176955591","pull_request_review_id":106744960,"id":176955591,"diff_hunk":"@@ -1276,6 +1356,158 @@ def async_api_previous(hass, config, request, entity):\n     return api_message(request)\n \n \n+def api_error_temp_range(request, temp, min_temp, max_temp, unit):\n+    \"\"\"Create temperature value out of range API error response.\n+\n+    Async friendly.\n+    \"\"\"\n+    temp_range = {\n+        'minimumValue': {\n+            'value': min_temp,\n+            'scale': API_TEMP_UNITS[unit],\n+        },\n+        'maximumValue': {\n+            'value': max_temp,\n+            'scale': API_TEMP_UNITS[unit],\n+        },\n+    }\n+\n+    msg = 'The requested temperature {} is out of range'.format(temp)\n+    _LOGGER.info(msg)\n+    return api_error(\n+        request,\n+        error_type='TEMPERATURE_VALUE_OUT_OF_RANGE',\n+        error_message=msg,\n+        payload={'validRange': temp_range},\n+    )\n+\n+\n+def temperature_from_object(temp_obj, to_unit, absolute=True):\n+    \"\"\"Get temperature from Temperature object in requested unit.\"\"\"\n+    from_unit = TEMP_CELSIUS\n+    temp = float(temp_obj['value'])\n+\n+    if temp_obj['scale'] == 'FAHRENHEIT':\n+        from_unit = TEMP_FAHRENHEIT\n+    elif temp_obj['scale'] == 'KELVIN':\n+        # convert to Celsius if absolute temperature\n+        if absolute:\n+            temp -= 273.15\n+\n+    if not absolute:\n+        if from_unit != to_unit:\n+            if from_unit == TEMP_FAHRENHEIT:\n+                return temp / 1.8","path":"homeassistant/components/alexa/smart_home.py","position":197,"original_position":197,"commit_id":"b69f538dad366fdad5617802f6232bbd4adc3709","original_commit_id":"b69f538dad366fdad5617802f6232bbd4adc3709","user":{"login":"trisk","id":207920,"avatar_url":"https://avatars3.githubusercontent.com/u/207920?v=4","gravatar_id":"","url":"https://api.github.com/users/trisk","html_url":"https://github.com/trisk","followers_url":"https://api.github.com/users/trisk/followers","following_url":"https://api.github.com/users/trisk/following{/other_user}","gists_url":"https://api.github.com/users/trisk/gists{/gist_id}","starred_url":"https://api.github.com/users/trisk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trisk/subscriptions","organizations_url":"https://api.github.com/users/trisk/orgs","repos_url":"https://api.github.com/users/trisk/repos","events_url":"https://api.github.com/users/trisk/events{/privacy}","received_events_url":"https://api.github.com/users/trisk/received_events","type":"User","site_admin":false},"body":"I already use `homeassistant.util.temperature.convert` (as `convert_temperature`) for conversions at the bottom of that function. For `AdjustTemperature` calls I can't pass the `targetSetpointDelta` value directly to `convert` since it will be adjusted for the C/F zero points, so I hardcodeed the scale conversion here. The alternative is to convert the current temperature to the same unit as the delta, add the delta, and convert the result back, which is more expensive (and may cost some precision).","created_at":"2018-03-25T21:51:44Z","updated_at":"2018-03-25T21:51:44Z","html_url":"https://github.com/home-assistant/home-assistant/pull/13340#discussion_r176955591","pull_request_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/13340","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments/176955591"},"html":{"href":"https://github.com/home-assistant/home-assistant/pull/13340#discussion_r176955591"},"pull_request":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/13340"}},"in_reply_to_id":176953604},"pull_request":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/13340","id":176005037,"html_url":"https://github.com/home-assistant/home-assistant/pull/13340","diff_url":"https://github.com/home-assistant/home-assistant/pull/13340.diff","patch_url":"https://github.com/home-assistant/home-assistant/pull/13340.patch","issue_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/13340","number":13340,"state":"open","locked":false,"title":"Implement thermostat support for Alexa","user":{"login":"trisk","id":207920,"avatar_url":"https://avatars3.githubusercontent.com/u/207920?v=4","gravatar_id":"","url":"https://api.github.com/users/trisk","html_url":"https://github.com/trisk","followers_url":"https://api.github.com/users/trisk/followers","following_url":"https://api.github.com/users/trisk/following{/other_user}","gists_url":"https://api.github.com/users/trisk/gists{/gist_id}","starred_url":"https://api.github.com/users/trisk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trisk/subscriptions","organizations_url":"https://api.github.com/users/trisk/orgs","repos_url":"https://api.github.com/users/trisk/repos","events_url":"https://api.github.com/users/trisk/events{/privacy}","received_events_url":"https://api.github.com/users/trisk/received_events","type":"User","site_admin":false},"body":"## Description:\r\nThis provides full Alexa.ThermostatController support for thermostats with multiple setpoints. These entities also support the Alexa.TemperatureSensor interface for reporting the current temperature.\r\n\r\n## Example entry for `configuration.yaml` (if applicable):\r\n```yaml\r\nalexa:\r\n  smart_home:\r\n    filter:\r\n      include_domains:\r\n        - climate\r\n```\r\n\r\n## Checklist:\r\n  - [x] The code change is tested and works locally.\r\n  - [x] Local tests pass with `tox`. **Your PR cannot be merged unless tests pass**\r\n\r\nIf the code does not interact with devices:\r\n  - [x] Tests have been added to verify that the new code works.","created_at":"2018-03-19T19:41:30Z","updated_at":"2018-03-25T21:51:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"05891ded183a9dc9e5d2e828fbcc346b5e1bf85a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":527871105,"url":"https://api.github.com/repos/home-assistant/home-assistant/labels/cla-signed","name":"cla-signed","color":"008000","default":false},{"id":603007238,"url":"https://api.github.com/repos/home-assistant/home-assistant/labels/component:%20alexa","name":"component: alexa","color":"ededed","default":false},{"id":451931292,"url":"https://api.github.com/repos/home-assistant/home-assistant/labels/core","name":"core","color":"c5def5","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/13340/commits","review_comments_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/13340/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/13340/comments","statuses_url":"https://api.github.com/repos/home-assistant/home-assistant/statuses/b69f538dad366fdad5617802f6232bbd4adc3709","head":{"label":"trisk:alexa_thermostat","ref":"alexa_thermostat","sha":"b69f538dad366fdad5617802f6232bbd4adc3709","user":{"login":"trisk","id":207920,"avatar_url":"https://avatars3.githubusercontent.com/u/207920?v=4","gravatar_id":"","url":"https://api.github.com/users/trisk","html_url":"https://github.com/trisk","followers_url":"https://api.github.com/users/trisk/followers","following_url":"https://api.github.com/users/trisk/following{/other_user}","gists_url":"https://api.github.com/users/trisk/gists{/gist_id}","starred_url":"https://api.github.com/users/trisk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trisk/subscriptions","organizations_url":"https://api.github.com/users/trisk/orgs","repos_url":"https://api.github.com/users/trisk/repos","events_url":"https://api.github.com/users/trisk/events{/privacy}","received_events_url":"https://api.github.com/users/trisk/received_events","type":"User","site_admin":false},"repo":{"id":75620375,"name":"home-assistant","full_name":"trisk/home-assistant","owner":{"login":"trisk","id":207920,"avatar_url":"https://avatars3.githubusercontent.com/u/207920?v=4","gravatar_id":"","url":"https://api.github.com/users/trisk","html_url":"https://github.com/trisk","followers_url":"https://api.github.com/users/trisk/followers","following_url":"https://api.github.com/users/trisk/following{/other_user}","gists_url":"https://api.github.com/users/trisk/gists{/gist_id}","starred_url":"https://api.github.com/users/trisk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trisk/subscriptions","organizations_url":"https://api.github.com/users/trisk/orgs","repos_url":"https://api.github.com/users/trisk/repos","events_url":"https://api.github.com/users/trisk/events{/privacy}","received_events_url":"https://api.github.com/users/trisk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/trisk/home-assistant","description":":house_with_garden: Open-source home automation platform running on Python 3","fork":true,"url":"https://api.github.com/repos/trisk/home-assistant","forks_url":"https://api.github.com/repos/trisk/home-assistant/forks","keys_url":"https://api.github.com/repos/trisk/home-assistant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/trisk/home-assistant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/trisk/home-assistant/teams","hooks_url":"https://api.github.com/repos/trisk/home-assistant/hooks","issue_events_url":"https://api.github.com/repos/trisk/home-assistant/issues/events{/number}","events_url":"https://api.github.com/repos/trisk/home-assistant/events","assignees_url":"https://api.github.com/repos/trisk/home-assistant/assignees{/user}","branches_url":"https://api.github.com/repos/trisk/home-assistant/branches{/branch}","tags_url":"https://api.github.com/repos/trisk/home-assistant/tags","blobs_url":"https://api.github.com/repos/trisk/home-assistant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/trisk/home-assistant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/trisk/home-assistant/git/refs{/sha}","trees_url":"https://api.github.com/repos/trisk/home-assistant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/trisk/home-assistant/statuses/{sha}","languages_url":"https://api.github.com/repos/trisk/home-assistant/languages","stargazers_url":"https://api.github.com/repos/trisk/home-assistant/stargazers","contributors_url":"https://api.github.com/repos/trisk/home-assistant/contributors","subscribers_url":"https://api.github.com/repos/trisk/home-assistant/subscribers","subscription_url":"https://api.github.com/repos/trisk/home-assistant/subscription","commits_url":"https://api.github.com/repos/trisk/home-assistant/commits{/sha}","git_commits_url":"https://api.github.com/repos/trisk/home-assistant/git/commits{/sha}","comments_url":"https://api.github.com/repos/trisk/home-assistant/comments{/number}","issue_comment_url":"https://api.github.com/repos/trisk/home-assistant/issues/comments{/number}","contents_url":"https://api.github.com/repos/trisk/home-assistant/contents/{+path}","compare_url":"https://api.github.com/repos/trisk/home-assistant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/trisk/home-assistant/merges","archive_url":"https://api.github.com/repos/trisk/home-assistant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/trisk/home-assistant/downloads","issues_url":"https://api.github.com/repos/trisk/home-assistant/issues{/number}","pulls_url":"https://api.github.com/repos/trisk/home-assistant/pulls{/number}","milestones_url":"https://api.github.com/repos/trisk/home-assistant/milestones{/number}","notifications_url":"https://api.github.com/repos/trisk/home-assistant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/trisk/home-assistant/labels{/name}","releases_url":"https://api.github.com/repos/trisk/home-assistant/releases{/id}","deployments_url":"https://api.github.com/repos/trisk/home-assistant/deployments","created_at":"2016-12-05T11:56:45Z","updated_at":"2016-12-05T11:56:49Z","pushed_at":"2018-03-25T19:22:15Z","git_url":"git://github.com/trisk/home-assistant.git","ssh_url":"git@github.com:trisk/home-assistant.git","clone_url":"https://github.com/trisk/home-assistant.git","svn_url":"https://github.com/trisk/home-assistant","homepage":"https://home-assistant.io","size":80012,"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,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"home-assistant:dev","ref":"dev","sha":"b99663296592f6c8c480b02bdd4d08d7088cc291","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":"2018-03-25T21:32:34Z","pushed_at":"2018-03-25T21:32: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":80199,"stargazers_count":13400,"watchers_count":13400,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3898,"mirror_url":null,"archived":false,"open_issues_count":838,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":3898,"open_issues":838,"watchers":13400,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/13340"},"html":{"href":"https://github.com/home-assistant/home-assistant/pull/13340"},"issue":{"href":"https://api.github.com/repos/home-assistant/home-assistant/issues/13340"},"comments":{"href":"https://api.github.com/repos/home-assistant/home-assistant/issues/13340/comments"},"review_comments":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/13340/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/13340/commits"},"statuses":{"href":"https://api.github.com/repos/home-assistant/home-assistant/statuses/b69f538dad366fdad5617802f6232bbd4adc3709"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"trisk"}}