{"action":"created","comment":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments/68338483","id":68338483,"diff_hunk":"@@ -0,0 +1,125 @@\n+\"\"\"\n+The homematic sensor platform.\n+\n+For more details about this platform, please refer to the documentation at\n+https://home-assistant.io/components/sensor.homematic/\n+\n+Important: For this platform to work the homematic component has to be\n+properly configured.\n+\n+Configuration:\n+\n+sensor:\n+  - platform: homematic\n+    address: <Homematic address for device> # e.g. \"JEQ0XXXXXXX\"\n+    name: <User defined name> (optional)\n+    param: <Name of datapoint to us as sensor> (optional)\n+\"\"\"\n+\n+import logging\n+from homeassistant.const import STATE_UNKNOWN\n+import homeassistant.components.homematic as homematic\n+\n+_LOGGER = logging.getLogger(__name__)\n+\n+DEPENDENCIES = ['homematic']\n+\n+HM_STATE_HA_CAST = {\n+    \"RotaryHandleSensor\": {0: \"closed\", 1: \"tilted\", 2: \"open\"}\n+}\n+\n+HM_UNIT_HA_CAST = {\n+    \"HUMIDITY\": \"%\",\n+    \"TEMPERATURE\": \"°C\",\n+    \"BRIGHTNESS\": \"#\",\n+    \"POWER\": \"W\",\n+    \"CURRENT\": \"mA\",\n+    \"VOLTAGE\": \"V\",\n+    \"ENERGY_COUNTER\": \"Wh\"\n+}\n+\n+\n+def setup_platform(hass, config, add_callback_devices, discovery_info=None):\n+    \"\"\"Setup the platform.\"\"\"\n+    return homematic.setup_hmdevice_entity_helper(HMSensor,\n+                                                  config,\n+                                                  add_callback_devices)\n+\n+\n+class HMSensor(homematic.HMDevice):\n+    \"\"\"Represents various Homematic sensors in Home Assistant.\"\"\"\n+\n+    @property\n+    def state(self):\n+        \"\"\"Return the state of the sensor.\"\"\"\n+        if not self.available:\n+            return STATE_UNKNOWN\n+\n+        # Does a cast exist for this class?\n+        name = self._hmdevice.__class__.__name__\n+        if name in HM_STATE_HA_CAST:\n+            return HM_STATE_HA_CAST[name].get(self._hm_get_state(), None)\n+\n+        # No cast, return original value\n+        return self._hm_get_state()\n+\n+    @property\n+    def unit_of_measurement(self):\n+        \"\"\"Return the unit of measurement of this entity, if any.\"\"\"\n+        if not self.available:\n+            return None\n+\n+        return HM_UNIT_HA_CAST.get(self._state, None)\n+\n+    def _check_hm_to_ha_object(self):\n+        \"\"\"\n+        Check if possible to use the HM Object as this HA type\n+        NEEDS overwrite by inherit!\n+        \"\"\"\n+        from pyhomematic.devicetypes.sensors import HMSensor as pyHMSensor\n+\n+        # Check compatibility from HMDevice\n+        if not super()._check_hm_to_ha_object():\n+            return False\n+\n+        # Check if the homematic device is correct for this HA device\n+        if not isinstance(self._hmdevice, pyHMSensor):\n+            _LOGGER.critical(\"This %s can't be use as sensor!\", self._name)\n+            return False\n+\n+        # Does user defined value exist?\n+        if self._state and self._state not in self._hmdevice.SENSORNODE:\n+            # pylint: disable=logging-too-many-args\n+            _LOGGER.critical(\"This %s have no sensor with %s! Values are\",\n+                             self._name, self._state,\n+                             str(self._hmdevice.SENSORNODE.keys()))\n+            return False\n+\n+        # No param is set and more than 1 sensor nodes are present\n+        if self._state is None and len(self._hmdevice.SENSORNODE) > 1:\n+            _LOGGER.critical(\"This %s has multiple sensor nodes. \" +\n+                             \"Please us param. Values are: %s\", self._name,\n+                             str(self._hmdevice.SENSORNODE.keys()))\n+            return False\n+\n+        _LOGGER.debug(\"%s is okay for linking\", self._name)\n+        return True\n+\n+    def _init_data_struct(self):","path":"homeassistant/components/sensor/homematic.py","position":108,"original_position":108,"commit_id":"5582a679fdc2585556dc7650789c47f7585697b5","original_commit_id":"5582a679fdc2585556dc7650789c47f7585697b5","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* D205: 1 blank line required between summary line and description (found 0)\n* D400: First line should end with a period (not 'a')","created_at":"2016-06-24T00:32:02Z","updated_at":"2016-06-24T00:32:02Z","html_url":"https://github.com/home-assistant/home-assistant/pull/2366#discussion_r68338483","pull_request_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/2366","_links":{"self":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments/68338483"},"html":{"href":"https://github.com/home-assistant/home-assistant/pull/2366#discussion_r68338483"},"pull_request":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/2366"}}},"pull_request":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/2366","id":75048792,"html_url":"https://github.com/home-assistant/home-assistant/pull/2366","diff_url":"https://github.com/home-assistant/home-assistant/pull/2366.diff","patch_url":"https://github.com/home-assistant/home-assistant/pull/2366.patch","issue_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/2366","number":2366,"state":"open","locked":false,"title":"Homematic Support","user":{"login":"danielperna84","id":7396998,"avatar_url":"https://avatars.githubusercontent.com/u/7396998?v=3","gravatar_id":"","url":"https://api.github.com/users/danielperna84","html_url":"https://github.com/danielperna84","followers_url":"https://api.github.com/users/danielperna84/followers","following_url":"https://api.github.com/users/danielperna84/following{/other_user}","gists_url":"https://api.github.com/users/danielperna84/gists{/gist_id}","starred_url":"https://api.github.com/users/danielperna84/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielperna84/subscriptions","organizations_url":"https://api.github.com/users/danielperna84/orgs","repos_url":"https://api.github.com/users/danielperna84/repos","events_url":"https://api.github.com/users/danielperna84/events{/privacy}","received_events_url":"https://api.github.com/users/danielperna84/received_events","type":"User","site_admin":false},"body":"**Description:**\r\nAdding bi-directional Homematic support. This includes lots of actors (switches, rollershutters etc.), thermostats and sensors (motion, brightness, shutter contacts etc.). I roughly estimate that we cover more than 60% (maybe even more) of all the currently available Homematic RF products, which are widely spread in Europe (primarily Germany, Austria and Switzerland).\r\nConfiguration of devices might be complex, but we'll cover that in the documentation (working on that). Basic setup is described within the component/platform files.\r\nWe also have an (experimental) autodetect feature, which discovers and configures every device we're capable of handling, although without friendly names. But for beginners this will quickly show which of their devices are supported and can be manually configured accordingly.\r\n\r\nThanks to @jazzaj for starting the Homematic implementation based on my pyhomematic module.\r\nThanks to @pvizeli for making radical improvements to my module and jazzajs implementation.\r\nThanks to @bimbar for support of MAX! Thermostats.\r\n\r\n**Pull request in [home-assistant.io](https://github.com/home-assistant/home-assistant.io) with documentation (if applicable):** home-assistant/home-assistant.io#\r\n\r\n**Example entry for `configuration.yaml` (if applicable):**\r\n```yaml\r\nhomematic:\r\n  local_ip: \"<IP of device running Home Assistant>\"\r\n  local_port: <Port for connection with Home Assistant>\r\n  remote_ip: \"<IP of Homegear / CCU>\"\r\n  remote_port: <Port of Homegear / CCU XML-RPC Server>\r\n  autodetect: \"<True/False>\" (optional, experimental, detect all devices)\r\n```\r\n\r\n**Checklist:**\r\n\r\nIf user exposed functionality or configuration variables are added/changed:\r\n  - [ ] Documentation added/updated in [home-assistant.io](https://github.com/home-assistant/home-assistant.io)\r\n\r\nIf code communicates with devices:\r\n  - [x] Local tests with `tox` run successfully. **Your PR cannot be merged unless tests pass**\r\n  - [x] New dependencies have been added to the `REQUIREMENTS` variable ([example][ex-requir]).\r\n  - [x] New dependencies are only imported inside functions that use them ([example][ex-import]).\r\n  - [x] New dependencies have been added to `requirements_all.txt` by running `script/gen_requirements_all.py`.\r\n  - [x] New files were added to `.coveragerc`.\r\n\r\n\r\n[fork]: http://stackoverflow.com/a/7244456\r\n[squash]: https://github.com/ginatrapani/todo.txt-android/wiki/Squash-All-Commits-Related-to-a-Single-Issue-into-a-Single-Commit\r\n[ex-requir]: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/keyboard.py#L16\r\n[ex-import]: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/keyboard.py#L51\r\n\r\n","created_at":"2016-06-24T00:31:42Z","updated_at":"2016-06-24T00:32:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"20cfeb4d3eb7791aea43ddde66f19e64d9de0f15","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/2366/commits","review_comments_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/2366/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/2366/comments","statuses_url":"https://api.github.com/repos/home-assistant/home-assistant/statuses/5582a679fdc2585556dc7650789c47f7585697b5","head":{"label":"danielperna84:Homematic","ref":"Homematic","sha":"5582a679fdc2585556dc7650789c47f7585697b5","user":{"login":"danielperna84","id":7396998,"avatar_url":"https://avatars.githubusercontent.com/u/7396998?v=3","gravatar_id":"","url":"https://api.github.com/users/danielperna84","html_url":"https://github.com/danielperna84","followers_url":"https://api.github.com/users/danielperna84/followers","following_url":"https://api.github.com/users/danielperna84/following{/other_user}","gists_url":"https://api.github.com/users/danielperna84/gists{/gist_id}","starred_url":"https://api.github.com/users/danielperna84/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielperna84/subscriptions","organizations_url":"https://api.github.com/users/danielperna84/orgs","repos_url":"https://api.github.com/users/danielperna84/repos","events_url":"https://api.github.com/users/danielperna84/events{/privacy}","received_events_url":"https://api.github.com/users/danielperna84/received_events","type":"User","site_admin":false},"repo":{"id":60876235,"name":"home-assistant","full_name":"danielperna84/home-assistant","owner":{"login":"danielperna84","id":7396998,"avatar_url":"https://avatars.githubusercontent.com/u/7396998?v=3","gravatar_id":"","url":"https://api.github.com/users/danielperna84","html_url":"https://github.com/danielperna84","followers_url":"https://api.github.com/users/danielperna84/followers","following_url":"https://api.github.com/users/danielperna84/following{/other_user}","gists_url":"https://api.github.com/users/danielperna84/gists{/gist_id}","starred_url":"https://api.github.com/users/danielperna84/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielperna84/subscriptions","organizations_url":"https://api.github.com/users/danielperna84/orgs","repos_url":"https://api.github.com/users/danielperna84/repos","events_url":"https://api.github.com/users/danielperna84/events{/privacy}","received_events_url":"https://api.github.com/users/danielperna84/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danielperna84/home-assistant","description":":house_with_garden: Open-source home automation platform running on Python 3","fork":true,"url":"https://api.github.com/repos/danielperna84/home-assistant","forks_url":"https://api.github.com/repos/danielperna84/home-assistant/forks","keys_url":"https://api.github.com/repos/danielperna84/home-assistant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danielperna84/home-assistant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danielperna84/home-assistant/teams","hooks_url":"https://api.github.com/repos/danielperna84/home-assistant/hooks","issue_events_url":"https://api.github.com/repos/danielperna84/home-assistant/issues/events{/number}","events_url":"https://api.github.com/repos/danielperna84/home-assistant/events","assignees_url":"https://api.github.com/repos/danielperna84/home-assistant/assignees{/user}","branches_url":"https://api.github.com/repos/danielperna84/home-assistant/branches{/branch}","tags_url":"https://api.github.com/repos/danielperna84/home-assistant/tags","blobs_url":"https://api.github.com/repos/danielperna84/home-assistant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danielperna84/home-assistant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danielperna84/home-assistant/git/refs{/sha}","trees_url":"https://api.github.com/repos/danielperna84/home-assistant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danielperna84/home-assistant/statuses/{sha}","languages_url":"https://api.github.com/repos/danielperna84/home-assistant/languages","stargazers_url":"https://api.github.com/repos/danielperna84/home-assistant/stargazers","contributors_url":"https://api.github.com/repos/danielperna84/home-assistant/contributors","subscribers_url":"https://api.github.com/repos/danielperna84/home-assistant/subscribers","subscription_url":"https://api.github.com/repos/danielperna84/home-assistant/subscription","commits_url":"https://api.github.com/repos/danielperna84/home-assistant/commits{/sha}","git_commits_url":"https://api.github.com/repos/danielperna84/home-assistant/git/commits{/sha}","comments_url":"https://api.github.com/repos/danielperna84/home-assistant/comments{/number}","issue_comment_url":"https://api.github.com/repos/danielperna84/home-assistant/issues/comments{/number}","contents_url":"https://api.github.com/repos/danielperna84/home-assistant/contents/{+path}","compare_url":"https://api.github.com/repos/danielperna84/home-assistant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danielperna84/home-assistant/merges","archive_url":"https://api.github.com/repos/danielperna84/home-assistant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danielperna84/home-assistant/downloads","issues_url":"https://api.github.com/repos/danielperna84/home-assistant/issues{/number}","pulls_url":"https://api.github.com/repos/danielperna84/home-assistant/pulls{/number}","milestones_url":"https://api.github.com/repos/danielperna84/home-assistant/milestones{/number}","notifications_url":"https://api.github.com/repos/danielperna84/home-assistant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danielperna84/home-assistant/labels{/name}","releases_url":"https://api.github.com/repos/danielperna84/home-assistant/releases{/id}","deployments_url":"https://api.github.com/repos/danielperna84/home-assistant/deployments","created_at":"2016-06-10T20:52:21Z","updated_at":"2016-06-10T22:59:57Z","pushed_at":"2016-06-24T00:07:08Z","git_url":"git://github.com/danielperna84/home-assistant.git","ssh_url":"git@github.com:danielperna84/home-assistant.git","clone_url":"https://github.com/danielperna84/home-assistant.git","svn_url":"https://github.com/danielperna84/home-assistant","homepage":"https://home-assistant.io","size":70976,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":0,"default_branch":"dev"}},"base":{"label":"home-assistant:dev","ref":"dev","sha":"600a3e3965387be38211012fd7351121a17a433d","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-06-23T22:38:22Z","pushed_at":"2016-06-24T00:31:42Z","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":82742,"stargazers_count":3621,"watchers_count":3621,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":782,"mirror_url":null,"open_issues_count":156,"forks":782,"open_issues":156,"watchers":3621,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/2366"},"html":{"href":"https://github.com/home-assistant/home-assistant/pull/2366"},"issue":{"href":"https://api.github.com/repos/home-assistant/home-assistant/issues/2366"},"comments":{"href":"https://api.github.com/repos/home-assistant/home-assistant/issues/2366/comments"},"review_comments":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/2366/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/2366/commits"},"statuses":{"href":"https://api.github.com/repos/home-assistant/home-assistant/statuses/5582a679fdc2585556dc7650789c47f7585697b5"}}}}
{"actor":{"display_login":"balloobbot"}}