{"action":"created","comment":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments/200410379","pull_request_review_id":134721802,"id":200410379,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMDQxMDM3OQ==","diff_hunk":"@@ -116,7 +118,13 @@ class APIEventStream(HomeAssistantView):\n             _LOGGER.debug(\"STREAM %s ATTACHED\", id(stop_obj))\n \n             # Fire off one message so browsers fire open event right away\n-            await to_write.put(STREAM_PING_PAYLOAD)\n+            if fullstate:\n+                msg = json.dumps(request.app['hass'].states.async_all(),\n+                    cls=rem.JSONEncoder)","path":"homeassistant/components/api.py","position":16,"original_position":16,"commit_id":"34ba47c254002517c1fdd4edd74c4bb787157aa3","original_commit_id":"34ba47c254002517c1fdd4edd74c4bb787157aa3","user":{"login":"houndci-bot","id":6697940,"node_id":"MDQ6VXNlcjY2OTc5NDA=","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 under-indented for visual indent","created_at":"2018-07-05T16:13:47Z","updated_at":"2018-07-05T16:13:47Z","html_url":"https://github.com/home-assistant/home-assistant/pull/15309#discussion_r200410379","pull_request_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/15309","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments/200410379"},"html":{"href":"https://github.com/home-assistant/home-assistant/pull/15309#discussion_r200410379"},"pull_request":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/15309"}}},"pull_request":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/15309","id":199520616,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk5NTIwNjE2","html_url":"https://github.com/home-assistant/home-assistant/pull/15309","diff_url":"https://github.com/home-assistant/home-assistant/pull/15309.diff","patch_url":"https://github.com/home-assistant/home-assistant/pull/15309.patch","issue_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/15309","number":15309,"state":"open","locked":false,"title":"add option to receive fullstate on /api/stream establish","user":{"login":"bahamas10","id":1205722,"node_id":"MDQ6VXNlcjEyMDU3MjI=","avatar_url":"https://avatars3.githubusercontent.com/u/1205722?v=4","gravatar_id":"","url":"https://api.github.com/users/bahamas10","html_url":"https://github.com/bahamas10","followers_url":"https://api.github.com/users/bahamas10/followers","following_url":"https://api.github.com/users/bahamas10/following{/other_user}","gists_url":"https://api.github.com/users/bahamas10/gists{/gist_id}","starred_url":"https://api.github.com/users/bahamas10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bahamas10/subscriptions","organizations_url":"https://api.github.com/users/bahamas10/orgs","repos_url":"https://api.github.com/users/bahamas10/repos","events_url":"https://api.github.com/users/bahamas10/events{/privacy}","received_events_url":"https://api.github.com/users/bahamas10/received_events","type":"User","site_admin":false},"body":"# summary\r\n\r\nThis changes add a GET query parameter to the `/api/stream` endpoint (`fullstate`).  If this parameter is set, the state of all entities will be returned immediately when the stream is established instead of the first ping packet.\r\n\r\n# example\r\n\r\n`GET /api/stream`\r\n\r\n```\r\n$ ./curl-hass /api/stream\r\ndata: ping\r\n\r\n^C\r\n```\r\n\r\n`GET /api/stream?fullstate=true`\r\n```\r\n$ ./curl-hass /api/stream?fullstate=true\r\ndata: [{\"entity_id\": \"zone.home\", \"state\": \"zoning\", \"attributes\": {\"hidden\": true, ...}}] (snipped for brevity)\r\n```\r\n\r\nThe first data packet received is functionally equivalent to the data received by `GET /api/states`\r\n\r\n# reasoning\r\n\r\nI want to make a home assistant dashboard (HTML/CSS/JavaScript) for my home, and want it to consume the stream api for realtime updates.  In order to get the initial state (for when the dashboard first starts), I'd have to hit `/api/states` - this seemed inherently racy to me.  Basically, a connection would have to be made to `/api/states` and `/api/stream` and there is no guarantee which one will be handled first, or if messages would have possibly been lost in the time between 1 connection completed to when both completed.   I *could* create the stream request first, then query the full states, and then try to coalesce that data into 1 view of the current system.\r\n\r\nInstead, I thought it would be easiest for the `/api/stream` endpoint to just dump its current view of the world first, and then give subsequent updates that can be \"applied\" to the original dump so the consumer can always have the most up-to-date view of the entities in the system.\r\n\r\nThis is a new flag, so existing consumers of this endpoint should not be affected.","created_at":"2018-07-05T16:13:38Z","updated_at":"2018-07-05T16:13:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"834ce461d5c8215141fddc34bf8e7beadd3d1a3d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[{"name":"Core","id":2410391,"node_id":"MDQ6VGVhbTI0MTAzOTE=","slug":"core","description":"Developers with knowledge of the Home Assistant core","privacy":"closed","url":"https://api.github.com/teams/2410391","members_url":"https://api.github.com/teams/2410391/members{/member}","repositories_url":"https://api.github.com/teams/2410391/repos","permission":"pull"}],"labels":[{"id":527909495,"node_id":"MDU6TGFiZWw1Mjc5MDk0OTU=","url":"https://api.github.com/repos/home-assistant/home-assistant/labels/cla-needed","name":"cla-needed","color":"ffff00","default":false},{"id":561104835,"node_id":"MDU6TGFiZWw1NjExMDQ4MzU=","url":"https://api.github.com/repos/home-assistant/home-assistant/labels/component:%20api","name":"component: api","color":"ededed","default":false},{"id":955422305,"node_id":"MDU6TGFiZWw5NTU0MjIzMDU=","url":"https://api.github.com/repos/home-assistant/home-assistant/labels/in%20progress","name":"in progress","color":"ededed","default":false},{"id":832964196,"node_id":"MDU6TGFiZWw4MzI5NjQxOTY=","url":"https://api.github.com/repos/home-assistant/home-assistant/labels/small-pr","name":"small-pr","color":"e5bd7e","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/15309/commits","review_comments_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/15309/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/15309/comments","statuses_url":"https://api.github.com/repos/home-assistant/home-assistant/statuses/34ba47c254002517c1fdd4edd74c4bb787157aa3","head":{"label":"bahamas10:dave-1530806652","ref":"dave-1530806652","sha":"34ba47c254002517c1fdd4edd74c4bb787157aa3","user":{"login":"bahamas10","id":1205722,"node_id":"MDQ6VXNlcjEyMDU3MjI=","avatar_url":"https://avatars3.githubusercontent.com/u/1205722?v=4","gravatar_id":"","url":"https://api.github.com/users/bahamas10","html_url":"https://github.com/bahamas10","followers_url":"https://api.github.com/users/bahamas10/followers","following_url":"https://api.github.com/users/bahamas10/following{/other_user}","gists_url":"https://api.github.com/users/bahamas10/gists{/gist_id}","starred_url":"https://api.github.com/users/bahamas10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bahamas10/subscriptions","organizations_url":"https://api.github.com/users/bahamas10/orgs","repos_url":"https://api.github.com/users/bahamas10/repos","events_url":"https://api.github.com/users/bahamas10/events{/privacy}","received_events_url":"https://api.github.com/users/bahamas10/received_events","type":"User","site_admin":false},"repo":{"id":139871815,"node_id":"MDEwOlJlcG9zaXRvcnkxMzk4NzE4MTU=","name":"home-assistant","full_name":"bahamas10/home-assistant","owner":{"login":"bahamas10","id":1205722,"node_id":"MDQ6VXNlcjEyMDU3MjI=","avatar_url":"https://avatars3.githubusercontent.com/u/1205722?v=4","gravatar_id":"","url":"https://api.github.com/users/bahamas10","html_url":"https://github.com/bahamas10","followers_url":"https://api.github.com/users/bahamas10/followers","following_url":"https://api.github.com/users/bahamas10/following{/other_user}","gists_url":"https://api.github.com/users/bahamas10/gists{/gist_id}","starred_url":"https://api.github.com/users/bahamas10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bahamas10/subscriptions","organizations_url":"https://api.github.com/users/bahamas10/orgs","repos_url":"https://api.github.com/users/bahamas10/repos","events_url":"https://api.github.com/users/bahamas10/events{/privacy}","received_events_url":"https://api.github.com/users/bahamas10/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bahamas10/home-assistant","description":":house_with_garden: Open-source home automation platform running on Python 3","fork":true,"url":"https://api.github.com/repos/bahamas10/home-assistant","forks_url":"https://api.github.com/repos/bahamas10/home-assistant/forks","keys_url":"https://api.github.com/repos/bahamas10/home-assistant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bahamas10/home-assistant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bahamas10/home-assistant/teams","hooks_url":"https://api.github.com/repos/bahamas10/home-assistant/hooks","issue_events_url":"https://api.github.com/repos/bahamas10/home-assistant/issues/events{/number}","events_url":"https://api.github.com/repos/bahamas10/home-assistant/events","assignees_url":"https://api.github.com/repos/bahamas10/home-assistant/assignees{/user}","branches_url":"https://api.github.com/repos/bahamas10/home-assistant/branches{/branch}","tags_url":"https://api.github.com/repos/bahamas10/home-assistant/tags","blobs_url":"https://api.github.com/repos/bahamas10/home-assistant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bahamas10/home-assistant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bahamas10/home-assistant/git/refs{/sha}","trees_url":"https://api.github.com/repos/bahamas10/home-assistant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bahamas10/home-assistant/statuses/{sha}","languages_url":"https://api.github.com/repos/bahamas10/home-assistant/languages","stargazers_url":"https://api.github.com/repos/bahamas10/home-assistant/stargazers","contributors_url":"https://api.github.com/repos/bahamas10/home-assistant/contributors","subscribers_url":"https://api.github.com/repos/bahamas10/home-assistant/subscribers","subscription_url":"https://api.github.com/repos/bahamas10/home-assistant/subscription","commits_url":"https://api.github.com/repos/bahamas10/home-assistant/commits{/sha}","git_commits_url":"https://api.github.com/repos/bahamas10/home-assistant/git/commits{/sha}","comments_url":"https://api.github.com/repos/bahamas10/home-assistant/comments{/number}","issue_comment_url":"https://api.github.com/repos/bahamas10/home-assistant/issues/comments{/number}","contents_url":"https://api.github.com/repos/bahamas10/home-assistant/contents/{+path}","compare_url":"https://api.github.com/repos/bahamas10/home-assistant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bahamas10/home-assistant/merges","archive_url":"https://api.github.com/repos/bahamas10/home-assistant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bahamas10/home-assistant/downloads","issues_url":"https://api.github.com/repos/bahamas10/home-assistant/issues{/number}","pulls_url":"https://api.github.com/repos/bahamas10/home-assistant/pulls{/number}","milestones_url":"https://api.github.com/repos/bahamas10/home-assistant/milestones{/number}","notifications_url":"https://api.github.com/repos/bahamas10/home-assistant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bahamas10/home-assistant/labels{/name}","releases_url":"https://api.github.com/repos/bahamas10/home-assistant/releases{/id}","deployments_url":"https://api.github.com/repos/bahamas10/home-assistant/deployments","created_at":"2018-07-05T15:57:55Z","updated_at":"2018-07-05T15:58:05Z","pushed_at":"2018-07-05T16:04:44Z","git_url":"git://github.com/bahamas10/home-assistant.git","ssh_url":"git@github.com:bahamas10/home-assistant.git","clone_url":"https://github.com/bahamas10/home-assistant.git","svn_url":"https://github.com/bahamas10/home-assistant","homepage":"https://home-assistant.io","size":84221,"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,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"home-assistant:dev","ref":"dev","sha":"f65c3940aee624b27b5b60f1ded39367443d1f6f","user":{"login":"home-assistant","id":13844975,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzODQ0OTc1","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,"node_id":"MDEwOlJlcG9zaXRvcnkxMjg4ODk5Mw==","name":"home-assistant","full_name":"home-assistant/home-assistant","owner":{"login":"home-assistant","id":13844975,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzODQ0OTc1","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-07-05T15:21:59Z","pushed_at":"2018-07-05T16:13:39Z","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":84221,"stargazers_count":15085,"watchers_count":15085,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4480,"mirror_url":null,"archived":false,"open_issues_count":878,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":4480,"open_issues":878,"watchers":15085,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/15309"},"html":{"href":"https://github.com/home-assistant/home-assistant/pull/15309"},"issue":{"href":"https://api.github.com/repos/home-assistant/home-assistant/issues/15309"},"comments":{"href":"https://api.github.com/repos/home-assistant/home-assistant/issues/15309/comments"},"review_comments":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/15309/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/15309/commits"},"statuses":{"href":"https://api.github.com/repos/home-assistant/home-assistant/statuses/34ba47c254002517c1fdd4edd74c4bb787157aa3"}},"author_association":"NONE"}}
{"actor":{"display_login":"houndci-bot"}}