{"action":"created","issue":{"url":"https://api.github.com/repos/andreek/node-eibd/issues/15","labels_url":"https://api.github.com/repos/andreek/node-eibd/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/andreek/node-eibd/issues/15/comments","events_url":"https://api.github.com/repos/andreek/node-eibd/issues/15/events","html_url":"https://github.com/andreek/node-eibd/pull/15","id":102885165,"number":15,"title":"Subscription functions","user":{"login":"snowdd1","id":11786396,"avatar_url":"https://avatars.githubusercontent.com/u/11786396?v=3","gravatar_id":"","url":"https://api.github.com/users/snowdd1","html_url":"https://github.com/snowdd1","followers_url":"https://api.github.com/users/snowdd1/followers","following_url":"https://api.github.com/users/snowdd1/following{/other_user}","gists_url":"https://api.github.com/users/snowdd1/gists{/gist_id}","starred_url":"https://api.github.com/users/snowdd1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snowdd1/subscriptions","organizations_url":"https://api.github.com/users/snowdd1/orgs","repos_url":"https://api.github.com/users/snowdd1/repos","events_url":"https://api.github.com/users/snowdd1/events{/privacy}","received_events_url":"https://api.github.com/users/snowdd1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-24T20:33:19Z","updated_at":"2015-08-28T10:03:23Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/andreek/node-eibd/pulls/15","html_url":"https://github.com/andreek/node-eibd/pull/15","diff_url":"https://github.com/andreek/node-eibd/pull/15.diff","patch_url":"https://github.com/andreek/node-eibd/pull/15.patch"},"body":"I would like to introduce two new functions for the convenience of nodeJS programmers to use callbacks for specific addresses.\r\nInstead of subscribing to the 'write' or 'response' events directly and parsing the answers themselves, programmers can use these prepared functions.\r\n\r\nregisterGA(address, callback)\r\nstartMonitor(opts)\r\n\r\nWith that, eibd can be directly integrate in node apps, such as khaosT/HAP-nodeJS or nfarina/homebridge, and possible several more\r\n\r\nTested on my raspberry with node 0.12.1 and knxd on a separated machine."},"comment":{"url":"https://api.github.com/repos/andreek/node-eibd/issues/comments/135725601","html_url":"https://github.com/andreek/node-eibd/pull/15#issuecomment-135725601","issue_url":"https://api.github.com/repos/andreek/node-eibd/issues/15","id":135725601,"user":{"login":"andreek","id":1627377,"avatar_url":"https://avatars.githubusercontent.com/u/1627377?v=3","gravatar_id":"","url":"https://api.github.com/users/andreek","html_url":"https://github.com/andreek","followers_url":"https://api.github.com/users/andreek/followers","following_url":"https://api.github.com/users/andreek/following{/other_user}","gists_url":"https://api.github.com/users/andreek/gists{/gist_id}","starred_url":"https://api.github.com/users/andreek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreek/subscriptions","organizations_url":"https://api.github.com/users/andreek/orgs","repos_url":"https://api.github.com/users/andreek/repos","events_url":"https://api.github.com/users/andreek/events{/privacy}","received_events_url":"https://api.github.com/users/andreek/received_events","type":"User","site_admin":false},"created_at":"2015-08-28T10:03:23Z","updated_at":"2015-08-28T10:03:23Z","body":"Hey,\r\n\r\nI think its a great feature to register callbacks for all events on specific addresses. Unfortunately this feature can be introduced to node-eibd more easily than your way. \r\n\r\n```javascript\r\nself.emit(event, tools.addr2str(src, false), tools.addr2str(dest, true), type, value);\r\n```\r\nhttps://github.com/andreek/node-eibd/blob/master/lib/parser.js#L83\r\n\r\n```javascript\r\nself.emit(event, tools.addr2str(src, false), tools.addr2str(dest, true));\r\n```\r\nhttps://github.com/andreek/node-eibd/blob/master/lib/parser.js#L89\r\n\r\nI would extend both lines to emit events for destination address. Like:\r\n\r\n```javascript\r\n// emit action event\r\nself.emit(event, tools.addr2str(src, false), tools.addr2str(dest, true), type, value);\r\n// emit dest address event\r\nself.emit(tools.addr2str(dest, true), event, tools.addr2str(src, false), tools.addr2str(dest, true), type, value);\r\n```\r\nhttps://github.com/andreek/node-eibd/blob/master/lib/parser.js#L83\r\n\r\n```javascript\r\n// emit action event\r\nself.emit(event, tools.addr2str(src, false), tools.addr2str(dest, true));\r\n// emit dest address event\r\nself.emit(tools.addr2str(dest, true), event, tools.addr2str(src, false), tools.addr2str(dest, true));\r\n```\r\nhttps://github.com/andreek/node-eibd/blob/master/lib/parser.js#L89\r\n\r\nSo you can register your specific callbacks for a address to the parser:\r\n```javascript\r\nparser.on('1/1/1', function(event, src, dest, type, value) {});\r\n```"}}