{"id":16759133,"url":"https://github.com/alcalzone/node-g-homa","last_synced_at":"2026-03-04T19:01:35.923Z","repository":{"id":54255188,"uuid":"99245789","full_name":"AlCalzone/node-g-homa","owner":"AlCalzone","description":"Node.js library to control G-Homa WiFi plugs","archived":false,"fork":false,"pushed_at":"2021-03-01T10:02:09.000Z","size":178,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T10:40:25.513Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlCalzone.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}},"created_at":"2017-08-03T15:08:59.000Z","updated_at":"2021-03-01T10:02:12.000Z","dependencies_parsed_at":"2022-08-13T10:10:31.042Z","dependency_job_id":null,"html_url":"https://github.com/AlCalzone/node-g-homa","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlCalzone%2Fnode-g-homa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlCalzone%2Fnode-g-homa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlCalzone%2Fnode-g-homa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlCalzone%2Fnode-g-homa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlCalzone","download_url":"https://codeload.github.com/AlCalzone/node-g-homa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248261916,"owners_count":21074225,"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","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":[],"created_at":"2024-10-13T04:07:23.212Z","updated_at":"2025-04-10T17:14:39.879Z","avatar_url":"https://github.com/AlCalzone.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-g-homa\n\nNodeJS module to control G-Homa WiFi plugs. Functions include:\n* **Inclusion of new Plugs** into an existing WiFi network without using the app. \nOnly works if the discovering device transmits via WiFi or \nif the router is configured to forward UDP broadcasts over WiFi.\n* Replacement of the default external **C\u0026C server** with a local one, so the plugs don't have to phone home.\n* **Command line serial interface** to manually talk to plugs on the local network.\n\n## Credits\nProtocol information was adapted from \n* [FHEM](https://svn.fhem.de/trac/browser/trunk/fhem/FHEM/53_GHoma.pm)\n* [rodney42](https://github.com/rodney42/node-ghoma/blob/master/ghoma.js)\n\nBig thanks for the original work decoding the protocol!\n\n## Usage\n\n### Inclusion of new plugs (only works on wireless devices):\n```ts\nconst gHoma = require(\"g-homa\");\n\nconst discovery = new gHoma.Discovery();\ndiscovery\n    .on(\"inclusion finished\", (devices) =\u003e {\n        // do something with included devices\n    })\n    .once(\"ready\", () =\u003e {\n        // start inclusion\n        discovery.beginInclusion(\"psk\");\n    })\n;\n```\nYou have to supply the WiFi key to the `beginInclusion` method. By default, inclusion stops after one device was found.\nThe overload `beginInclusion(\"psk\", false)` keeps finding new plugs for 60s and then returns.\nDiscovery works by sending packets to the broadcast address of a network interface. If you have multiple ones, e.g. LAN and WiFi, you can select the one to use by providing options to the constructor:\n```ts\nconst discovery = new gHoma.Discovery({\n    networkInterfaceIndex: 0,\n});\n```\n\nThe devices object contains a table of IP and MAC addresses of the found plugs:\n```js\n{\n    \"ip#1\": \"AABBCCDDEEFF\",\n    \"ip#2\": \"FFEEDDCCBBAA\",\n    // and so on...\n}\n```\n\n### Discovery and configuration of included plugs\n```ts\nconst manager = new gHoma.Manager();\nmanager\n    .once(\"ready\", () =\u003e {\n        // find plugs (promise version)\n        manager.findAllPlugs(/* optional duration in ms */)\n            .then(plugs =\u003e {\n                // do something with the plugs\n            })\n        ;\n\n        // find plugs (async version)\n        const plugs = manager.findAllPlugs(/* optional duration in ms */);\n\n        // configure a plug to use the local C\u0026C server\n        // async version:\n        let success /* boolean */ = manager.configurePlug(\"plug IP\", \"server IP\", serverPort);\n\n        // restore a plug to use the default external C\u0026C server\n        let success /* boolean */ = manager.restorePlug(\"plug IP\");\n    })\n;\n```\nLike with Discovery, you can select the network interface the Manager uses by providing options to the constructor:\n```ts\nconst manager = new gHoma.Manager({\n    networkInterfaceIndex: 0,\n});\n```\n\n### Control of configured devices with the local C\u0026C server\n```ts\nconst server = new gHoma.Server(/* optional port number */);\n// ...\n// close the server when you're done\nserver.close();\n```\n\nThe server emits a number of events:\n- `server started`: The server has been started. Parameters: `address \u003c{port, family, address}\u003e`.\n- `server closed`: The server was shut down.\n- `plug added`: A plug has connected to the server. Parameters: `plugId \u003cstring\u003e`.\n- `plug updated`: A plug was switched. Parameters: `plugInfo \u003cPlug\u003e` (see below).\n- `plug dead`: The connection to a plug was lost. Parameters: `plugId \u003cstring\u003e`.\n- `plug alive`: The connection to a plug was re-established. Parameters: `plugId \u003cstring\u003e`.\n\nThe Plug object looks as follows:\n```js\n{\n    id: string,        // ID of this plug\n    ip: string,        // remote IP address\n    port: number,      // remote port number\n    lastSeen: number,  // last seen (UNIX time)\n    online: boolean,   // if the plug is alive or dead\n    lastSwitchSource: \"unknown\" | \"remote\" | \"local\", // where the plug was last switched from\n    state: boolean,    // if the plug is on or off\n    shortmac: string,  // last 3 bytes of the MAC, e.g. DD:EE:FF\n    mac: string,       // e.g. AA:BB:CC:DD:EE:FF\n}\n```\n\n### Manual serial interface\n1. run it from the command line: `node build/serial.js`\n1. enter an ip address to talk to, or leave the line blank to broadcast to all plugs\n    1. enter password `HF-A11ASSISTHREAD` (default, can be changed)\n    1. if the plug responds, confirm the receipt with `+ok`\n    1. get a list of commands with `AT+H\\r` (all commands need to include `\\r` at the end)\n    1. ...?\n    1. profit\n\n## Changelog\n\n#### 1.2.1 (2019-08-15)\n* (AlCalzone) Close the socket instead of throwing when invalid data is received.\n\n#### 1.2.0 (2019-08-09)\n* (AlCalzone) Test all discovered devices instead of assuming they are G-Homa \n\n#### 1.1.3 (2018-06-28)\n* (AlCalzone) Log the payload and triggercode when an unknown plug type is detected.\n\n#### 1.1.2 (2018-01-28)\n* (AlCalzone) Added the possibility to select a network interface to use for communication\n* (AlCalzone) Added debug logs to `Discovery` and `Manager`\n\n#### 1.0.0 (2018-01-11)\n* (AlCalzone) Support energy measurement\n* (AlCalzone) Support reading the firmware version\n\n#### 0.0.4 (2017-08-31)\n* (AlCalzone) Fix reconnection after power loss of the plug\n\n#### 0.0.3 (2017-08-07)\n* (AlCalzone) Fix incompatibility with NodeJS 4.x\n\n#### 0.0.2 (2017-08-05)\n* (AlCalzone) Bugfixes and additional logging\n\n#### 0.0.1 (2017-08-05)\n* (AlCalzone) Initial release\n\n\n## License\nThe MIT License (MIT)\n\nCopyright (c) 2017 AlCalzone \u003cd.griesel@gmx.net\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falcalzone%2Fnode-g-homa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falcalzone%2Fnode-g-homa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falcalzone%2Fnode-g-homa/lists"}