Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thde/mystrom
The mystrom package provides Go client for the myStrom REST API.
https://github.com/thde/mystrom
Last synced: 13 days ago
JSON representation
The mystrom package provides Go client for the myStrom REST API.
- Host: GitHub
- URL: https://github.com/thde/mystrom
- Owner: thde
- License: mit
- Created: 2023-11-06T19:19:27.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-13T16:03:14.000Z (6 months ago)
- Last Synced: 2024-10-11T07:45:46.035Z (about 1 month ago)
- Language: Go
- Size: 24.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mystrom
[![Go Reference](https://pkg.go.dev/badge/thde.io/mystrom.svg)](https://pkg.go.dev/thde.io/mystrom) [![Go Report Card](https://goreportcard.com/badge/thde.io/mystrom)](https://goreportcard.com/report/thde.io/mystrom)
The mystrom package provides Go client for the [myStrom REST API](https://api.mystrom.ch/).
## Features
- [x] Switch
- [ ] Button
- [ ] Bulb
- [ ] LED Strip
- [ ] PIR
- [ ] New Button Plus
- [x] DiscoveryPR's for additional endpoints are welcome!
## Usage
To install the mystrom package, use the following command:
```go
package mainimport (
"context"
"log"
"net"
"net/url""thde.io/mystrom"
)func main() {
client := mystrom.NewClient()for {
discover := mystrom.Discover{}
device, err := discover.Device(context.Background())
if err != nil {
log.Fatal(err)
}log.Printf("%+v", device)
host, _, err := net.SplitHostPort(device.Address.String())
if err != nil {
log.Fatal(err)
}
if device.Type != mystrom.DeviceTypeSwitchCH && device.Type != mystrom.DeviceTypeSwitchEU {
continue
}u, err := url.Parse("http://" + host)
if err != nil {
log.Fatal(err)
}
sw := client.NewSwitch(u)
temp, err := sw.Temperature(context.Background())
if err != nil {
log.Fatal(err)
}
log.Printf("%+v", temp)
}
}```
## CLI
To install the CLI, run:
```shell
go install thde.io/mystrom/cmd/mystrom@latest
```