{"id":13996026,"url":"https://github.com/JordanMartin/harmonyhub-api","last_synced_at":"2025-07-22T23:30:36.639Z","repository":{"id":33823834,"uuid":"162824339","full_name":"JordanMartin/harmonyhub-api","owner":"JordanMartin","description":"Harmony Hub API that use the local websocket API of the hub","archived":false,"fork":false,"pushed_at":"2023-04-30T03:00:36.000Z","size":390,"stargazers_count":42,"open_issues_count":5,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-09T14:24:16.568Z","etag":null,"topics":["api","harmony","harmony-hub","logitech","websocket"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JordanMartin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-12-22T16:01:52.000Z","updated_at":"2024-12-05T21:25:56.000Z","dependencies_parsed_at":"2024-04-12T03:03:09.777Z","dependency_job_id":null,"html_url":"https://github.com/JordanMartin/harmonyhub-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JordanMartin/harmonyhub-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordanMartin%2Fharmonyhub-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordanMartin%2Fharmonyhub-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordanMartin%2Fharmonyhub-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordanMartin%2Fharmonyhub-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JordanMartin","download_url":"https://codeload.github.com/JordanMartin/harmonyhub-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordanMartin%2Fharmonyhub-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266589856,"owners_count":23952825,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","harmony","harmony-hub","logitech","websocket"],"created_at":"2024-08-09T14:03:44.355Z","updated_at":"2025-07-22T23:30:36.282Z","avatar_url":"https://github.com/JordanMartin.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Harmony Hub API (with local websocket)\n\nThis module  tend to replace the old XMPP API which was removed with the firemware 4.15.206 ([see more here](https://community.logitech.com/s/question/0D55A00008D4bZ4SAJ/harmony-hub-firmware-update-fixes-vulnerabilities)).\n\nIt uses the local websocket API of the hub.\n\n\u003e **UPDATE 23/12/2018**\n\u003e Logitech reversed his decision about the XMPP API. It makes available back the API but only for developers. [see more here](https://community.logitech.com/s/question/0D55A00008D4bZ4SAJ/harmony-hub-firmware-update-fixes-vulnerabilities). The local websocket API remains available.\n\n# Usage\n\n## Installation\n```bash\n$ npm install harmonyhub-api\n```\n\n## Get the remote id of the hub\nUse the following helper:\n```bash\n$ node_modules/.bin/harmonyhub-remote-id \u003chub_ip_or_host\u003e\n```\n\nOr juste make the following http post\n```http\nHost: \u003chub_host_or_ip\u003e:8088\nOrigin: http://sl.dhg.myharmony.com\nContent-Type: application/json\nAccept-Charset: utf-8\n\n{\n    \"id \": 1,\n    \"cmd\": \"setup.account?getProvisionInfo\",\n    \"params\": {}\n}\n```\n\n**Example with curl**\n```bash\n$ curl -X POST \u003chub_host_or_ip\u003e:8088 -H 'Accept: utf-8' -H 'Content-Type: application/json' -H 'Origin: http://sl.dhg.myharmony.com' -d '{\"id\":1,\"cmd\":\"setup.account?getProvisionInfo\",\"params\":{}}'\n```\n\n## Connection and configuration\n```javascript\nconst HarmonyHub = require('harmonyhub-api').HarmonyHub;\nconst HUB_HOST = 'X.X.X.X';\nconst HUB_REMOTE_ID = 'XXXXXXX';\nconst hub = new HarmonyHub(HUB_HOST, HUB_REMOTE_ID);\n\nhub.connect()\n    .then((config) =\u003e {\n        console.log('Connected to the hub');\n\n        console.log('\\nActivities\\n==========');\n        config.activity.forEach(activity =\u003e {\n            console.log(`${activity.label} (${activity.id})`);\n        });\n\n        console.log('\\nDevices\\n========');\n        config.device.forEach(device =\u003e {\n            console.log(`${device.label} (${device.id})`);\n        });\n    });\n```\n\n## Keep the connection alive\n\u003e :warning: Without activities, the connection is automatically closed after 60 seconds. You can periodically send a `ping` or catch the `close` event to open a new connection.\n\n```javascript\n// Regularly ping \nsetInterval(() =\u003e hub.ping(), 50000);\n\n// Or catch the close event\nhub.on('close', () =\u003e hub.connect());\n```\n\n## Start an activity\nThe list of activityId can be found in the configuration object or with `hub.getActivities()`\n```javascript\nhub.startActivity('xxxxxx');\n```\n\n## Send command to a device\nThe list of commands and deviceId can be found in the configuration object of each devices. Browse the content of `hub.getDevices()`.\n\n```javascript\n// Simple press\nhub.sendCommand('VolumeUp', '53161273');\n\n// Hold a press for 1 second\nhub.holdCommand('VolumeUp', '53161273', 1000);\n```\n\n## Close the connection\n```javascript\nhub.disconnect();\n```\n\n## Listen for events\nThe HarmonyHub object is a EventEmitter for some events : \n\n```javascript\nhub.on('error|connect|close|message', callback)\n````\n\n- `error` : On error on the websocket\n    - 1 argument: the error\n- `connect` : On connection to the websocket of the hub\n    - 1 argument: the config of the hub\n- `close` : On the websocket connection close\n    - 2 arguments: code and description\n- `message` : On incoming message from the hub\n    - 1 argument: The message data\n\n\n## Log level\nBy default, the logger is set on 'warn'. You can override with the `LOG_LEVEL` environnement variable. eg:\n```bash\n$ LOG_LEVEL=debug node test.js\n```\n\n## API documentation\nThe full API documentation is available in the `docs/` folder.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJordanMartin%2Fharmonyhub-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJordanMartin%2Fharmonyhub-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJordanMartin%2Fharmonyhub-api/lists"}