{"action":"created","comment":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments/158768409","pull_request_review_id":85622116,"id":158768409,"diff_hunk":"@@ -59,17 +64,35 @@ def name(self):\n \n     def turn_on(self, **kwargs):\n         \"\"\"Turn the switch on.\"\"\"\n-        self._state = True\n         with mochad.REQ_LOCK:\n-            self.device.send_cmd('on')\n-            self._controller.read_data()\n+            try:\n+                self._state = True\n+                # Recycle socket on new command to recover mochad connection\n+                _LOGGER.debug(\"Reconnect %s:%s\", self._controller.server,","path":"homeassistant/components/switch/mochad.py","position":null,"original_position":25,"commit_id":"58be91429e8d71fc2bcc2bd9fa16a6df3a6e65a4","original_commit_id":"9fbade8e7ad387e7651251923c5953eef8456a8d","user":{"login":"aosadchyy","id":21959540,"avatar_url":"https://avatars0.githubusercontent.com/u/21959540?v=4","gravatar_id":"","url":"https://api.github.com/users/aosadchyy","html_url":"https://github.com/aosadchyy","followers_url":"https://api.github.com/users/aosadchyy/followers","following_url":"https://api.github.com/users/aosadchyy/following{/other_user}","gists_url":"https://api.github.com/users/aosadchyy/gists{/gist_id}","starred_url":"https://api.github.com/users/aosadchyy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aosadchyy/subscriptions","organizations_url":"https://api.github.com/users/aosadchyy/orgs","repos_url":"https://api.github.com/users/aosadchyy/repos","events_url":"https://api.github.com/users/aosadchyy/events{/privacy}","received_events_url":"https://api.github.com/users/aosadchyy/received_events","type":"User","site_admin":false},"body":"Ok. Fixed in commit 9fbade8e7","created_at":"2017-12-27T06:35:41Z","updated_at":"2017-12-27T06:35:42Z","html_url":"https://github.com/home-assistant/home-assistant/pull/11296#discussion_r158768409","pull_request_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/11296","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments/158768409"},"html":{"href":"https://github.com/home-assistant/home-assistant/pull/11296#discussion_r158768409"},"pull_request":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/11296"}},"in_reply_to_id":158642282},"pull_request":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/11296","id":160011231,"html_url":"https://github.com/home-assistant/home-assistant/pull/11296","diff_url":"https://github.com/home-assistant/home-assistant/pull/11296.diff","patch_url":"https://github.com/home-assistant/home-assistant/pull/11296.patch","issue_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/11296","number":11296,"state":"open","locked":false,"title":"Reconnect before mochad switch send command","user":{"login":"aosadchyy","id":21959540,"avatar_url":"https://avatars0.githubusercontent.com/u/21959540?v=4","gravatar_id":"","url":"https://api.github.com/users/aosadchyy","html_url":"https://github.com/aosadchyy","followers_url":"https://api.github.com/users/aosadchyy/followers","following_url":"https://api.github.com/users/aosadchyy/following{/other_user}","gists_url":"https://api.github.com/users/aosadchyy/gists{/gist_id}","starred_url":"https://api.github.com/users/aosadchyy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aosadchyy/subscriptions","organizations_url":"https://api.github.com/users/aosadchyy/orgs","repos_url":"https://api.github.com/users/aosadchyy/repos","events_url":"https://api.github.com/users/aosadchyy/events{/privacy}","received_events_url":"https://api.github.com/users/aosadchyy/received_events","type":"User","site_admin":false},"body":"## Description:\r\nConnection to mochad occasionally stalls on RPi and CM19A. Re-connect the underlying socket in controller.PyMochad when X10 swtich is set to on/off. \r\nCurrent design of mochad in homeassistant is to keep 24/7 connection to mochad server open. There is no watchdog nor automatic reconnect routine.  \r\n\r\nThere is a known issue for mochad to get locked up occasionally. e.g. as seen often on RPi.\r\nhttps://sourceforge.net/p/mochad/discussion/1320003/thread/1c193f01/\r\n\r\nWhen this happens, mochad can be recovered by restarting it. However, mochad.py components in home-assistant once connected on HA startup, won't ever reconnect.\r\n\r\nThis improvement allows to reconnect underlying socket in controller. PyMochad when X10 commands are sent to mochad server. It's tested to work fine on my HA.\r\n\r\n**Related issue (if applicable):** fixes #<home-assistant issue number goes here>\r\nhttps://sourceforge.net/p/mochad/discussion/1320003/thread/1c193f01/\r\n\r\n","created_at":"2017-12-24T21:34:23Z","updated_at":"2017-12-27T06:35:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f151c2d93a47ec819086fc45308bcb04f1b8e594","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/11296/commits","review_comments_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/11296/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/11296/comments","statuses_url":"https://api.github.com/repos/home-assistant/home-assistant/statuses/58be91429e8d71fc2bcc2bd9fa16a6df3a6e65a4","head":{"label":"aosadchyy:dev","ref":"dev","sha":"58be91429e8d71fc2bcc2bd9fa16a6df3a6e65a4","user":{"login":"aosadchyy","id":21959540,"avatar_url":"https://avatars0.githubusercontent.com/u/21959540?v=4","gravatar_id":"","url":"https://api.github.com/users/aosadchyy","html_url":"https://github.com/aosadchyy","followers_url":"https://api.github.com/users/aosadchyy/followers","following_url":"https://api.github.com/users/aosadchyy/following{/other_user}","gists_url":"https://api.github.com/users/aosadchyy/gists{/gist_id}","starred_url":"https://api.github.com/users/aosadchyy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aosadchyy/subscriptions","organizations_url":"https://api.github.com/users/aosadchyy/orgs","repos_url":"https://api.github.com/users/aosadchyy/repos","events_url":"https://api.github.com/users/aosadchyy/events{/privacy}","received_events_url":"https://api.github.com/users/aosadchyy/received_events","type":"User","site_admin":false},"repo":{"id":115287664,"name":"home-assistant","full_name":"aosadchyy/home-assistant","owner":{"login":"aosadchyy","id":21959540,"avatar_url":"https://avatars0.githubusercontent.com/u/21959540?v=4","gravatar_id":"","url":"https://api.github.com/users/aosadchyy","html_url":"https://github.com/aosadchyy","followers_url":"https://api.github.com/users/aosadchyy/followers","following_url":"https://api.github.com/users/aosadchyy/following{/other_user}","gists_url":"https://api.github.com/users/aosadchyy/gists{/gist_id}","starred_url":"https://api.github.com/users/aosadchyy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aosadchyy/subscriptions","organizations_url":"https://api.github.com/users/aosadchyy/orgs","repos_url":"https://api.github.com/users/aosadchyy/repos","events_url":"https://api.github.com/users/aosadchyy/events{/privacy}","received_events_url":"https://api.github.com/users/aosadchyy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aosadchyy/home-assistant","description":":house_with_garden: Open-source home automation platform running on Python 3","fork":true,"url":"https://api.github.com/repos/aosadchyy/home-assistant","forks_url":"https://api.github.com/repos/aosadchyy/home-assistant/forks","keys_url":"https://api.github.com/repos/aosadchyy/home-assistant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aosadchyy/home-assistant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aosadchyy/home-assistant/teams","hooks_url":"https://api.github.com/repos/aosadchyy/home-assistant/hooks","issue_events_url":"https://api.github.com/repos/aosadchyy/home-assistant/issues/events{/number}","events_url":"https://api.github.com/repos/aosadchyy/home-assistant/events","assignees_url":"https://api.github.com/repos/aosadchyy/home-assistant/assignees{/user}","branches_url":"https://api.github.com/repos/aosadchyy/home-assistant/branches{/branch}","tags_url":"https://api.github.com/repos/aosadchyy/home-assistant/tags","blobs_url":"https://api.github.com/repos/aosadchyy/home-assistant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aosadchyy/home-assistant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aosadchyy/home-assistant/git/refs{/sha}","trees_url":"https://api.github.com/repos/aosadchyy/home-assistant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aosadchyy/home-assistant/statuses/{sha}","languages_url":"https://api.github.com/repos/aosadchyy/home-assistant/languages","stargazers_url":"https://api.github.com/repos/aosadchyy/home-assistant/stargazers","contributors_url":"https://api.github.com/repos/aosadchyy/home-assistant/contributors","subscribers_url":"https://api.github.com/repos/aosadchyy/home-assistant/subscribers","subscription_url":"https://api.github.com/repos/aosadchyy/home-assistant/subscription","commits_url":"https://api.github.com/repos/aosadchyy/home-assistant/commits{/sha}","git_commits_url":"https://api.github.com/repos/aosadchyy/home-assistant/git/commits{/sha}","comments_url":"https://api.github.com/repos/aosadchyy/home-assistant/comments{/number}","issue_comment_url":"https://api.github.com/repos/aosadchyy/home-assistant/issues/comments{/number}","contents_url":"https://api.github.com/repos/aosadchyy/home-assistant/contents/{+path}","compare_url":"https://api.github.com/repos/aosadchyy/home-assistant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aosadchyy/home-assistant/merges","archive_url":"https://api.github.com/repos/aosadchyy/home-assistant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aosadchyy/home-assistant/downloads","issues_url":"https://api.github.com/repos/aosadchyy/home-assistant/issues{/number}","pulls_url":"https://api.github.com/repos/aosadchyy/home-assistant/pulls{/number}","milestones_url":"https://api.github.com/repos/aosadchyy/home-assistant/milestones{/number}","notifications_url":"https://api.github.com/repos/aosadchyy/home-assistant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aosadchyy/home-assistant/labels{/name}","releases_url":"https://api.github.com/repos/aosadchyy/home-assistant/releases{/id}","deployments_url":"https://api.github.com/repos/aosadchyy/home-assistant/deployments","created_at":"2017-12-24T21:20:23Z","updated_at":"2017-12-24T21:20:30Z","pushed_at":"2017-12-27T06:34:08Z","git_url":"git://github.com/aosadchyy/home-assistant.git","ssh_url":"git@github.com:aosadchyy/home-assistant.git","clone_url":"https://github.com/aosadchyy/home-assistant.git","svn_url":"https://github.com/aosadchyy/home-assistant","homepage":"https://home-assistant.io","size":76735,"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":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"home-assistant:dev","ref":"dev","sha":"3fa45375d96577fee91b90a8d39e07aa14383003","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-12-27T06:10:37Z","pushed_at":"2017-12-27T06:34: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":76803,"stargazers_count":11072,"watchers_count":11072,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3166,"mirror_url":null,"archived":false,"open_issues_count":707,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":3166,"open_issues":707,"watchers":11072,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/11296"},"html":{"href":"https://github.com/home-assistant/home-assistant/pull/11296"},"issue":{"href":"https://api.github.com/repos/home-assistant/home-assistant/issues/11296"},"comments":{"href":"https://api.github.com/repos/home-assistant/home-assistant/issues/11296/comments"},"review_comments":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/11296/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/11296/commits"},"statuses":{"href":"https://api.github.com/repos/home-assistant/home-assistant/statuses/58be91429e8d71fc2bcc2bd9fa16a6df3a6e65a4"}},"author_association":"NONE"}}
{"actor":{"display_login":"aosadchyy"}}