{"_id":"@damoclark/cec-monitor","_rev":"12-e0778b509692e9d11d500f2a32fb4bce","name":"@damoclark/cec-monitor","time":{"modified":"2022-06-12T16:51:41.401Z","created":"2017-08-24T13:19:50.905Z","1.0.10-release.1":"2017-08-24T13:19:50.905Z","1.0.10-release.2":"2017-08-24T13:29:19.557Z","1.0.10-release.3":"2017-08-28T02:14:18.011Z","1.0.10-release.4":"2017-10-01T10:45:10.931Z","1.0.10-release.5":"2018-03-30T12:31:35.483Z"},"maintainers":[{"email":"damo.clarky@gmail.com","name":"damoclark"}],"dist-tags":{"latest":"1.0.10-release.5"},"versions":{"1.0.10-release.2":{"name":"@damoclark/cec-monitor","version":"1.0.10-release.2","description":"Fork of @senzil/cec-monitor - HDMI-CEC library with a simple monitor written on ES6 to make cec enabled apps.","author":{"name":"SENZIL SRL","email":"contact@senzil.com","url":"https://www.senzil.com"},"collaborators":[{"name":"Pablo González","email":"pablodgonzalez@gmail.com","web":"https://github.com/pablodgonzalez"},{"name":"Damien Clark","email":"damo.clarky@gmail.com","web":"https://damos.world"}],"main":"index.js","bin":{"cec-monitor":"./bin/cli.js"},"keywords":["cec","hdmi","monitor","wrapper"],"scripts":{"build":"babel src -d lib","test":"babel src -d lib && node test/test.js","prepublishOnly":"npm run build"},"devDependencies":{"babel-cli":"^6.24.1","babel-env":"^2.4.1","babel-eslint":"^7.2.3","babel-plugin-transform-class-properties":"^6.24.1","eslint":"^4.2.0","pre-commit":"^1.2.2"},"repository":{"type":"git","url":"git+ssh://git@github.com/damoclark/cec-monitor.git"},"license":"MIT","dependencies":{"death":"^1.1.0","event-stream":"^3.3.4"},"gitHead":"7097b916d0fb1c83a49853f041198a2103d44e1a","bugs":{"url":"https://github.com/damoclark/cec-monitor/issues"},"homepage":"https://github.com/damoclark/cec-monitor#readme","_id":"@damoclark/cec-monitor@1.0.10-release.2","_shasum":"f292649777ff3f4b5af8fb4352f675aa3323c4cd","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.2","_npmUser":{"name":"damoclark","email":"damo.clarky@gmail.com"},"dist":{"shasum":"f292649777ff3f4b5af8fb4352f675aa3323c4cd","tarball":"https://registry.npmjs.org/@damoclark/cec-monitor/-/cec-monitor-1.0.10-release.2.tgz","integrity":"sha512-v8Vl/qLF4MCJGMhUqwQvTF/Fq3o8IPCwIfYsjvcx1WhHEfEpsqfertr3V70mA7EfmDsOXKi5woMH1BxjNuUUYw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICB/zXxPzHdAW4d3bPnn5DZeksagsA9M6AujoD60KfFTAiEA/kJ5odmDUvF2ReCFalTCRUlLfsX1UacHBEodiPJjpng="}]},"maintainers":[{"email":"damo.clarky@gmail.com","name":"damoclark"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cec-monitor-1.0.10-release.2.tgz_1503581359135_0.7844567804131657"},"directories":{}},"1.0.10-release.3":{"name":"@damoclark/cec-monitor","version":"1.0.10-release.3","description":"Fork of @senzil/cec-monitor - HDMI-CEC library with a simple monitor written on ES6 to make cec enabled apps.","author":{"name":"SENZIL SRL","email":"contact@senzil.com","url":"https://www.senzil.com"},"collaborators":[{"name":"Pablo González","email":"pablodgonzalez@gmail.com","web":"https://github.com/pablodgonzalez"},{"name":"Damien Clark","email":"damo.clarky@gmail.com","web":"https://damos.world"}],"main":"index.js","bin":{"cec-monitor":"./bin/cli.js"},"keywords":["cec","hdmi","monitor","wrapper"],"scripts":{"build":"babel src -d lib","test":"babel src -d lib && node test/test.js","prepublishOnly":"npm run build"},"devDependencies":{"babel-cli":"^6.24.1","babel-env":"^2.4.1","babel-eslint":"^7.2.3","babel-plugin-transform-class-properties":"^6.24.1","eslint":"^4.2.0","pre-commit":"^1.2.2"},"repository":{"type":"git","url":"git+ssh://git@github.com/damoclark/cec-monitor.git"},"license":"MIT","dependencies":{"death":"^1.1.0","event-stream":"^3.3.4"},"gitHead":"8b174663231a21fe46a03cefc6e2e4f0493ccbc4","bugs":{"url":"https://github.com/damoclark/cec-monitor/issues"},"homepage":"https://github.com/damoclark/cec-monitor#readme","_id":"@damoclark/cec-monitor@1.0.10-release.3","_shasum":"10213d82c3e4a2e2a6a3b99320d72f5856f85dcd","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.2","_npmUser":{"name":"damoclark","email":"damo.clarky@gmail.com"},"dist":{"shasum":"10213d82c3e4a2e2a6a3b99320d72f5856f85dcd","tarball":"https://registry.npmjs.org/@damoclark/cec-monitor/-/cec-monitor-1.0.10-release.3.tgz","integrity":"sha512-A3Mqpn/U2rSfaOPu5batwvV5qu055AP+XpmjXrgjz2MfgkMeLKnA8Ib9i1QjpcirHsG+wI8DHzO8iGErjOj4Jw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBURo4MPq+PCuSHml5wxOQedDgrNoUsc68qbdsS7hXFRAiEA/CUwWNmwXwOASAFUPKJ7tRsQMR+oCN+0b0uUf1iU7Nk="}]},"maintainers":[{"email":"damo.clarky@gmail.com","name":"damoclark"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cec-monitor-1.0.10-release.3.tgz_1503886457790_0.28497337573207915"},"directories":{}},"1.0.10-release.4":{"name":"@damoclark/cec-monitor","version":"1.0.10-release.4","description":"Fork of @senzil/cec-monitor - HDMI-CEC library with a simple monitor written on ES6 to make cec enabled apps.","author":{"name":"SENZIL SRL","email":"contact@senzil.com","url":"https://www.senzil.com"},"collaborators":[{"name":"Pablo González","email":"pablodgonzalez@gmail.com","web":"https://github.com/pablodgonzalez"},{"name":"Damien Clark","email":"damo.clarky@gmail.com","web":"https://damos.world"}],"main":"index.js","bin":{"cec-monitor":"./bin/cli.js"},"keywords":["cec","hdmi","monitor","wrapper"],"scripts":{"build":"babel src -d lib","test":"babel src -d lib && node test/test.js","prepublishOnly":"npm run build"},"devDependencies":{"babel-cli":"^6.24.1","babel-env":"^2.4.1","babel-eslint":"^7.2.3","babel-plugin-transform-class-properties":"^6.24.1","eslint":"^4.2.0","pre-commit":"^1.2.2"},"repository":{"type":"git","url":"git+ssh://git@github.com/damoclark/cec-monitor.git"},"license":"MIT","dependencies":{"death":"^1.1.0","event-stream":"^3.3.4"},"gitHead":"ba061f9d5b9df86570f7c07ef4a02a247f93c792","bugs":{"url":"https://github.com/damoclark/cec-monitor/issues"},"homepage":"https://github.com/damoclark/cec-monitor#readme","_id":"@damoclark/cec-monitor@1.0.10-release.4","_npmVersion":"5.4.0","_nodeVersion":"6.11.2","_npmUser":{"name":"damoclark","email":"damo.clarky@gmail.com"},"dist":{"integrity":"sha512-j0RdQ8CS2DGxhnXVlb1eLlDTf9Hl6huOk/mLKtX1IWXnNsgovtPC/RaTMvCfXeRM/J4X4sNmzQU7pfV6ZgkvJg==","shasum":"238d4f01f3f933c27b6088c228034a158a8b67d8","tarball":"https://registry.npmjs.org/@damoclark/cec-monitor/-/cec-monitor-1.0.10-release.4.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDrpeubWwLbRKo+JTppGKUGHh1/RiVTPXY4R4S6/Bb2PwIgD4rZXhXSjT3hAZB19X0pRVXCxw0hA0fElTgg7h/jRCc="}]},"maintainers":[{"email":"damo.clarky@gmail.com","name":"damoclark"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cec-monitor-1.0.10-release.4.tgz_1506854710847_0.8407446930650622"},"directories":{}},"1.0.10-release.5":{"name":"@damoclark/cec-monitor","version":"1.0.10-release.5","description":"Fork of @senzil/cec-monitor - HDMI-CEC library with a simple monitor written on ES6 to make cec enabled apps.","author":{"name":"SENZIL SRL","email":"contact@senzil.com","url":"https://www.senzil.com"},"collaborators":[{"name":"Pablo González","email":"pablodgonzalez@gmail.com","web":"https://github.com/pablodgonzalez"},{"name":"Damien Clark","email":"damo.clarky@gmail.com","web":"https://damos.world"}],"main":"index.js","bin":{"cec-monitor":"./bin/cli.js"},"keywords":["cec","hdmi","monitor","wrapper"],"scripts":{"build":"babel src -d lib","test":"babel src -d lib && node test/test.js","prepublishOnly":"npm run build"},"devDependencies":{"babel-cli":"^6.24.1","babel-env":"^2.4.1","babel-eslint":"^7.2.3","babel-plugin-transform-class-properties":"^6.24.1","eslint":"^4.2.0","pre-commit":"^1.2.2"},"repository":{"type":"git","url":"git+ssh://git@github.com/damoclark/cec-monitor.git"},"license":"MIT","dependencies":{"death":"^1.1.0","event-stream":"^3.3.4"},"gitHead":"0fb8a926e3ed608dca638bbd0168bf48d7bec8cd","bugs":{"url":"https://github.com/damoclark/cec-monitor/issues"},"homepage":"https://github.com/damoclark/cec-monitor#readme","_id":"@damoclark/cec-monitor@1.0.10-release.5","_npmVersion":"5.4.0","_nodeVersion":"6.11.2","_npmUser":{"name":"damoclark","email":"damo.clarky@gmail.com"},"dist":{"integrity":"sha512-s8ALqVr7KEtR8Q868OryT8TQTEUL4RM8EpZXmkVWEzlhLqvcrKsDZJQUJe5hezVYTFanuEDht07XSJqHSzr9Mg==","shasum":"f94ace9d6c1059d8a92d480c0b313052fb4a1a21","tarball":"https://registry.npmjs.org/@damoclark/cec-monitor/-/cec-monitor-1.0.10-release.5.tgz","fileCount":12,"unpackedSize":115411,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIChmf3yM8K3brzZal4HOqfQhOYh8XwFhnlbBaZUapzzoAiAH3vDjmEgIgePTBSUhAYMyh5h10Hzcm0R88NjnxLfmeQ=="}]},"maintainers":[{"email":"damo.clarky@gmail.com","name":"damoclark"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cec-monitor_1.0.10-release.5_1522413095409_0.317499167088249"},"_hasShrinkwrap":false}},"readme":"# cec-monitor\nHDMI-CEC library with a simple monitor written on ES6 to make cec enabled apps.\n\n## Install\n\n```bash\nnpm install --save @senzil/cec-monitor\n```\n\n## Examples\n\n### Events\n\n```javascript\nimport {CEC, CECMonitor} from 'cec-monitor';\n\n//All config options are optionals\nlet monitor = new CECMonitor('custom-osdname', {\n  debug: false,           // enable/disabled debug events from cec-client\n  hdmiport: 1,            // set inital hdmi port\n  processManaged: false,  // set/unset handlers to avoid unclear process exit.\n  recorder: true,         //enable cec-client as recorder device\n  player: false,          //enable cec-client as player device\n  tuner: false,           //enable cec-client as tuner device\n  audio: false,           //enable cec-client as audio system device\n  autorestart: true,      //enable autrestart cec-client to avoid some wierd conditions\n  no_serial: {            //controls if the monitor restart cec-client when that stop after the usb was unplugged\n    reconnect: false,       //enable reconnection attempts when usb is unplugged\n    wait_time: 30,          //in seconds - time to do the attempt\n    trigger_stop: false     //avoid trigger stop event\n  }\n});\n\n\nmonitor.once(CECMonitor.EVENTS._READY, function() {\n  console.log( ' -- READY -- ' );\n  // Low-level\n  monitor.WriteMessage(CEC.LogicalAddress.BROADCAST, CEC.LogicalAddress.TV, CEC.Opcode.GIVE_DEVICE_POWER_STATUS);\n  // High-level\n  monitor.SendMessage(null,null,CEC.Opcode.SET_OSD_NAME,'Plex'); // Broadcast my OSD Name\n  monitor.SendMessage(null, CEC.LogicalAddress.TV, CEC.Opcode.GIVE_OSD_NAME); // Ask TV for OSD Name\n});\n\nmonitor.on(CECMonitor.EVENTS.REPORT_POWER_STATUS, function (packet) {\n  console.log('POWER STATUS CODE:',packet.data.val);\n  console.log('POWER STATUS:',packet.data.str);\n});\n\nmonitor.on(CECMonitor.EVENTS.ROUTING_CHANGE, function(packet) {\n  console.log( 'Routing changed from ' + packet.data.from.str + ' to ' + packet.data.to.str + '.' );\n});\n\nmonitor.on(CECMonitor.EVENTS.SET_OSD_NAME, function(packet) {\n  console.log( 'Logical address ' + packet.source + 'has OSD name ' + packet.data.str);\n});\n\n// Any packet with an opcode (excludes debug, notify and other message types from cec-client\nmonitor.on(CECMonitor.EVENTS._OPCODE, function(packet) {\n  console.log(packet);\n});\n```\n\nOpcode-based events emitted provide a single parameter `packet` to the callback. The value is an object of the form:\n\n```json\n{\n  \"type\": \"TRAFFIC\", \"number\": \"82784\", \"flow\": \"IN\", \n  \"source\": 1, \"target\": 4, \"opcode\": 144, \"args\": [0],\n  \"event\": \"REPORT_POWER_STATUS\", \n  \"data\": {\"val\": 0, \"str\": \"ON\"}\n}\n```\n\nPackets containing the following opcodes that are received are parsed, with the results added to a\n`data` property.\n\n* CEC.Opcode.ACTIVE_SOURCE\n* CEC.Opcode.CEC_VERSION\n* CEC.Opcode.DECK_STATUS\n* CEC.Opcode.DEVICE_VENDOR_ID\n* CEC.Opcode.REPORT_PHYSICAL_ADDRESS\n* CEC.Opcode.REPORT_POWER_STATUS\n* CEC.Opcode.ROUTING_CHANGE\n* CEC.Opcode.SET_OSD_NAME\n\nThe `data` property contains the raw value, and a string representation of the parsed results stored\nin the `arg` property, based on the `event` type / `opcode` value.  Where multiple values are parsed\nfrom `args`, a substructure is created in the `data` property, as shown below for `ROUTING_CHANGE`.\n\n```json\n{\n  \"type\": \"TRAFFIC\", \"number\": \"23553258\", \"flow\": \"IN\",\n  \"source\": 0, \"target\": 1 5, \"opcode\": 128, \"args\": [0, 0, 16, 0],\n  \"event\": \"ROUTING_CHANGE\",\n  \"data\": {\n    \"from\": {\"val\": 0, \"str\": \"0.0.0.0\"},\n    \"to\": {\"val\": 4096, \"str\": \"1.0.0.0\"}\n  }\n}\n```\n\n### Sending CEC Messages\n\nThere are three APIs to choose from to send a message on the bus.  This section discusses each of these\nmethods, with examples.  \n\nThe message used in the examples broadcasts a SET_OSD_NAME message on the bus, setting playbackdevice1 \n(logical address 04) on screen name to 'Frisbee'.\n\n#### WriteRawMessage\n\n`WriteRawMessage(raw)`\n\n`WriteRawMessage` writes the low-level commands to `cec-client`.  Use this method as you type commands\ndirectly to `cec-client` itself at the command line.  \n\n```javascript\nmonitor.WriteRawMessage('tx 0F:46:46:72:69:73:62:65:65');\n```\n\n#### WriteMessage\n\n`WriteMessage(source, target, opcode, args)`\n\n`WriteMessage` is used to write `tx` messages to `cec-client`.  These are messages containing a low-level\nprotocol `opcode`.  Unlike `WriteRawMessage` which takes a string, and is sent unchanged, `WriteMessage` \nhas a parameter list, and constructs a raw command from these parameters to send to `cec-client`.  \n\n```javascript\nmonitor.SendMessage(CEC.LogicalAddress.PLAYBACKDEVICE1, CEC.LogicalAddress.BROADCAST, CEC.Opcode.SET_OSD_NAME,[0x46,0x72,0x69,0x73,0x62,0x65,0x65]);\n```\n\n#### SendMessage\n\n`WriteMessage(source, target, opcode, args)`\n\n`SendMessage` is a high-level API of the same form as WriteMessage, but accepts a range of different data\ntypes and formats as input.  This is useful when sending messages from user input.  The following examples\nillustrate how to use SendMessage\n\n```javascript\nmonitor.SendMessage(CEC.LogicalAddress.PLAYBACKDEVICE1, CEC.LogicalAddress.BROADCAST, CEC.Opcode.SET_OSD_NAME,[0x46,0x72,0x69,0x73,0x62,0x65,0x65]);\n\nmonitor.SendMessage(4, 15, 70, [70,114,105,115,98,101,101];\n\nmonitor.SendMessage('0x4', '0xF', '0x46', [0x46,0x72,0x69,0x73,0x62,0x65,0x65]);\n\nmonitor.SendMessage('PLAYBACKDEVICE1','BROADCAST','SET_OSD_NAME','Frisbee');\n\nmonitor.SendMessage('playbackdevice1', 'broadcast', 'set_osd_name','Frisbee');\n\n// Can specify physical address as string, using dot notation\nmonitor.SendMessage(CEC.LogicalAddress.UNREGISTERED, CEC.LogicalAddress.BROADCAST, CEC.Opcode.ACTIVE_SOURCE,'2.0.0.0');\n\n// Or as an array of bytes\nmonitor.SendMessage(CEC.LogicalAddress.UNREGISTERED, CEC.LogicalAddress.BROADCAST, CEC.Opcode.ACTIVE_SOURCE,[0x20,0x0]);\n\n// Default source is the client - default destination is broadcast\nmonitor.SendMessage(null,null, 'set_osd_name','Frisbee');\n```\n\n### cli.js\n\nYou can experiment with how cec-monitor works and the codes generated with your HDMI connected equipment by \nexperimenting with the `bin/cli.js` script. This script implements a simple readline command interface where you can \nexecute instructions and see how cec-monitor responds, allowing you to adapt to your requirements. Press `TAB` for\nautocompletion of commands to see what it does and how to use it.\n\n## Roadmap\n\n* ~~Improve constructor to improve cec-client configuration~~\n* Implement more events with more context info\n* Implement some user control actions as special events (combining USER_CONTROL_PRESSED and USERCONTROL RELEASE events)\n* **Implement a ceclib adapter to avoid use a cec-client wrapper**\n\n## Credits\n**_nanos gigantum humeris insidentes_**\n\nThis work was based over the work of\n\n* http://www.cec-o-matic.com/\n* https://github.com/patlux/node-cec\n\n# License\n\nThe MIT License (MIT)\n\nCopyright 2017 SENZIL SRL\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","readmeFilename":"README.md","description":"Fork of @senzil/cec-monitor - HDMI-CEC library with a simple monitor written on ES6 to make cec enabled apps.","homepage":"https://github.com/damoclark/cec-monitor#readme","keywords":["cec","hdmi","monitor","wrapper"],"repository":{"type":"git","url":"git+ssh://git@github.com/damoclark/cec-monitor.git"},"author":{"name":"SENZIL SRL","email":"contact@senzil.com","url":"https://www.senzil.com"},"bugs":{"url":"https://github.com/damoclark/cec-monitor/issues"},"license":"MIT"}