swissmanu / harmonyhubjs-client

A Node.JS library which allows you to interact with your Logitech Harmony Hub.
https://github.com/swissmanu/harmonyhubjs-client
MIT License
155 stars 42 forks source link

I want just "IRCommand" send... not startActivity #5

Closed rubyon closed 9 years ago

rubyon commented 9 years ago

I want just "IRCommand" send... not startActivity

Is this possible?

please let me show sample code...

swissmanu commented 9 years ago

harmonyclient.js#sendCommand should allow you to do this. further does your hub expose a list of available commands. you can retrieve this list via harmonyclient.js#getAvailableCommands

please let us know how this works out.

rubyon commented 9 years ago

I get this data

harmonyhubjs:client:harmonyclient handleStanza({"activity":[{"suggestedDisplay":"Default","isAVActivity":false,"label":"PowerOff","id":"-1","activityTypeDisplayName":"Default","controlGroup":[],"sequences":[],"fixit":{"27304162":{"id":"27304162","Power":"Off"},"27303771":{"id":"27303771","Power":"Off"},"27304001":{"id":"27304001","isRelativePower":true,"Power":"Off"}},"rules":[],"icon":"Default","type":"PowerOff"},{"type":"VirtualGeneric","isAVActivity":true,"label":"iclebo","id":"14277810","activityTypeDisplayName":"Default","sequences":[],"isTuningDefault":false,"controlGroup":[{"name":"NumericBasic","function":[{"action":"{\"command\":\"0\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number0","label":"0"},{"action":"{\"command\":\"1\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number1","label":"1"},{"action":"{\"command\":\"2\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number2","label":"2"},{"action":"{\"command\":\"3\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number3","label":"3"},{"action":"{\"command\":\"4\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number4","label":"4"},{"action":"{\"command\":\"5\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number5","label":"5"},{"action":"{\"command\":\"6\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number6","label":"6"},{"action":"{\"command\":\"7\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number7","label":"7"},{"action":"{\"command\":\"8\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number8","label":"8"},{"action":"{\"command\":\"9\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number9","label":"9"}]},{"name":"NavigationBasic","function":[{"action":"{\"command\":\"DirectionDown\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"DirectionDown","label":"Direction Down"},{"action":"{\"command\":\"DirectionLeft\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"DirectionLeft","label":"Direction Left"},{"action":"{\"command\":\"DirectionRight\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"DirectionRight","label":"Direction Right"},{"action":"{\"command\":\"DirectionUp\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"DirectionUp","label":"Direction Up"}]},{"name":"TransportBasic","function":[{"action":"{\"command\":\"Stop\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Stop","label":"Stop"},{"action":"{\"command\":\"Play\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Play","label":"Play"},{"action":"{\"command\":\"Rewind\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Rewind","label":"Rewind"},{"action":"{\"command\":\"Eject\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Eject","label":"Eject"},{"action":"{\"command\":\"Pause\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Pause","label":"Pause"},{"action":"{\"command\":\"FastForward\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"FastForward","label":"Fast Forward"}]},{"name":"TransportExtended","function":[{"action":"{\"command\":\"ChapterPrev\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"SkipBackward","label":"Skip Backward"},{"action":"{\"command\":\"ChapterNext\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"SkipForward","label":"Skip Forward"}]},{"name":"NavigationDVD","function":[{"action":"{\"command\":\"TopMenu\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"TopMenu","label":"Top Menu"},{"action":"{\"command\":\"Menu\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Menu","label":"Menu"},{"action":"{\"command\":\"Subtitle\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Subtitle","label":"Subtitle"}]},{"name":"NavigationExtended","function":[{"action":"{\"command\":\"Cancel\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Cancel","label":"Cancel"}]}],"rules":[],"imageKey":"Activity\/7A38712D-0BB0-4D3C-B9AF-D54FF86CC9CC.png","activityOrder":1,"fixit":{"27304162":{"id":"27304162","Power":"Off"},"27303771":{"id":"27303771","Power":"Off"},"27304001":{"id":"27304001","isRelativePower":true,"Power":"On"}},"baseImageUri":"https:\/\/rcbu-test-ssl-amr.s3.amazonaws.com\/","icon":"userdata: 0x4454e0","suggestedDisplay":"Default"},{"type":"VirtualGeneric","isAVActivity":true,"label":"aircon on","id":"14277612","activityTypeDisplayName":"Default","sequences":[],"isTuningDefault":false,"controlGroup":[],"rules":[],"imageKey":"Activity\/3AEBFA09-DE9A-46F5-86FB-AC5E585295FB.png","activityOrder":0,"fixit":{"27304162":{"id":"27304162","Power":"Off"},"27303771":{"id":"27303771","Power":"On"},"27304001":{"id":"27304001","isRelativePower":true,"Power":"Off"}},"baseImageUri":"https:\/\/rcbu-test-ssl-amr.s3.amazonaws.com\/","icon":"userdata: 0x4454e0","suggestedDisplay":"Default"}],"device":[{"Transport":33,"suggestedDisplay":"DEFAULT","deviceTypeDisplayName":"AppleTV","label":"Apple TV","id":"27304162","Capabilities":[3,5,6,12,16,17,26],"type":"Default","DongleRFID":0,"controlGroup":[{"name":"Volume","function":[{"action":"{\"command\":\"Mute\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"Mute","label":"Mute"},{"action":"{\"command\":\"VolumeDown\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"VolumeDown","label":"Volume Down"},{"action":"{\"command\":\"VolumeUp\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"VolumeUp","label":"Volume Up"}]},{"name":"Channel","function":[{"action":"{\"command\":\"ChannelDown\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"ChannelDown","label":"Channel Down"},{"action":"{\"command\":\"ChannelUp\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"ChannelUp","label":"Channel Up"}]},{"name":"NavigationBasic","function":[{"action":"{\"command\":\"DirectionDown\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"DirectionDown","label":"Direction Down"},{"action":"{\"command\":\"DirectionLeft\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"DirectionLeft","label":"Direction Left"},{"action":"{\"command\":\"DirectionRight\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"DirectionRight","label":"Direction Right"},{"action":"{\"command\":\"DirectionUp\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"DirectionUp","label":"Direction Up"},{"action":"{\"command\":\"Select\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"Select","label":"Select"}]},{"name":"TransportBasic","function":[{"action":"{\"command\":\"Stop\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"Stop","label":"Stop"},{"action":"{\"command\":\"Play\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"Play","label":"Play"},{"action":"{\"command\":\"Rewind\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"Rewind","label":"Rewind"},{"action":"{\"command\":\"Pause\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"Pause","label":"Pause"},{"action":"{\"command\":\"FastForward\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"FastForward","label":"Fast Forward"}]},{"name":"TransportExtended","function":[{"action":"{\"command\":\"SkipBack\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"SkipBackward","label":"Skip Backward"},{"action":"{\"command\":\"SkipForward\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"SkipForward","label":"Skip Forward"}]},{"name":"NavigationDVD","function":[{"action":"{\"command\":\"Menu\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"Menu","label":"Menu"},{"action":"{\"command\":\"Back\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"Back","label":"Back"}]},{"name":"NavigationExtended","function":[{"action":"{\"command\":\"PageDown\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"PageDown","label":"Page Down"},{"action":"{\"command\":\"PageUp\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"PageUp","label":"Page Up"}]},{"name":"GoogleTVNavigation","function":[{"action":"{\"command\":\"Delete\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"Delete","label":"Backspace"}]},{"name":"Miscellaneous","function":[{"action":"{\"command\":\"Home\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"Home","label":"Home"},{"action":"{\"command\":\"NextChapter\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"NextChapter","label":"NextChapter"},{"action":"{\"command\":\"Pair\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"Pair","label":"Pair"},{"action":"{\"command\":\"PrevChapter\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"PrevChapter","label":"PrevChapter"},{"action":"{\"command\":\"Reset\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"Reset","label":"Reset"},{"action":"{\"command\":\"UnPair\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"UnPair","label":"UnPair"},{"action":"{\"command\":\"VideoMode\",\"type\":\"IRCommand\",\"deviceId\":\"27304162\"}","name":"VideoMode","label":"VideoMode"}]}],"ControlPort":7,"IsKeyboardAssociated":false,"model":"Apple TV","deviceProfileUri":"svcs.myharmony.com\/res\/device\/27304162-n1B6VWRpQRrwXNHBN5ZTkSfRLGzpn9Nl8fykDn9vXvU=","manufacturer":"Apple","icon":"51","isManualPower":"false"},{"Transport":1,"suggestedDisplay":"DEFAULT","deviceTypeDisplayName":"HomeAppliance","label":"iclebo pop","id":"27304001","Capabilities":[],"type":"HomeAppliance","DongleRFID":0,"controlGroup":[{"name":"Power","function":[{"action":"{\"command\":\"PowerToggle\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"PowerToggle","label":"Power Toggle"}]},{"name":"NumericBasic","function":[{"action":"{\"command\":\"0\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number0","label":"0"},{"action":"{\"command\":\"1\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number1","label":"1"},{"action":"{\"command\":\"2\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number2","label":"2"},{"action":"{\"command\":\"3\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number3","label":"3"},{"action":"{\"command\":\"4\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number4","label":"4"},{"action":"{\"command\":\"5\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number5","label":"5"},{"action":"{\"command\":\"6\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number6","label":"6"},{"action":"{\"command\":\"7\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number7","label":"7"},{"action":"{\"command\":\"8\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number8","label":"8"},{"action":"{\"command\":\"9\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Number9","label":"9"}]},{"name":"NavigationBasic","function":[{"action":"{\"command\":\"DirectionDown\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"DirectionDown","label":"Direction Down"},{"action":"{\"command\":\"DirectionLeft\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"DirectionLeft","label":"Direction Left"},{"action":"{\"command\":\"DirectionRight\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"DirectionRight","label":"Direction Right"},{"action":"{\"command\":\"DirectionUp\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"DirectionUp","label":"Direction Up"}]},{"name":"TransportBasic","function":[{"action":"{\"command\":\"Stop\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Stop","label":"Stop"},{"action":"{\"command\":\"Play\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Play","label":"Play"},{"action":"{\"command\":\"Rewind\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Rewind","label":"Rewind"},{"action":"{\"command\":\"Eject\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Eject","label":"Eject"},{"action":"{\"command\":\"Pause\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Pause","label":"Pause"},{"action":"{\"command\":\"FastForward\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"FastForward","label":"Fast Forward"}]},{"name":"TransportExtended","function":[{"action":"{\"command\":\"ChapterPrev\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"SkipBackward","label":"Skip Backward"},{"action":"{\"command\":\"ChapterNext\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"SkipForward","label":"Skip Forward"}]},{"name":"NavigationDVD","function":[{"action":"{\"command\":\"TopMenu\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"TopMenu","label":"Top Menu"},{"action":"{\"command\":\"Menu\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Menu","label":"Menu"},{"action":"{\"command\":\"Subtitle\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Subtitle","label":"Subtitle"},{"action":"{\"command\":\"Audio\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Audio","label":"Audio"},{"action":"{\"command\":\"Angle\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Angle","label":"Angle"}]},{"name":"NavigationExtended","function":[{"action":"{\"command\":\"Cancel\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Cancel","label":"Cancel"}]},{"name":"DisplayMode","function":[{"action":"{\"command\":\"Display\",\"type\":\"IRCommand\",\"deviceId\":\"27304001\"}","name":"Display","label":"Display"}]}],"ControlPort":7,"IsKeyboardAssociated":false,"model":"pop","deviceProfileUri":"svcs.myharmony.com\/res\/device\/27304001-NI5RzJZCWsbeYr1f1il2MzsYgIfYIJeb4LeFgwxBMUM=","manufacturer":"iclebo","icon":"44","isManualPower":"false"},{"Transport":1,"suggestedDisplay":"DEFAULT","deviceTypeDisplayName":"ClimateControl","label":"Samsung aircon","id":"27303771","Capabilities":[],"type":"ClimateControl","DongleRFID":0,"controlGroup":[{"name":"Home","function":[{"action":"{\"command\":\"Power Off\",\"type\":\"IRCommand\",\"deviceId\":\"27303771\"}","name":"PowerOff","label":"Power Off"},{"action":"{\"command\":\"Power On\",\"type\":\"IRCommand\",\"deviceId\":\"27303771\"}","name":"PowerOn","label":"Power On"}]},{"name":"Miscellaneous","function":[{"action":"{\"command\":\"19\",\"type\":\"IRCommand\",\"deviceId\":\"27303771\"}","name":"19","label":"19"},{"action":"{\"command\":\"20\",\"type\":\"IRCommand\",\"deviceId\":\"27303771\"}","name":"20","label":"20"}]}],"ControlPort":7,"IsKeyboardAssociated":false,"model":"aircon","deviceProfileUri":"svcs.myharmony.com\/res\/device\/27303771-Qgu7QkBsO8xyjQQIZbkNGAnf9GEKd4xCSTb1C2QKfm0=","manufacturer":"Samsung","icon":"45","isManualPower":"false"}],"sequence":[],"content":{"contentUserHost":"https:\/\/content.dhg.myharmony.com\/1.0\/User;{userProfileUri}","contentDeviceHost":"https:\/\/content.dhg.myharmony.com\/1.0\/Device;{deviceProfileUri}","contentServiceHost":"https:\/\/content.dhg.myharmony.com\/1.0\/Service\/{providerId}","contentImageHost":"https:\/\/d1tk8oqnnsddt5.cloudfront.net\/1.0\/station\/{stationId}\/image;maxX=40;maxY=40","householdUserProfileUri":"svcs.myharmony.com\/res\/\/household\/5745767-4cic2HioNImoUnH88\/V\/eo6JLGlkf2IyDzPLI\/W3TcU=\/user\/default"},"global":{"timeStampHash":"0344f4d9-a0b4-4a06-8176-e8b0b8e0f0b63b1ebc10-8699-410b-a9c0-697289188eb5\/5a4d051f-2546-414c-a543-6fda9608f087f09c9f44-eb8b-430d-bcb0-583e1da0c45b275e52de-718c-4409-8a0a-501fceb03cae6778714Harmonyko-KRKRMob-A82B8065-A21E-42F5-B5D2-E6EADB550A370-12884551392113476134asia%2fseoulasia%2fseoul","locale":"ko-KR"}}) +452ms

I want "Power On" command send... plz,help me...

rubyon commented 9 years ago

plz, show me the sample code... please...

swissmanu commented 9 years ago

find a new example in the examples directory: https://github.com/swissmanu/harmonyhubjs-client/blob/master/examples/sendCommand.js

swissmanu commented 9 years ago

harmonyhubjs-client and harmonyhubjs-discover is the result of an extensive amount of reverse engineering. @jterrace implemented a first version in Python. I took his work and made some compatibility improvements and implemented these libraries in JavaScript.

As part of the open source community, I dont want any material reward for this work. In fact I love to contribute my part to an amazing ecosystem.

When you consider to open an issue to any open source project anytime in the future, please reward the author not with money. Appreciate the project maintainers work by taking some time to look into the projects code, try to fix things by yourself first.

Last but not least: Keep in mind that most project maintainers have a regular job to earn their livings. We love to improve and grow our babies... But we don't always have the capacities to respond in a manner of hours or days. Keep your writing friendly and don't whine if you don't get an immediate response. You won't improve your place in the queue ;)

Thank you for your contribution & keep hacking, @swissmanu