{"id":21044622,"url":"https://github.com/tripflex/meteor-homie","last_synced_at":"2026-04-27T19:32:44.020Z","repository":{"id":147531832,"uuid":"116996269","full_name":"tripflex/meteor-homie","owner":"tripflex","description":"Meteor package to general Homie iot configuration, and helper methods","archived":false,"fork":false,"pushed_at":"2018-08-12T21:28:28.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-28T08:19:12.693Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://atmospherejs.com/tripflex/homie","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tripflex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2018-01-10T18:38:54.000Z","updated_at":"2018-08-12T21:28:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"ef8c9d1a-1851-49f0-b425-81dc17d2d303","html_url":"https://github.com/tripflex/meteor-homie","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tripflex/meteor-homie","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripflex%2Fmeteor-homie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripflex%2Fmeteor-homie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripflex%2Fmeteor-homie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripflex%2Fmeteor-homie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tripflex","download_url":"https://codeload.github.com/tripflex/meteor-homie/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripflex%2Fmeteor-homie/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32352396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T17:12:42.749Z","status":"ssl_error","status_checked_at":"2026-04-27T17:12:41.658Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-11-19T14:17:46.462Z","updated_at":"2026-04-27T19:32:44.000Z","avatar_url":"https://github.com/tripflex.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Homie for Meteor\n\nThis Meteor package is for projects that utilize the [Homie IoT convention](https://github.com/marvinroger/homie).\n\nIt includes helper methods for connecting and configuring Homie devices using the Meteor `HTTP` package for API calls, as well as formatting configuration JSON, and other helper methods.\n\nMeant to be used with NodeMCU (or any ESP8266) [Homie firmware](https://github.com/marvinroger/homie-esp8266).\n\n## Installation\n`meteor add tripflex:homie`\n\n## Promises\nAll methods are Asynchronous and are Promise based methods.  If you are not familiar with JavaScript Promises ... you should be ... but if you're not, here's some great resources:\n\n[https://javascript.info/promise-basics](https://javascript.info/promise-basics)\n\n[https://promise-nuggets.github.io/](https://promise-nuggets.github.io/)\n\nYou should also be using the ES6 `async` `await` since it's supported in Meteor and makes things 100x easier:\n\n[https://javascript.info/async-await](https://javascript.info/async-await)\n\n## Helper Methods\n* `sleep(customDelay)`\n\n`customDelay` is optional, and should be specified in ms to use a custom sleep (default is 2 seconds [2000ms])\n\n```javascript\nasync function f(){\n\tconsole.log( 'before sleep' );\n\tawait Homie.sleep(); // execution will pause for 2 seconds\n\tconsole.log( 'after sleep for 2 seconds' );\n}\n```\n\n## API Methods\nThis package exports `Homie` object, along with `Homie.API` for API calls\n\nCurrently available are:\n* `getHeartBeat(options)`\n* `getDeviceInfo(options)`\n* `getNetworks(options)`\n* `saveConfig(config, options)`\n* `connectToWifi(ssid, password, options)`\n* `getWifiStatus(options)`\n* `setProxy(enable, options)`\n* `generateConfig(device_name, device_id, wifi_ssid, wifi_password, mqtt_host, custom_settings, wifi_options, mqtt_options, ota)`\n\n`options` in each method is meant for overriding any of the default options for that specific API call, and are passed to `HTTP.Call`\n\nMaking API calls is very quick and easy (basic non `async/await` promise handling):\n```js\nlet API = new Homie.API();\nAPI.getHeartBeat().then( function( result ){\n\t// has a heartbeat\n}).catch( function( error ){\n\t// no heartbeat or some other error\n});\n```\n\n**All API Methods are asynchronous, and are JavaScript Promise based**\n\nThe example above is using `.then()` and `.catch()`, but you should be using `async/await`:\n\n```js\n\nasync function getNetworks(){\n    \n\tlet API = new Homie.API();\n\t\n\ttry {\n\t\tawait API.getHeartBeat();\n\t\tlet networks = API.getNetworks();\n\t\tconsole.log( 'Device networks found:', networks );\n\t\treturn networks; // Returning value resolves the promise\n\t} catch( error ){\n\t\tconsole.log( 'Error with heartbeat OR getting networks would trigger this catch', error );\n\t\tthrow error; // Throw rejects promise, this allows for bubbling up errors\n\t}\n}\n```\n\n## Changelog\n#### 1.0.0\n- Complete code refactoring\n- Now using Meteor `HTTP` package for API calls\n- Updated `/wifi/connect` and `/proxy/control/` to use `POST`\n- Basically completely new plugin codebase\n\n#### 0.0.1\n- Initial package creation\n\n### Example Async/Await Class Try/Catch Handling\n\nInitially learning Promises and `async/await` was quite confusing for me initially, and as such, I created some example code you can see below to show how to use `async/await` in classes, and `try/catch` blocks.\nYou can also run this code and play around with it at the links below:\n\n[Glot.IO](https://glot.io/snippets/exdd6t4bjz) - OR - [JSFiddle](https://jsfiddle.net/tripflex/9ye8wbhd/)\n\n```javascript\nlet WiFiLib = {\n\n\taddNetwork: function( netID ){\n\n\t\treturn new Promise( function( resolve, reject ){\n\n\t\t\tif( netID \u003e -1 ){\n\t\t\t\tresolve( true );\n\t\t\t} else {\n\t\t\t\treject( 'Invalid network ID!' );\n\t\t\t}\n\n\t\t});\n\n\t},\n\n\tconnect: function( netID ){\n\n\t\treturn new Promise( function( resolve, reject ){\n\n\t\t\tresolve( true );\n\t\t\t//reject( 'Unable to connect to wifi!' );\n\n\t\t});\n\n\t}\n\n};\n\nclass WiFi {\n\n\tconstructor(){\n\t\tthis.delay = 2000;\n\t\tthis.netID = -1;\n\t}\n\n\tasync connect(){\n\n\t\ttry {\n\n\t\t\tlet netID = this.add();\n\t\t\tthis.netID = await netID;\n\n\t\t\tawait this.doConnect();\n\n\t\t\treturn true;\n\n\t\t} catch( error ){\n\n                    console.log( 'Wifi connect catch error: ', error );\n                    await this.timeout();\n                    console.log( 'Wifi connect catch error after timeout' );\n                    throw error;\n\t\t}\n\t}\n\n\tasync add(){\n\n\t\tconst networkAdded = await WiFiLib.addNetwork( 2 );\n\t\tawait this.timeout();\n\n\t\treturn networkAdded;\n\t}\n\n\tasync doConnect(){\n\n\t\tconst networkConnected = await WiFiLib.connect( this.netID );\n\t\tawait this.timeout();\n\n\t\treturn networkConnected;\n\t}\n\n\t/**\n\t * Synchronous Sleep/Timeout `await this.timeout()`\n\t */\n\ttimeout( customDelay ) {\n\t\tlet delay = customDelay ? parseInt( customDelay ) : parseInt( this.delay );\n\t\treturn new Promise(function(resolve, reject) {\n\t\t\tsetTimeout(resolve, delay);\n\t\t});\n\t}\n}\n\nclass Provisioner {\n\n\tconstructor( wifi ){\n\t\tthis.wifi = wifi;\n\t}\n\n\tasync startProvision(){\n\n\t\ttry {\n\n\t\t\tawait this.wifi.connect();\n\t\t\t//do some provision stuff\n\t\t\t\n\t\t\treturn true;\n\n\t\t} catch ( error ){\n\n\t\t\tconsole.log( 'Provisioner Catch', error );\n\t\t\t\n\t\t\tlet doRetry = this.doRetry( false );\n\t\t\tawait doRetry;\n\t\t\t\n\t\t\tif( doRetry ){\n\t\t\t\tthis.startProvision();\n\t\t\t} else {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\t\n\t\t}\n\n\t}\n\t\n\tasync doRetry( shouldDo ){\n\t\t\tawait this.timeout();\n\t\t\treturn shouldDo;\n\t}\n\t\n\t\t/**\n\t * Synchronous Sleep/Timeout `await this.timeout()`\n\t */\n\ttimeout( customDelay ) {\n\t\tlet delay = customDelay ? parseInt( customDelay ) : parseInt( this.delay );\n\t\treturn new Promise(function(resolve, reject) {\n\t\t\tsetTimeout(resolve, delay);\n\t\t});\n\t}\n}\n\nlet wifiConnector = new WiFi();\nlet provisioning = new Provisioner( wifiConnector );\n\nprovisioning.startProvision().then( ()=\u003e{\n\tconsole.log( 'Provisioner Complete!' );\n}, error =\u003e {\n\tconsole.log( 'Provisioner Error!' );\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftripflex%2Fmeteor-homie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftripflex%2Fmeteor-homie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftripflex%2Fmeteor-homie/lists"}