{"id":17770766,"url":"https://github.com/abn/homey-interval-manager","last_synced_at":"2026-02-14T08:02:15.632Z","repository":{"id":259251587,"uuid":"877000066","full_name":"abn/homey-interval-manager","owner":"abn","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-24T02:03:58.000Z","size":359,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-13T03:46:48.871Z","etag":null,"topics":["helper","homey","library","node-module","nodejs","setinterval","typescript"],"latest_commit_sha":null,"homepage":"https://abn.github.io/homey-interval-manager/","language":"TypeScript","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/abn.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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-22T23:08:52.000Z","updated_at":"2025-02-03T07:27:04.000Z","dependencies_parsed_at":"2024-10-30T22:45:36.217Z","dependency_job_id":"cfa13b28-8b50-4181-8a15-694c231814ed","html_url":"https://github.com/abn/homey-interval-manager","commit_stats":{"total_commits":58,"total_committers":2,"mean_commits":29.0,"dds":"0.10344827586206895","last_synced_commit":"80ebdb1ef2e8f66336dfea92f663a815c82df7ac"},"previous_names":["abn/homey-interval-manager"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/abn/homey-interval-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abn%2Fhomey-interval-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abn%2Fhomey-interval-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abn%2Fhomey-interval-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abn%2Fhomey-interval-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abn","download_url":"https://codeload.github.com/abn/homey-interval-manager/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abn%2Fhomey-interval-manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29439821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T07:24:13.446Z","status":"ssl_error","status_checked_at":"2026-02-14T07:23:58.969Z","response_time":53,"last_error":"SSL_read: 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":["helper","homey","library","node-module","nodejs","setinterval","typescript"],"created_at":"2024-10-26T21:27:02.432Z","updated_at":"2026-02-14T08:02:15.617Z","avatar_url":"https://github.com/abn.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# homey-interval-manager\n\nA lightweight TypeScript library for managing intervals in Homey Apps, Devices and Drivers. Simplifies the process of\nscheduling and managing recurring tasks within your Homey applications.\n\n## Features\n\n- **Easy interval management:** Start, stop, and restart intervals with a simple API.\n- **Flexible configuration:** Define intervals with custom functions, settings, and intervals.\n- **Automatic restarts:** Optionally restart intervals when device settings change.\n- **TypeScript support:** Provides type definitions for improved code clarity and maintainability.\n\n## Installation\n\n```bash\nnpm install homey-interval-manager\n```\n\n## Usage\n\n1. **Import the class:**\n\n\u003c!-- end list --\u003e\n\n```typescript\nimport HomeyIntervalManager from \"homey-interval-manager\";\n```\n\n2. **Create an instance:**\n\n\u003c!-- end list --\u003e\n\n```typescript\n// In your device class constructor:\nthis.intervalManager = new HomeyIntervalManager(\n    this,\n    {\n        SOME_KEY: {\n            functionName: \"myFunction\", // Name of the function to execute\n            settingName: \"mySetting\", // Optional setting to watch for changes\n            intervalSeconds: 300, // Optional interval in seconds (default: 600)\n            disableAutoStart: false, // Optional, prevent auto-start on device init\n        },\n        SOME_OTHER_KEY: {\n            functionName: \"myOtherFunction\", // Name of the function to execute\n        },\n        // ... more interval configurations ...\n    },\n    600,\n); // defaults to 10 minutes if no interval or setting name provided\n```\n\n3. **Start the intervals:**\n\n\u003c!-- end list --\u003e\n\n```typescript\n// Start all intervals (defined in the config)\nawait this.intervalManager.start();\n\n// Or start specific intervals\nawait this.intervalManager.start(\"SOME_KEY\", \"SOME_OTHER_KEY\");\n```\n\n4. **Stop the intervals:**\n\n\u003c!-- end list --\u003e\n\n```typescript\n// Stop all intervals\nawait this.intervalManager.stop();\n\n// Or stop a specific interval\nawait this.intervalManager.clearInterval(\"myInterval\");\n```\n\n5. **Restart intervals:**\n\n\u003c!-- end list --\u003e\n\n```typescript\n// Restart all intervals\nawait this.intervalManager.restart();\n\n// Restart intervals associated with specific settings\nawait this.intervalManager.restart(\"mySetting\");\n```\n\n## Example\n\n```typescript\nimport { OAuth2Device } from \"homey-oauth2app\";\nimport { HomeyIntervalManager, IntervalConfiguration, IntervalConfigurationCollection } from \"homey-interval-manager\";\n\ntype DeviceSettingsValue = boolean | string | number | undefined | null;\ntype DeviceSettings = Record\u003cstring, DeviceSettingsValue\u003e;\n\nclass SomeCloudApiDevice extends OAuth2Device {\n    protected intervalManager!: HomeyIntervalManager\u003cthis\u003e;\n\n    async onOAuth2Init() {\n        this.intervalManager = new HomeyIntervalManager(\n            this,\n            {\n                STATUS_UPDATE: {\n                    functionName: \"syncStatusUpdate\",\n                    settingName: \"status_update_polling_interval\",\n                },\n            },\n            600,\n            true,\n        );\n        await this.intervalManager.start();\n    }\n\n    async syncStatusUpdate(): Promise\u003cvoid\u003e {\n        const status = await this.get({ path: \"/status\" });\n        await this.setCapabilityValue(\"device_status\", status.name);\n    }\n\n    async onOAuth2Uninit() {\n        await this.intervalManager.stop();\n    }\n\n    async onSettings(event: {\n        oldSettings: DeviceSettings;\n        newSettings: DeviceSettings;\n        changedKeys: string[];\n    }): Promise\u003cstring | void\u003e {\n        this.log(\"SomeCloudApi device settings where changed\");\n        const changedKeys = event.changedKeys as IntervalConfiguration\u003cthis\u003e[\"settingName\"][] \u0026 string[];\n        this.homey.setTimeout(async () =\u003e {\n            await this.intervalManager.restartBySettings(...changedKeys);\n        }, 1000);\n    }\n}\n```\n\n## Contributing\n\nContributions are welcome\\! Feel free to open issues or submit pull requests.\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabn%2Fhomey-interval-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabn%2Fhomey-interval-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabn%2Fhomey-interval-manager/lists"}