{"id":28546692,"url":"https://github.com/yasuoza/switchbot-ble-go","last_synced_at":"2025-07-07T07:32:15.858Z","repository":{"id":38419567,"uuid":"281982761","full_name":"yasuoza/switchbot-ble-go","owner":"yasuoza","description":"Unofficial SwitchBot client for Go.","archived":false,"fork":false,"pushed_at":"2025-05-19T11:51:25.000Z","size":198,"stargazers_count":7,"open_issues_count":8,"forks_count":1,"subscribers_count":2,"default_branch":"v2","last_synced_at":"2025-06-10T00:07:29.351Z","etag":null,"topics":["ble","go","switchbot"],"latest_commit_sha":null,"homepage":"","language":"Go","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/yasuoza.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":"2020-07-23T15:02:42.000Z","updated_at":"2025-05-19T11:50:42.000Z","dependencies_parsed_at":"2024-02-22T17:55:27.424Z","dependency_job_id":"313156d1-d6c8-4c06-ab99-b472fb762841","html_url":"https://github.com/yasuoza/switchbot-ble-go","commit_stats":null,"previous_names":["yasuoza/switchbot"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/yasuoza/switchbot-ble-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasuoza%2Fswitchbot-ble-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasuoza%2Fswitchbot-ble-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasuoza%2Fswitchbot-ble-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasuoza%2Fswitchbot-ble-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yasuoza","download_url":"https://codeload.github.com/yasuoza/switchbot-ble-go/tar.gz/refs/heads/v2","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasuoza%2Fswitchbot-ble-go/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264034580,"owners_count":23547239,"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":["ble","go","switchbot"],"created_at":"2025-06-10T00:07:35.415Z","updated_at":"2025-07-07T07:32:15.853Z","avatar_url":"https://github.com/yasuoza.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwitchBot Client for Go \u003cbr/\u003e ![test](https://github.com/yasuoza/switchbot/workflows/test/badge.svg) ![CodeQL](https://github.com/yasuoza/switchbot/workflows/CodeQL/badge.svg?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/yasuoza/switchbot)](https://goreportcard.com/report/github.com/yasuoza/switchbot) [![Coverage Status](https://coveralls.io/repos/github/yasuoza/switchbot/badge.svg?branch=master)](https://coveralls.io/github/yasuoza/switchbot?branch=master) [![PkgGoDev](https://pkg.go.dev/badge/github.com/yasuoza/switchbot-ble-go/v2)](https://pkg.go.dev/github.com/yasuoza/switchbot-ble-go/v2)\n\nUnofficial [SwitchBot](https://www.switch-bot.com/) client for Go.\n\n## Commandline\n\n```\n$ go install github.com/yasuoza/switchbot-ble-go/v2/cmd/switchbot@latest\n```\n\n```\nUsage: switchbot [--version] [--help] \u003ccommand\u003e [\u003cargs\u003e]\n\nAvailable commands are:\n    info     Show current SwitchBot information\n    press    Trigger press command\n    scan     Search for SwitchBots\n```\n\nScan SwitchBots.\n\n```\n$ switchbot scan\n11:11:11:11:11:11\n```\n\nPress.\n\n```\nswitchbot press -max-retry '11:11:11:11:11:11'\n```\n\n## API Example\n\n```go\n\nimport (\n  \"github.com/yasuoza/switchbot-ble-go/v2/pkg/switchbot\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\ttimeout := 5 * time.Second\n\n\t// Scan SwitchBots.\n\tvar addrs []string\n\terr := switchbot.Scan(ctx, timeout, func(addr string) {\n\t\taddrs = append(addrs, addr)\n\t})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// If there is no SwitchBot, err is nil and length of addresses is 0.\n\tif len(addrs) == 0 {\n\t\tlog.Println(\"SwitchBot not found\")\n\t\tos.Exit(0)\n\t}\n\n\t// First, connect to SwitchBot.\n\taddr := addrs[0]\n\tlog.Printf(\"Connecting to SwitchBot %s\\n\", addr)\n\tbot, err := switchbot.Connect(ctx, addr, timeout)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Trigger Press.\n\tlog.Printf(\"Connected to SwitchBot %s. Trigger Press\\n\", addr)\n\tbot.Press(false)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyasuoza%2Fswitchbot-ble-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyasuoza%2Fswitchbot-ble-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyasuoza%2Fswitchbot-ble-go/lists"}