{"id":28420771,"url":"https://github.com/grrowl/homebridge-plugin-automation","last_synced_at":"2025-06-26T17:31:26.643Z","repository":{"id":219086810,"uuid":"748126913","full_name":"grrowl/homebridge-plugin-automation","owner":"grrowl","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-13T05:32:22.000Z","size":578,"stargazers_count":10,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-04T09:54:53.327Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grrowl.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}},"created_at":"2024-01-25T10:30:55.000Z","updated_at":"2025-04-14T21:09:22.000Z","dependencies_parsed_at":"2024-05-13T01:42:45.144Z","dependency_job_id":"fd8c15f1-9551-496c-b2e4-cf508c4673ab","html_url":"https://github.com/grrowl/homebridge-plugin-automation","commit_stats":{"total_commits":70,"total_committers":1,"mean_commits":70.0,"dds":0.0,"last_synced_commit":"845cbfda6c4b30374f54020597524be688a0ad00"},"previous_names":["grrowl/homebridge-plugin-automation"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/grrowl/homebridge-plugin-automation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grrowl%2Fhomebridge-plugin-automation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grrowl%2Fhomebridge-plugin-automation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grrowl%2Fhomebridge-plugin-automation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grrowl%2Fhomebridge-plugin-automation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grrowl","download_url":"https://codeload.github.com/grrowl/homebridge-plugin-automation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grrowl%2Fhomebridge-plugin-automation/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259913544,"owners_count":22931234,"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":"2025-06-05T03:49:43.770Z","updated_at":"2025-06-26T17:31:26.628Z","avatar_url":"https://github.com/grrowl.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# homebridge-automation\n\nControl and automate your Homebridge instance with Javascript.\n\n\u003e [!WARNING]\n\u003e This plugin is very new, but since it's so useful and unique (no simpler homebridge automation approaches exist) I'm releasing it for constributors, testers, and as a request for feedback.\n\nAny time a device/service status changes, a callback registered at `automation.listen` will fire with an `event` shaped like a (Service)[https://github.com/grrowl/homebridge-plugin-automation/blob/main/src/schemas/Service.ts]. This allows you to build automations without setting up Node-RED or other third-party solutions.\n\n## Examples\n\n```js\nautomation.listen(function (event) {\n  if (event.type === \"Lightbulb\") {\n    // Some lightbulb changed state\n  }\n  if (event.serviceName === \"Book Globe\") {\n    // A specific device/service changed state\n  }\n});\n```\n\nWhen Dummy Switch is turned on, wait 5 seconds, then turn it Off.\n\n```js\nautomation.listen(function (event) {\n  if (event.serviceName === \"Dummy Switch\") {\n    const On = event.serviceCharacteristics.find((c) =\u003e c.serviceName === \"On\");\n\n    if (On \u0026\u0026 On.value === 1) {\n      setTimeout(function () {\n        automation.set(event.uniqueId, On.iid, 0);\n      }, 5_000);\n      return true;\n    }\n    return false;\n  }\n  return null;\n});\n```\n\nOn Motion sensor updating, check if it's Active, if so, turn on the lamp.\n\n```js\nautomation.listen(function (event) {\n  if (event.serviceName === \"Motion sensor\") {\n    if (\n      event.serviceCharacteristics.find(\n        (c) =\u003e c.type === \"MotionDetected\" \u0026\u0026 c.value === 1,\n      )\n    ) {\n      // Find the light we want\n      const light = automation.services.find(\n        (s) =\u003e s.serviceName === \"Tall Lamp\",\n      );\n      if (light) {\n        const on = light.serviceCharacteristics.find((s) =\u003e s.type === \"On\");\n        if (on) {\n          automation.set(light.uniqueId, on.iid, 1);\n        }\n      }\n    }\n  }\n});\n```\n\n## API\n\nThe `automation` object is available in your function module scope and defined in [`platformApi.ts`](https://github.com/grrowl/homebridge-plugin-automation/blob/main/src/platformApi.ts).\n\nSee [`schemas/Service.ts`](https://github.com/grrowl/homebridge-plugin-automation/blob/main/src/schemas/Service.ts) and [`schemas/Characteristic.ts`](https://github.com/grrowl/homebridge-plugin-automation/blob/main/src/schemas/Characteristic.ts).\n\nYour function module scope is preserved between invocations, but is lost on Homebridge restart.\n\n## Troubleshooting\n\nTurn on \"Homebridge Debug Mode\" to see the return values from your functions in the logs (helpful for debugging).\n\nHomebridge (or the bridge homebridge-automation runs on) needs to be restarted for changes to the automation javascript to take effect.\n\nYou might need \"Homebridge 'Insecure' Mode (Enable Accessory Control)\" enabled.\n\nNote your `serviceName` may not be the same as the Accessory name! Click the gear on your accessory and check the \"Name\" listed in the table -- that is the true `serviceName` exposed to the automation.\n\n## Development\n\n### Local testing\n\nSimply run `npm run watch` to start. By default it uses the config at `~/.homebridge/config.json`, so if you want to discover local network instance add the correct PIN for your Homebridge instance there.\n\n### Local testing (in docker)\n\nThis runs segregated from your local network for more specific testing scenarios.\n\n```shell\ndocker run --name=homebridge-automation -p 18581:8581 -v $(pwd)/homebridge:/homebridge -v $(pwd):/var/lib/homebridge-plugin-automation homebridge/homebridge:latest; docker rm homebridge-automation\n```\n\nThen open homebridge UI: http://localhost:18581/\n\nNote: because of our use of `isolated-vm`, linking your host node_modules/dist into a docker container of a different arch (e.g. arm64 or x86) won't work, with error \"invalid ELF header\"\n\n---\n\n### Link To Homebridge\n\nRun this command so your global install of Homebridge can discover the plugin in your development environment:\n\n```\nnpm link\n```\n\nYou can now start Homebridge, use the `-D` flag so you can see debug log messages in your plugin:\n\n```\nhomebridge -D\n```\n\n### Installing Beta Versions\n\nYou can install _beta_ versions of this plugin by appending `@beta` to the install command, for example:\n\n```\nsudo npm install -g homebridge-example-plugin@beta\n```\n\nBeta versions may break functionality, but\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrrowl%2Fhomebridge-plugin-automation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrrowl%2Fhomebridge-plugin-automation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrrowl%2Fhomebridge-plugin-automation/lists"}