{"action":"created","comment":{"url":"https://api.github.com/repos/balloob/home-assistant/pulls/comments/48093855","id":48093855,"diff_hunk":"@@ -0,0 +1,219 @@\n+\"\"\"\n+homeassistant.components.mysensors\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n+MySensors component that connects to a MySensors gateway via pymysensors\n+API.\n+\n+For more details about this platform, please refer to the documentation at\n+https://home-assistant.io/components/sensor.mysensors.html\n+\n+\n+New features:\n+\n+New MySensors component.\n+Updated MySensors Sensor platform.\n+New MySensors Switch platform.\n+Multiple gateways are now supported.\n+\n+Configuration.yaml:\n+\n+mysensors:\n+  port:\n+    - '/dev/ttyUSB0'\n+    - '/dev/ttyACM1'\n+  debug: true\n+  persistence: true\n+  persistence_file:\n+    - 'path/to/.homeassistant/mysensors.json'\n+    - 'path/to/.homeassistant/mysensors2.json'\n+  version: '1.5'\n+\n+sensor:\n+  platform: mysensors\n+\n+switch:\n+  platform: mysensors\n+\"\"\"\n+import logging\n+\n+from homeassistant.helpers import (validate_config)\n+\n+from homeassistant.const import (\n+    EVENT_HOMEASSISTANT_START,\n+    EVENT_HOMEASSISTANT_STOP,\n+    TEMP_CELCIUS)\n+\n+CONF_PORT = 'port'\n+CONF_DEBUG = 'debug'\n+CONF_PERSISTENCE = 'persistence'\n+CONF_PERSISTENCE_FILE = 'persistence_file'\n+CONF_VERSION = 'version'\n+\n+DOMAIN = 'mysensors'\n+DEPENDENCIES = []\n+REQUIREMENTS = [\n+    'https://github.com/theolind/pymysensors/archive/'\n+    '2aa8f32908e8c5bb3e5c77c5851db778f8635792.zip#pymysensors==0.3']\n+_LOGGER = logging.getLogger(__name__)\n+ATTR_PORT = 'port'\n+ATTR_DEVICES = 'devices'\n+ATTR_NODE_ID = 'node_id'\n+ATTR_CHILD_ID = 'child_id'\n+ATTR_UPDATE_TYPE = 'update_type'\n+\n+IS_METRIC = None\n+CONST = None\n+GATEWAYS = None\n+EVENT_MYSENSORS_NODE_UPDATE = 'MYSENSORS_NODE_UPDATE'\n+\n+\n+def setup(hass, config):  # noqa\n+    \"\"\" Setup the MySensors component. \"\"\"\n+    # pylint:disable=no-name-in-module\n+    import mysensors.mysensors as mysensors\n+\n+    if not validate_config(config,\n+                           {DOMAIN: [CONF_PORT]},\n+                           _LOGGER):\n+        return False\n+\n+    version = config[DOMAIN].get(CONF_VERSION, '1.4')\n+\n+    global CONST\n+    if version == '1.4':","path":"homeassistant/components/mysensors.py","position":83,"original_position":83,"commit_id":"845926236ef62a01cb0ac362208dabe17f5dc3c8","original_commit_id":"845926236ef62a01cb0ac362208dabe17f5dc3c8","user":{"login":"balloob","id":1444314,"avatar_url":"https://avatars.githubusercontent.com/u/1444314?v=3","gravatar_id":"","url":"https://api.github.com/users/balloob","html_url":"https://github.com/balloob","followers_url":"https://api.github.com/users/balloob/followers","following_url":"https://api.github.com/users/balloob/following{/other_user}","gists_url":"https://api.github.com/users/balloob/gists{/gist_id}","starred_url":"https://api.github.com/users/balloob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balloob/subscriptions","organizations_url":"https://api.github.com/users/balloob/orgs","repos_url":"https://api.github.com/users/balloob/repos","events_url":"https://api.github.com/users/balloob/events{/privacy}","received_events_url":"https://api.github.com/users/balloob/received_events","type":"User","site_admin":false},"body":"Just stick to `if .. else` here.","created_at":"2015-12-19T15:59:54Z","updated_at":"2015-12-19T15:59:54Z","html_url":"https://github.com/balloob/home-assistant/pull/771#discussion_r48093855","pull_request_url":"https://api.github.com/repos/balloob/home-assistant/pulls/771","_links":{"self":{"href":"https://api.github.com/repos/balloob/home-assistant/pulls/comments/48093855"},"html":{"href":"https://github.com/balloob/home-assistant/pull/771#discussion_r48093855"},"pull_request":{"href":"https://api.github.com/repos/balloob/home-assistant/pulls/771"}}},"pull_request":{"url":"https://api.github.com/repos/balloob/home-assistant/pulls/771","id":54060628,"html_url":"https://github.com/balloob/home-assistant/pull/771","diff_url":"https://github.com/balloob/home-assistant/pull/771.diff","patch_url":"https://github.com/balloob/home-assistant/pull/771.patch","issue_url":"https://api.github.com/repos/balloob/home-assistant/issues/771","number":771,"state":"open","locked":false,"title":"Mysensors component switch","user":{"login":"MartinHjelmare","id":3181692,"avatar_url":"https://avatars.githubusercontent.com/u/3181692?v=3","gravatar_id":"","url":"https://api.github.com/users/MartinHjelmare","html_url":"https://github.com/MartinHjelmare","followers_url":"https://api.github.com/users/MartinHjelmare/followers","following_url":"https://api.github.com/users/MartinHjelmare/following{/other_user}","gists_url":"https://api.github.com/users/MartinHjelmare/gists{/gist_id}","starred_url":"https://api.github.com/users/MartinHjelmare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MartinHjelmare/subscriptions","organizations_url":"https://api.github.com/users/MartinHjelmare/orgs","repos_url":"https://api.github.com/users/MartinHjelmare/repos","events_url":"https://api.github.com/users/MartinHjelmare/events{/privacy}","received_events_url":"https://api.github.com/users/MartinHjelmare/received_events","type":"User","site_admin":false},"body":"Hi!\r\n\r\nThis is a major overhaul of the MySensors support in homeassistant.\r\n\r\nNew features:\r\n* New components/mysenors\r\n* Update sensors/mysensors, to use new component.\r\n* New switch/mysensors\r\n* Add support for multiple serial gateways connected at the same time.\r\n\r\nDon't hesitate to be critical. =)\r\n\r\nBest regards,\r\nMartin","created_at":"2015-12-18T03:12:45Z","updated_at":"2015-12-19T15:59:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/balloob/home-assistant/pulls/771/commits","review_comments_url":"https://api.github.com/repos/balloob/home-assistant/pulls/771/comments","review_comment_url":"https://api.github.com/repos/balloob/home-assistant/pulls/comments{/number}","comments_url":"https://api.github.com/repos/balloob/home-assistant/issues/771/comments","statuses_url":"https://api.github.com/repos/balloob/home-assistant/statuses/845926236ef62a01cb0ac362208dabe17f5dc3c8","head":{"label":"MartinHjelmare:mysensors-component-switch","ref":"mysensors-component-switch","sha":"845926236ef62a01cb0ac362208dabe17f5dc3c8","user":{"login":"MartinHjelmare","id":3181692,"avatar_url":"https://avatars.githubusercontent.com/u/3181692?v=3","gravatar_id":"","url":"https://api.github.com/users/MartinHjelmare","html_url":"https://github.com/MartinHjelmare","followers_url":"https://api.github.com/users/MartinHjelmare/followers","following_url":"https://api.github.com/users/MartinHjelmare/following{/other_user}","gists_url":"https://api.github.com/users/MartinHjelmare/gists{/gist_id}","starred_url":"https://api.github.com/users/MartinHjelmare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MartinHjelmare/subscriptions","organizations_url":"https://api.github.com/users/MartinHjelmare/orgs","repos_url":"https://api.github.com/users/MartinHjelmare/repos","events_url":"https://api.github.com/users/MartinHjelmare/events{/privacy}","received_events_url":"https://api.github.com/users/MartinHjelmare/received_events","type":"User","site_admin":false},"repo":{"id":44849508,"name":"home-assistant","full_name":"MartinHjelmare/home-assistant","owner":{"login":"MartinHjelmare","id":3181692,"avatar_url":"https://avatars.githubusercontent.com/u/3181692?v=3","gravatar_id":"","url":"https://api.github.com/users/MartinHjelmare","html_url":"https://github.com/MartinHjelmare","followers_url":"https://api.github.com/users/MartinHjelmare/followers","following_url":"https://api.github.com/users/MartinHjelmare/following{/other_user}","gists_url":"https://api.github.com/users/MartinHjelmare/gists{/gist_id}","starred_url":"https://api.github.com/users/MartinHjelmare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MartinHjelmare/subscriptions","organizations_url":"https://api.github.com/users/MartinHjelmare/orgs","repos_url":"https://api.github.com/users/MartinHjelmare/repos","events_url":"https://api.github.com/users/MartinHjelmare/events{/privacy}","received_events_url":"https://api.github.com/users/MartinHjelmare/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MartinHjelmare/home-assistant","description":"Open-source home automation platform running on Python 3","fork":true,"url":"https://api.github.com/repos/MartinHjelmare/home-assistant","forks_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/forks","keys_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/teams","hooks_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/hooks","issue_events_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/issues/events{/number}","events_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/events","assignees_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/assignees{/user}","branches_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/branches{/branch}","tags_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/tags","blobs_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/git/refs{/sha}","trees_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/statuses/{sha}","languages_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/languages","stargazers_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/stargazers","contributors_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/contributors","subscribers_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/subscribers","subscription_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/subscription","commits_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/commits{/sha}","git_commits_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/git/commits{/sha}","comments_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/comments{/number}","issue_comment_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/issues/comments{/number}","contents_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/contents/{+path}","compare_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/merges","archive_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/downloads","issues_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/issues{/number}","pulls_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/pulls{/number}","milestones_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/milestones{/number}","notifications_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/labels{/name}","releases_url":"https://api.github.com/repos/MartinHjelmare/home-assistant/releases{/id}","created_at":"2015-10-24T02:49:56Z","updated_at":"2015-10-24T02:50:00Z","pushed_at":"2015-12-18T02:59:20Z","git_url":"git://github.com/MartinHjelmare/home-assistant.git","ssh_url":"git@github.com:MartinHjelmare/home-assistant.git","clone_url":"https://github.com/MartinHjelmare/home-assistant.git","svn_url":"https://github.com/MartinHjelmare/home-assistant","homepage":"https://home-assistant.io","size":26141,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"balloob:dev","ref":"dev","sha":"a0ff8819a99e2e104fb0c2bc7aabd9f2018e889a","user":{"login":"balloob","id":1444314,"avatar_url":"https://avatars.githubusercontent.com/u/1444314?v=3","gravatar_id":"","url":"https://api.github.com/users/balloob","html_url":"https://github.com/balloob","followers_url":"https://api.github.com/users/balloob/followers","following_url":"https://api.github.com/users/balloob/following{/other_user}","gists_url":"https://api.github.com/users/balloob/gists{/gist_id}","starred_url":"https://api.github.com/users/balloob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balloob/subscriptions","organizations_url":"https://api.github.com/users/balloob/orgs","repos_url":"https://api.github.com/users/balloob/repos","events_url":"https://api.github.com/users/balloob/events{/privacy}","received_events_url":"https://api.github.com/users/balloob/received_events","type":"User","site_admin":false},"repo":{"id":12888993,"name":"home-assistant","full_name":"balloob/home-assistant","owner":{"login":"balloob","id":1444314,"avatar_url":"https://avatars.githubusercontent.com/u/1444314?v=3","gravatar_id":"","url":"https://api.github.com/users/balloob","html_url":"https://github.com/balloob","followers_url":"https://api.github.com/users/balloob/followers","following_url":"https://api.github.com/users/balloob/following{/other_user}","gists_url":"https://api.github.com/users/balloob/gists{/gist_id}","starred_url":"https://api.github.com/users/balloob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balloob/subscriptions","organizations_url":"https://api.github.com/users/balloob/orgs","repos_url":"https://api.github.com/users/balloob/repos","events_url":"https://api.github.com/users/balloob/events{/privacy}","received_events_url":"https://api.github.com/users/balloob/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/balloob/home-assistant","description":"Open-source home automation platform running on Python 3","fork":false,"url":"https://api.github.com/repos/balloob/home-assistant","forks_url":"https://api.github.com/repos/balloob/home-assistant/forks","keys_url":"https://api.github.com/repos/balloob/home-assistant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/balloob/home-assistant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/balloob/home-assistant/teams","hooks_url":"https://api.github.com/repos/balloob/home-assistant/hooks","issue_events_url":"https://api.github.com/repos/balloob/home-assistant/issues/events{/number}","events_url":"https://api.github.com/repos/balloob/home-assistant/events","assignees_url":"https://api.github.com/repos/balloob/home-assistant/assignees{/user}","branches_url":"https://api.github.com/repos/balloob/home-assistant/branches{/branch}","tags_url":"https://api.github.com/repos/balloob/home-assistant/tags","blobs_url":"https://api.github.com/repos/balloob/home-assistant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/balloob/home-assistant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/balloob/home-assistant/git/refs{/sha}","trees_url":"https://api.github.com/repos/balloob/home-assistant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/balloob/home-assistant/statuses/{sha}","languages_url":"https://api.github.com/repos/balloob/home-assistant/languages","stargazers_url":"https://api.github.com/repos/balloob/home-assistant/stargazers","contributors_url":"https://api.github.com/repos/balloob/home-assistant/contributors","subscribers_url":"https://api.github.com/repos/balloob/home-assistant/subscribers","subscription_url":"https://api.github.com/repos/balloob/home-assistant/subscription","commits_url":"https://api.github.com/repos/balloob/home-assistant/commits{/sha}","git_commits_url":"https://api.github.com/repos/balloob/home-assistant/git/commits{/sha}","comments_url":"https://api.github.com/repos/balloob/home-assistant/comments{/number}","issue_comment_url":"https://api.github.com/repos/balloob/home-assistant/issues/comments{/number}","contents_url":"https://api.github.com/repos/balloob/home-assistant/contents/{+path}","compare_url":"https://api.github.com/repos/balloob/home-assistant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/balloob/home-assistant/merges","archive_url":"https://api.github.com/repos/balloob/home-assistant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/balloob/home-assistant/downloads","issues_url":"https://api.github.com/repos/balloob/home-assistant/issues{/number}","pulls_url":"https://api.github.com/repos/balloob/home-assistant/pulls{/number}","milestones_url":"https://api.github.com/repos/balloob/home-assistant/milestones{/number}","notifications_url":"https://api.github.com/repos/balloob/home-assistant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/balloob/home-assistant/labels{/name}","releases_url":"https://api.github.com/repos/balloob/home-assistant/releases{/id}","created_at":"2013-09-17T07:29:48Z","updated_at":"2015-12-19T13:27:10Z","pushed_at":"2015-12-19T13:14:19Z","git_url":"git://github.com/balloob/home-assistant.git","ssh_url":"git@github.com:balloob/home-assistant.git","clone_url":"https://github.com/balloob/home-assistant.git","svn_url":"https://github.com/balloob/home-assistant","homepage":"https://home-assistant.io","size":33694,"stargazers_count":2442,"watchers_count":2442,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":343,"mirror_url":null,"open_issues_count":87,"forks":343,"open_issues":87,"watchers":2442,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/balloob/home-assistant/pulls/771"},"html":{"href":"https://github.com/balloob/home-assistant/pull/771"},"issue":{"href":"https://api.github.com/repos/balloob/home-assistant/issues/771"},"comments":{"href":"https://api.github.com/repos/balloob/home-assistant/issues/771/comments"},"review_comments":{"href":"https://api.github.com/repos/balloob/home-assistant/pulls/771/comments"},"review_comment":{"href":"https://api.github.com/repos/balloob/home-assistant/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/balloob/home-assistant/pulls/771/commits"},"statuses":{"href":"https://api.github.com/repos/balloob/home-assistant/statuses/845926236ef62a01cb0ac362208dabe17f5dc3c8"}}}}