{"action":"created","comment":{"url":"https://api.github.com/repos/openT2T/translators/pulls/comments/78867299","id":78867299,"diff_hunk":"@@ -40,56 +16,133 @@ function validateArgumentType(arg, argName, expectedType) {\n     }\n }\n \n+// Helper method to convert the device schema to the translator schema.\n+function deviceSchemaToTranslatorSchema(deviceSchema) {\n+\n+    var deviceState = deviceSchema.state;\n+    var result = {\n+        id:  'lights.' + deviceId,\n+        rt: 'org.opent2t.sample.lamp.superpopular'\n+    };\n+    \n+    if(typeof deviceState != 'undefined'){\n+        result.n = deviceSchema['name'] ;\n+        result.power = { value: deviceState['on'] };\n+        result.dim = { dimmingSetting: deviceState['bri'], range: [1, 254]};\n+    } else {\n+        for (var i = 0; i < deviceSchema.length; i++){\n+            var changeResult = deviceSchema[i].success;\n+            if(typeof changeResult != 'undefined'){\n+                var key = Object.keys(changeResult)[0];\n+                var parseKey = key.split(\"/\");\n+                var attribute = parseKey[parseKey.length-1];\n+                if( attribute == 'on'){\n+                    result.power = { value: changeResult[key] };\n+                } else if ( attribute == 'bri'){\n+                    result.dim = { dimmingSetting: changeResult[key], range: [1, 254]};\n+                } else if ( attribute == 'name'){\n+                    result.n = changeResult[key];\n+                }\n+            }\n+        }\n+    }\n+    return result;\n+}\n+\n+// Helper method to convert the translator schema to the device schema.\n+function translatorSchemaToDeviceSchema(translatorSchema) {\n \n-var device;\n-var deviceProps;\n-var api;\n+    // build the object with desired state\n+    var result = { };\n \n-// module exports, implementing the schema\n-module.exports = {\n+    if (translatorSchema.n !== undefined) {\n+        result['name'] = translatorSchema.n;\n+    }\n \n-    initDevice: function (dev) {\n+    if (translatorSchema.power!== undefined) {\n+        result['on'] = translatorSchema.power.value;\n+    }\n+\n+    if (translatorSchema.dim!== undefined) {\n+        result['bri'] = translatorSchema.dim.dimmingSetting;\n+    }\n+\n+    return result;\n+}\n+\n+var deviceId;\n+var deviceType = 'lights';\n+var hueHelper;\n+\n+// This translator class implements the 'org.opent2t.sample.light.superpopular' schema.\n+class Translator {\n+\n+    constructor(device) {","path":"org.opent2t.sample.lamp.superpopular/com.philips.hue.bulb/js/thingTranslator.js","position":112,"original_position":112,"commit_id":"9f175f7467c3515caf516d4899f62b10f1006cbb","original_commit_id":"9f175f7467c3515caf516d4899f62b10f1006cbb","user":{"login":"danielrischar","id":21249276,"avatar_url":"https://avatars.githubusercontent.com/u/21249276?v=3","gravatar_id":"","url":"https://api.github.com/users/danielrischar","html_url":"https://github.com/danielrischar","followers_url":"https://api.github.com/users/danielrischar/followers","following_url":"https://api.github.com/users/danielrischar/following{/other_user}","gists_url":"https://api.github.com/users/danielrischar/gists{/gist_id}","starred_url":"https://api.github.com/users/danielrischar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielrischar/subscriptions","organizations_url":"https://api.github.com/users/danielrischar/orgs","repos_url":"https://api.github.com/users/danielrischar/repos","events_url":"https://api.github.com/users/danielrischar/events{/privacy}","received_events_url":"https://api.github.com/users/danielrischar/received_events","type":"User","site_admin":false},"body":"The Nest and Wink translators have moved away from having *helper classes, and instead use a concept of \"hubs\" even where a physical hub doesn't exist (like with Nest).  The \"hub\" is then passed to the translator in the constructor.","created_at":"2016-09-15T00:01:49Z","updated_at":"2016-09-15T00:13:15Z","html_url":"https://github.com/openT2T/translators/pull/96#discussion_r78867299","pull_request_url":"https://api.github.com/repos/openT2T/translators/pulls/96","_links":{"self":{"href":"https://api.github.com/repos/openT2T/translators/pulls/comments/78867299"},"html":{"href":"https://github.com/openT2T/translators/pull/96#discussion_r78867299"},"pull_request":{"href":"https://api.github.com/repos/openT2T/translators/pulls/96"}}},"pull_request":{"url":"https://api.github.com/repos/openT2T/translators/pulls/96","id":85185777,"html_url":"https://github.com/openT2T/translators/pull/96","diff_url":"https://github.com/openT2T/translators/pull/96.diff","patch_url":"https://github.com/openT2T/translators/pull/96.patch","issue_url":"https://api.github.com/repos/openT2T/translators/issues/96","number":96,"state":"open","locked":false,"title":"Dev","user":{"login":"m-chau","id":14900903,"avatar_url":"https://avatars.githubusercontent.com/u/14900903?v=3","gravatar_id":"","url":"https://api.github.com/users/m-chau","html_url":"https://github.com/m-chau","followers_url":"https://api.github.com/users/m-chau/followers","following_url":"https://api.github.com/users/m-chau/following{/other_user}","gists_url":"https://api.github.com/users/m-chau/gists{/gist_id}","starred_url":"https://api.github.com/users/m-chau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-chau/subscriptions","organizations_url":"https://api.github.com/users/m-chau/orgs","repos_url":"https://api.github.com/users/m-chau/repos","events_url":"https://api.github.com/users/m-chau/events{/privacy}","received_events_url":"https://api.github.com/users/m-chau/received_events","type":"User","site_admin":false},"body":"Adding Hue helper library and updated the Hue bulb translator to reflect the OCF schema.","created_at":"2016-09-14T08:27:54Z","updated_at":"2016-09-15T00:13:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6eb3f2b26798ce63fb8e3eda40f4bf0a078539ea","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/openT2T/translators/pulls/96/commits","review_comments_url":"https://api.github.com/repos/openT2T/translators/pulls/96/comments","review_comment_url":"https://api.github.com/repos/openT2T/translators/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openT2T/translators/issues/96/comments","statuses_url":"https://api.github.com/repos/openT2T/translators/statuses/9f175f7467c3515caf516d4899f62b10f1006cbb","head":{"label":"m-chau:dev","ref":"dev","sha":"9f175f7467c3515caf516d4899f62b10f1006cbb","user":{"login":"m-chau","id":14900903,"avatar_url":"https://avatars.githubusercontent.com/u/14900903?v=3","gravatar_id":"","url":"https://api.github.com/users/m-chau","html_url":"https://github.com/m-chau","followers_url":"https://api.github.com/users/m-chau/followers","following_url":"https://api.github.com/users/m-chau/following{/other_user}","gists_url":"https://api.github.com/users/m-chau/gists{/gist_id}","starred_url":"https://api.github.com/users/m-chau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-chau/subscriptions","organizations_url":"https://api.github.com/users/m-chau/orgs","repos_url":"https://api.github.com/users/m-chau/repos","events_url":"https://api.github.com/users/m-chau/events{/privacy}","received_events_url":"https://api.github.com/users/m-chau/received_events","type":"User","site_admin":false},"repo":{"id":67580298,"name":"translators","full_name":"m-chau/translators","owner":{"login":"m-chau","id":14900903,"avatar_url":"https://avatars.githubusercontent.com/u/14900903?v=3","gravatar_id":"","url":"https://api.github.com/users/m-chau","html_url":"https://github.com/m-chau","followers_url":"https://api.github.com/users/m-chau/followers","following_url":"https://api.github.com/users/m-chau/following{/other_user}","gists_url":"https://api.github.com/users/m-chau/gists{/gist_id}","starred_url":"https://api.github.com/users/m-chau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-chau/subscriptions","organizations_url":"https://api.github.com/users/m-chau/orgs","repos_url":"https://api.github.com/users/m-chau/repos","events_url":"https://api.github.com/users/m-chau/events{/privacy}","received_events_url":"https://api.github.com/users/m-chau/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/m-chau/translators","description":"Repository for Open Translators to Things. ","fork":true,"url":"https://api.github.com/repos/m-chau/translators","forks_url":"https://api.github.com/repos/m-chau/translators/forks","keys_url":"https://api.github.com/repos/m-chau/translators/keys{/key_id}","collaborators_url":"https://api.github.com/repos/m-chau/translators/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/m-chau/translators/teams","hooks_url":"https://api.github.com/repos/m-chau/translators/hooks","issue_events_url":"https://api.github.com/repos/m-chau/translators/issues/events{/number}","events_url":"https://api.github.com/repos/m-chau/translators/events","assignees_url":"https://api.github.com/repos/m-chau/translators/assignees{/user}","branches_url":"https://api.github.com/repos/m-chau/translators/branches{/branch}","tags_url":"https://api.github.com/repos/m-chau/translators/tags","blobs_url":"https://api.github.com/repos/m-chau/translators/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/m-chau/translators/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/m-chau/translators/git/refs{/sha}","trees_url":"https://api.github.com/repos/m-chau/translators/git/trees{/sha}","statuses_url":"https://api.github.com/repos/m-chau/translators/statuses/{sha}","languages_url":"https://api.github.com/repos/m-chau/translators/languages","stargazers_url":"https://api.github.com/repos/m-chau/translators/stargazers","contributors_url":"https://api.github.com/repos/m-chau/translators/contributors","subscribers_url":"https://api.github.com/repos/m-chau/translators/subscribers","subscription_url":"https://api.github.com/repos/m-chau/translators/subscription","commits_url":"https://api.github.com/repos/m-chau/translators/commits{/sha}","git_commits_url":"https://api.github.com/repos/m-chau/translators/git/commits{/sha}","comments_url":"https://api.github.com/repos/m-chau/translators/comments{/number}","issue_comment_url":"https://api.github.com/repos/m-chau/translators/issues/comments{/number}","contents_url":"https://api.github.com/repos/m-chau/translators/contents/{+path}","compare_url":"https://api.github.com/repos/m-chau/translators/compare/{base}...{head}","merges_url":"https://api.github.com/repos/m-chau/translators/merges","archive_url":"https://api.github.com/repos/m-chau/translators/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/m-chau/translators/downloads","issues_url":"https://api.github.com/repos/m-chau/translators/issues{/number}","pulls_url":"https://api.github.com/repos/m-chau/translators/pulls{/number}","milestones_url":"https://api.github.com/repos/m-chau/translators/milestones{/number}","notifications_url":"https://api.github.com/repos/m-chau/translators/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/m-chau/translators/labels{/name}","releases_url":"https://api.github.com/repos/m-chau/translators/releases{/id}","deployments_url":"https://api.github.com/repos/m-chau/translators/deployments","created_at":"2016-09-07T06:53:29Z","updated_at":"2016-09-07T06:53:30Z","pushed_at":"2016-09-14T08:51:28Z","git_url":"git://github.com/m-chau/translators.git","ssh_url":"git@github.com:m-chau/translators.git","clone_url":"https://github.com/m-chau/translators.git","svn_url":"https://github.com/m-chau/translators","homepage":"http://www.opentranslatorstothings.org","size":348,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"master"}},"base":{"label":"openT2T:dev","ref":"dev","sha":"fb04dab4ae91644af59ce168096f322945f73d4d","user":{"login":"openT2T","id":17659874,"avatar_url":"https://avatars.githubusercontent.com/u/17659874?v=3","gravatar_id":"","url":"https://api.github.com/users/openT2T","html_url":"https://github.com/openT2T","followers_url":"https://api.github.com/users/openT2T/followers","following_url":"https://api.github.com/users/openT2T/following{/other_user}","gists_url":"https://api.github.com/users/openT2T/gists{/gist_id}","starred_url":"https://api.github.com/users/openT2T/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openT2T/subscriptions","organizations_url":"https://api.github.com/users/openT2T/orgs","repos_url":"https://api.github.com/users/openT2T/repos","events_url":"https://api.github.com/users/openT2T/events{/privacy}","received_events_url":"https://api.github.com/users/openT2T/received_events","type":"Organization","site_admin":false},"repo":{"id":55200869,"name":"translators","full_name":"openT2T/translators","owner":{"login":"openT2T","id":17659874,"avatar_url":"https://avatars.githubusercontent.com/u/17659874?v=3","gravatar_id":"","url":"https://api.github.com/users/openT2T","html_url":"https://github.com/openT2T","followers_url":"https://api.github.com/users/openT2T/followers","following_url":"https://api.github.com/users/openT2T/following{/other_user}","gists_url":"https://api.github.com/users/openT2T/gists{/gist_id}","starred_url":"https://api.github.com/users/openT2T/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openT2T/subscriptions","organizations_url":"https://api.github.com/users/openT2T/orgs","repos_url":"https://api.github.com/users/openT2T/repos","events_url":"https://api.github.com/users/openT2T/events{/privacy}","received_events_url":"https://api.github.com/users/openT2T/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openT2T/translators","description":"Repository for Open Translators to Things. ","fork":false,"url":"https://api.github.com/repos/openT2T/translators","forks_url":"https://api.github.com/repos/openT2T/translators/forks","keys_url":"https://api.github.com/repos/openT2T/translators/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openT2T/translators/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openT2T/translators/teams","hooks_url":"https://api.github.com/repos/openT2T/translators/hooks","issue_events_url":"https://api.github.com/repos/openT2T/translators/issues/events{/number}","events_url":"https://api.github.com/repos/openT2T/translators/events","assignees_url":"https://api.github.com/repos/openT2T/translators/assignees{/user}","branches_url":"https://api.github.com/repos/openT2T/translators/branches{/branch}","tags_url":"https://api.github.com/repos/openT2T/translators/tags","blobs_url":"https://api.github.com/repos/openT2T/translators/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openT2T/translators/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openT2T/translators/git/refs{/sha}","trees_url":"https://api.github.com/repos/openT2T/translators/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openT2T/translators/statuses/{sha}","languages_url":"https://api.github.com/repos/openT2T/translators/languages","stargazers_url":"https://api.github.com/repos/openT2T/translators/stargazers","contributors_url":"https://api.github.com/repos/openT2T/translators/contributors","subscribers_url":"https://api.github.com/repos/openT2T/translators/subscribers","subscription_url":"https://api.github.com/repos/openT2T/translators/subscription","commits_url":"https://api.github.com/repos/openT2T/translators/commits{/sha}","git_commits_url":"https://api.github.com/repos/openT2T/translators/git/commits{/sha}","comments_url":"https://api.github.com/repos/openT2T/translators/comments{/number}","issue_comment_url":"https://api.github.com/repos/openT2T/translators/issues/comments{/number}","contents_url":"https://api.github.com/repos/openT2T/translators/contents/{+path}","compare_url":"https://api.github.com/repos/openT2T/translators/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openT2T/translators/merges","archive_url":"https://api.github.com/repos/openT2T/translators/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openT2T/translators/downloads","issues_url":"https://api.github.com/repos/openT2T/translators/issues{/number}","pulls_url":"https://api.github.com/repos/openT2T/translators/pulls{/number}","milestones_url":"https://api.github.com/repos/openT2T/translators/milestones{/number}","notifications_url":"https://api.github.com/repos/openT2T/translators/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openT2T/translators/labels{/name}","releases_url":"https://api.github.com/repos/openT2T/translators/releases{/id}","deployments_url":"https://api.github.com/repos/openT2T/translators/deployments","created_at":"2016-04-01T03:25:20Z","updated_at":"2016-08-29T03:50:13Z","pushed_at":"2016-09-14T08:51:29Z","git_url":"git://github.com/openT2T/translators.git","ssh_url":"git@github.com:openT2T/translators.git","clone_url":"https://github.com/openT2T/translators.git","svn_url":"https://github.com/openT2T/translators","homepage":"http://www.opentranslatorstothings.org","size":416,"stargazers_count":21,"watchers_count":21,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":32,"forks":24,"open_issues":32,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openT2T/translators/pulls/96"},"html":{"href":"https://github.com/openT2T/translators/pull/96"},"issue":{"href":"https://api.github.com/repos/openT2T/translators/issues/96"},"comments":{"href":"https://api.github.com/repos/openT2T/translators/issues/96/comments"},"review_comments":{"href":"https://api.github.com/repos/openT2T/translators/pulls/96/comments"},"review_comment":{"href":"https://api.github.com/repos/openT2T/translators/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openT2T/translators/pulls/96/commits"},"statuses":{"href":"https://api.github.com/repos/openT2T/translators/statuses/9f175f7467c3515caf516d4899f62b10f1006cbb"}}}}
{"actor":{"display_login":"danielrischar"}}