{"action":"created","comment":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments/73805839","id":73805839,"diff_hunk":"@@ -0,0 +1,106 @@\n+\"\"\"\n+Support for switching devices via pilight to on and off.\n+\n+For more details about this platform, please refer to the documentation at\n+https://home-assistant.io/components/switch.pilight/\n+\"\"\"\n+import logging\n+\n+import homeassistant.components.pilight as pilight\n+from homeassistant.components.switch import SwitchDevice\n+\n+DEPENDENCIES = ['pilight']\n+\n+_LOGGER = logging.getLogger(__name__)\n+\n+\n+def setup_platform(hass, config, add_devices_callback, discovery_info=None):\n+    \"\"\"Setup the pilight platform.\"\"\"\n+    # Verify that pilight-daemon connection is present\n+    if not pilight.CONNECTED:\n+        _LOGGER.error('A connection has not been made to the pilight-daemon')\n+        return False\n+\n+    \"\"\"Find and return switches controlled by pilight\"\"\"\n+    switches = config.get('switches', {})\n+    devices = []\n+\n+    for dev_name, properties in switches.items():\n+        devices.append(\n+            PilightSwitch(\n+                hass,\n+                properties.get('name', dev_name),\n+                properties.get('on_code'),\n+                properties.get('off_code'),\n+                properties.get('on_code_receive', False),\n+                properties.get('off_code_receive', False)))\n+\n+    add_devices_callback(devices)\n+\n+\n+class PilightSwitch(SwitchDevice):\n+    \"\"\"Representation of a pilight switch.\"\"\"\n+\n+    # pylint: disable=too-many-arguments, too-many-instance-attributes\n+    def __init__(self, hass, name, code_on, code_off, code_on_receive, code_off_receive):\n+        \"\"\"Initialize the switch.\"\"\"\n+        self._hass = hass\n+        self._name = name\n+        self._state = False\n+        self._code_on = code_on\n+        self._code_off = code_off\n+        self._code_on_receive = code_on_receive\n+        self._code_off_receive = code_off_receive\n+        \n+        if self._code_on_receive or self._code_off_receive:\n+            hass.bus.listen(pilight.EVENT, self._set_state)\n+\n+    @property\n+    def name(self):","path":"homeassistant/components/switch/pilight.py","position":59,"original_position":59,"commit_id":"d21cbb53ac13ca3179fa1f1e28a25129d08978e6","original_commit_id":"d21cbb53ac13ca3179fa1f1e28a25129d08978e6","user":{"login":"balloobbot","id":16367972,"avatar_url":"https://avatars.githubusercontent.com/u/16367972?v=3","gravatar_id":"","url":"https://api.github.com/users/balloobbot","html_url":"https://github.com/balloobbot","followers_url":"https://api.github.com/users/balloobbot/followers","following_url":"https://api.github.com/users/balloobbot/following{/other_user}","gists_url":"https://api.github.com/users/balloobbot/gists{/gist_id}","starred_url":"https://api.github.com/users/balloobbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balloobbot/subscriptions","organizations_url":"https://api.github.com/users/balloobbot/orgs","repos_url":"https://api.github.com/users/balloobbot/repos","events_url":"https://api.github.com/users/balloobbot/events{/privacy}","received_events_url":"https://api.github.com/users/balloobbot/received_events","type":"User","site_admin":false},"body":"_[farcy v1.1](https://github.com/appfolio/farcy)_\n* D400: First line should end with a period (not 'h')","created_at":"2016-08-07T17:26:45Z","updated_at":"2016-08-07T17:26:45Z","html_url":"https://github.com/home-assistant/home-assistant/pull/2742#discussion_r73805839","pull_request_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/2742","_links":{"self":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments/73805839"},"html":{"href":"https://github.com/home-assistant/home-assistant/pull/2742#discussion_r73805839"},"pull_request":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/2742"}}},"pull_request":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/2742","id":80372698,"html_url":"https://github.com/home-assistant/home-assistant/pull/2742","diff_url":"https://github.com/home-assistant/home-assistant/pull/2742.diff","patch_url":"https://github.com/home-assistant/home-assistant/pull/2742.patch","issue_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/2742","number":2742,"state":"open","locked":false,"title":"Pilight  component","user":{"login":"DavidLP","id":6951141,"avatar_url":"https://avatars.githubusercontent.com/u/6951141?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidLP","html_url":"https://github.com/DavidLP","followers_url":"https://api.github.com/users/DavidLP/followers","following_url":"https://api.github.com/users/DavidLP/following{/other_user}","gists_url":"https://api.github.com/users/DavidLP/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidLP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidLP/subscriptions","organizations_url":"https://api.github.com/users/DavidLP/orgs","repos_url":"https://api.github.com/users/DavidLP/repos","events_url":"https://api.github.com/users/DavidLP/events{/privacy}","received_events_url":"https://api.github.com/users/DavidLP/received_events","type":"User","site_admin":false},"body":"**Description:**\r\n\r\nA new hub component is added to interface [pilight](https://www.pilight.org/), a 433 MHz RF devices library. Sending _and_ receiving of codes is supported asynchronously.\r\n\r\nA new pilight switch is added using the new hub.  This switch can be toggled by HA and RF remotes. A _state safe_ way of toggling RF switches with HA and RF remotes is possible.\r\n\r\nDocumentation is available at https://home-assistant.io/components/pilight and https://home-assistant.io/components/switch.pilight/\r\n\r\n**Example entry for `configuration.yaml`:**\r\n```yaml\r\npilight:\r\n  host: 127.0.0.1\r\n  port: 5000\r\n\r\nswitch:\r\n  platform: pilight\r\n  switches:\r\n    test switch:\r\n      on_code:\r\n        protocol: intertechno_old\r\n        unit: 3\r\n        id: 12\r\n        'on': 1\r\n      off_code:\r\n        protocol: intertechno_old\r\n        unit: 3\r\n        id: 12\r\n        'off': 1\r\n``\r\n","created_at":"2016-08-07T17:26:09Z","updated_at":"2016-08-07T17:26:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"adb9b6cbceeff6def2358c2c62c7cfcc5d60fc0a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/2742/commits","review_comments_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/2742/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/2742/comments","statuses_url":"https://api.github.com/repos/home-assistant/home-assistant/statuses/d21cbb53ac13ca3179fa1f1e28a25129d08978e6","head":{"label":"DavidLP:dev","ref":"dev","sha":"d21cbb53ac13ca3179fa1f1e28a25129d08978e6","user":{"login":"DavidLP","id":6951141,"avatar_url":"https://avatars.githubusercontent.com/u/6951141?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidLP","html_url":"https://github.com/DavidLP","followers_url":"https://api.github.com/users/DavidLP/followers","following_url":"https://api.github.com/users/DavidLP/following{/other_user}","gists_url":"https://api.github.com/users/DavidLP/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidLP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidLP/subscriptions","organizations_url":"https://api.github.com/users/DavidLP/orgs","repos_url":"https://api.github.com/users/DavidLP/repos","events_url":"https://api.github.com/users/DavidLP/events{/privacy}","received_events_url":"https://api.github.com/users/DavidLP/received_events","type":"User","site_admin":false},"repo":{"id":64687663,"name":"home-assistant","full_name":"DavidLP/home-assistant","owner":{"login":"DavidLP","id":6951141,"avatar_url":"https://avatars.githubusercontent.com/u/6951141?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidLP","html_url":"https://github.com/DavidLP","followers_url":"https://api.github.com/users/DavidLP/followers","following_url":"https://api.github.com/users/DavidLP/following{/other_user}","gists_url":"https://api.github.com/users/DavidLP/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidLP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidLP/subscriptions","organizations_url":"https://api.github.com/users/DavidLP/orgs","repos_url":"https://api.github.com/users/DavidLP/repos","events_url":"https://api.github.com/users/DavidLP/events{/privacy}","received_events_url":"https://api.github.com/users/DavidLP/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DavidLP/home-assistant","description":":house_with_garden: Open-source home automation platform running on Python 3","fork":true,"url":"https://api.github.com/repos/DavidLP/home-assistant","forks_url":"https://api.github.com/repos/DavidLP/home-assistant/forks","keys_url":"https://api.github.com/repos/DavidLP/home-assistant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DavidLP/home-assistant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DavidLP/home-assistant/teams","hooks_url":"https://api.github.com/repos/DavidLP/home-assistant/hooks","issue_events_url":"https://api.github.com/repos/DavidLP/home-assistant/issues/events{/number}","events_url":"https://api.github.com/repos/DavidLP/home-assistant/events","assignees_url":"https://api.github.com/repos/DavidLP/home-assistant/assignees{/user}","branches_url":"https://api.github.com/repos/DavidLP/home-assistant/branches{/branch}","tags_url":"https://api.github.com/repos/DavidLP/home-assistant/tags","blobs_url":"https://api.github.com/repos/DavidLP/home-assistant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DavidLP/home-assistant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DavidLP/home-assistant/git/refs{/sha}","trees_url":"https://api.github.com/repos/DavidLP/home-assistant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DavidLP/home-assistant/statuses/{sha}","languages_url":"https://api.github.com/repos/DavidLP/home-assistant/languages","stargazers_url":"https://api.github.com/repos/DavidLP/home-assistant/stargazers","contributors_url":"https://api.github.com/repos/DavidLP/home-assistant/contributors","subscribers_url":"https://api.github.com/repos/DavidLP/home-assistant/subscribers","subscription_url":"https://api.github.com/repos/DavidLP/home-assistant/subscription","commits_url":"https://api.github.com/repos/DavidLP/home-assistant/commits{/sha}","git_commits_url":"https://api.github.com/repos/DavidLP/home-assistant/git/commits{/sha}","comments_url":"https://api.github.com/repos/DavidLP/home-assistant/comments{/number}","issue_comment_url":"https://api.github.com/repos/DavidLP/home-assistant/issues/comments{/number}","contents_url":"https://api.github.com/repos/DavidLP/home-assistant/contents/{+path}","compare_url":"https://api.github.com/repos/DavidLP/home-assistant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DavidLP/home-assistant/merges","archive_url":"https://api.github.com/repos/DavidLP/home-assistant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DavidLP/home-assistant/downloads","issues_url":"https://api.github.com/repos/DavidLP/home-assistant/issues{/number}","pulls_url":"https://api.github.com/repos/DavidLP/home-assistant/pulls{/number}","milestones_url":"https://api.github.com/repos/DavidLP/home-assistant/milestones{/number}","notifications_url":"https://api.github.com/repos/DavidLP/home-assistant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DavidLP/home-assistant/labels{/name}","releases_url":"https://api.github.com/repos/DavidLP/home-assistant/releases{/id}","deployments_url":"https://api.github.com/repos/DavidLP/home-assistant/deployments","created_at":"2016-08-01T17:31:32Z","updated_at":"2016-08-01T17:31:35Z","pushed_at":"2016-08-07T17:20:47Z","git_url":"git://github.com/DavidLP/home-assistant.git","ssh_url":"git@github.com:DavidLP/home-assistant.git","clone_url":"https://github.com/DavidLP/home-assistant.git","svn_url":"https://github.com/DavidLP/home-assistant","homepage":"https://home-assistant.io","size":91883,"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":"d1107a9cf328db9093187ac6d0b7be284fc4d2db","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":"2016-08-07T17:06:29Z","pushed_at":"2016-08-07T17:26:09Z","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":101715,"stargazers_count":3822,"watchers_count":3822,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":870,"mirror_url":null,"open_issues_count":181,"forks":870,"open_issues":181,"watchers":3822,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/2742"},"html":{"href":"https://github.com/home-assistant/home-assistant/pull/2742"},"issue":{"href":"https://api.github.com/repos/home-assistant/home-assistant/issues/2742"},"comments":{"href":"https://api.github.com/repos/home-assistant/home-assistant/issues/2742/comments"},"review_comments":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/2742/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/2742/commits"},"statuses":{"href":"https://api.github.com/repos/home-assistant/home-assistant/statuses/d21cbb53ac13ca3179fa1f1e28a25129d08978e6"}}}}
{"actor":{"display_login":"balloobbot"}}