{"id":22922398,"url":"https://github.com/firehed/homebridge-plugin-generic-switch","last_synced_at":"2026-04-27T23:32:16.635Z","repository":{"id":57265866,"uuid":"125659939","full_name":"Firehed/homebridge-plugin-generic-switch","owner":"Firehed","description":null,"archived":false,"fork":false,"pushed_at":"2018-03-17T19:20:26.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-01T19:41:34.654Z","etag":null,"topics":["homebridge","homebridge-plugin","homekit","homekit-accessory","homekit-accessory-protocol"],"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/Firehed.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":"2018-03-17T18:57:08.000Z","updated_at":"2021-02-09T17:58:47.000Z","dependencies_parsed_at":"2022-08-25T03:40:50.304Z","dependency_job_id":null,"html_url":"https://github.com/Firehed/homebridge-plugin-generic-switch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fhomebridge-plugin-generic-switch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fhomebridge-plugin-generic-switch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fhomebridge-plugin-generic-switch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fhomebridge-plugin-generic-switch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Firehed","download_url":"https://codeload.github.com/Firehed/homebridge-plugin-generic-switch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246655691,"owners_count":20812679,"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":["homebridge","homebridge-plugin","homekit","homekit-accessory","homekit-accessory-protocol"],"created_at":"2024-12-14T08:10:03.409Z","updated_at":"2026-04-27T23:32:16.593Z","avatar_url":"https://github.com/Firehed.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# homebridge-plugin-generic-switch\n\nHomekit connectivity for (almost) any network-connected switch.\n\nDesigned to work in combination with lightweight networked devices such as an ESP-8266.\n\n## How it works\n\nThis creates a Homebridge switch accessory, which is linked to the configured device.\nWhen the power state is requested, it will send a GET request and process the response, formatting it for Homekit.\nSimilarly, when the state is changed, it will send a POST request to the device.\n\n## Installation\n\nAssuming you already have Homebridge running somewhere, just install this plugin like you would with any other: `npm i -g homebridge-plugin-generic-switch`.\n\nIf you don't have Homebridge set up with at least one other device, it's probably best to not start with this one.\nWhile this plugin should work with very little work or configuration, the hardware side has a decent chance of being quite fiddly and you won't want to deal with that _in addition to_ getting Homebridge up and running.\n\n## Configuration\n\nIn your existing Homebridge configration, add an accessory with, at minimum, the following structure:\n\n```json\n\"accessories\": [\n    {\n        \"accessory\": \"GenericSwitch\",\n        \"host\": \"http://your-switch.local\",\n        \"name\": \"Some Switch Name\",\n    }\n]\n```\nMake sure that the `host` field includes the protocol.\n\nFor further customization, all of the following parameters can be set (with their default values shown below):\n\n```json\n\"accessories\": [\n    {\n        \"accessory\": \"GenericSwitch\",\n        \"host\": \"http://your-switch.local\",\n        \"name\": \"Some Switch Name\",\n        \"model\": \"Unknown\",\n        \"manufacturer\": \"Generic\",\n        \"sn\": \"XXXXXX\",\n        \"cache\":  15,\n        \"api\": {\n            \"get\": {\n                \"route\": \"/\",\n                \"on\": \"on\",\n                \"off\": \"off\"\n            },\n            \"set\": {\n                \"route\": \"/power\",\n                \"param\": \"state\",\n                \"on\": \"on\",\n                \"off\": \"off\"\n            }\n        }\n    }\n]\n```\n\nThe `model`, `manufacturer`, and `sn` fields are for display purposes only.\n\n`cache` is the duration (in seconds) that a response from the device should be cached.\nThis is meant primarily for devices that are slow to change their power state, such as projectors (which have warm-up and cool-down times).\nSet to `0` to disable, but this is not recommended if using an ESP8266-based device since its webserver doesn't support requests in parallel.\n\nThe `api` structure configures what requests will be sent when the state is set or retreived.\n\n### Default API\nThe default configuration indicates the following:\n\n#### Retreive power\n`GET /` - expects to receive a `text/plain` response containing `on` or `off`.\nIf another value is received, the state will default to off and an error will be logged.\n\n#### Set power\n`POST /power?state={on|off}` - the response is ignored.\nNote that due to a weird interaction between how `node-fetch` and the `ESP8266WebServer` libraries work, what normally would go in the POST body is instead sent as a query parameter.\nThis is hardcoded for now, but may become configurable in the future.\n\n## Contributing\n\nSend a pull request or open an issue.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirehed%2Fhomebridge-plugin-generic-switch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirehed%2Fhomebridge-plugin-generic-switch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirehed%2Fhomebridge-plugin-generic-switch/lists"}