# README
go-switchbot
A SwitchBot API client for Golang
SYNOPSIS
const (
openToken = "blahblahblah"
secretKey = "blahblahblah"
)
c := switchbot.New(openToken, secretKey)
// get physical devices and show
pdev, _, _ := c.Device().List(context.Background())
for _, d := range pdev {
fmt.Printf("%s\t%s\n", d.Type, d.Name)
}
Get Open Token
To use SwitchBot API, you need to get Open Token for auth. Follow steps below:
- Download the SwitchBot app on App Store or Google Play Store
- Register a SwitchBot account and log in into your account
- Generate an Open Token within the app a) Go to Profile > Preference b) Tap App Version 10 times. Developer Options will show up c) Tap Developer Options d) Tap Get Token
- Roll up your sleeves and get your hands dirty with SwitchBot OpenAPI!
# Functions
ACSetAllCommand returns a new Command which sets all state of air conditioner.
ButtonPushCommand returns a new Command which triggers button push.
ChannelAddCommand returns a new Command which is for switching to next channel.
ChannelSubCommand returns a new Command which is for switching to previous channel.
CreateKeyCommand returns a new Command which creates a new key for Lock devices.
DeleteKeyCommand returns a new Command which deletes a key from Lock devices.
DockCommand returns a new Command which returns robot vacuum cleaner to charging dock.
FanHighSpeedCommand returns a new Command which sets fan speed to high.
FanLowSpeedCommand returns a new Command which sets fan speed to low.
FanMiddleSpeedCommand returns a new Command which sets fan speed to medium.
FanSwingCommand returns a new Command which makes a fan swing.
FanTimerCommand returns a new Command which sets timer for a fan.
FastForwardCommand returns a new Command to make DVD player or speaker fastforward.
LightBrightnessDownCommand returns a new Command which make light's brigtness down.
LightBrightnessUpCommand returns a new Command which make light's brigtness up.
LockCommand returns a new Command which rotates the Lock device to locked position.
New returns a new switchbot client associated with given openToken.
NextCommand returns a new Command to switch DVD player or speaker to next track.
No description provided by the author
PauseCommand returns a new Command to make DVD player or speaker pause.
PlayCommand returns a new Command to make DVD player or speaker play.
PowLevelCommand returns a new Command which sets suction power level of robot vacuum cleaner.
PressCommand returns a new command which trigger Bot's press command.
PreviousCommand returns a new Command to switch DVD player or speaker to previous track.
RewindCommand returns a new Command to make DVD player or speaker rewind.
SetAllStatusCommand returns a new Commend which sets all status for smart fan.
SetBrightnessCommand returns a new Command which set brightness of color bulb, strip light, or ceiling ligths.
SetChannelCommand returns a new Command which set the TV channel to given channel.
SetColorCommand returns a new Command which set RGB color value of color bulb or strip light.
SetColorTemperatureCommand returns a new Command which set color temperature of color bulb or ceiling lights.
SetModeCommand returns a new Command which sets a mode for Humidifier.
SetMuteCommand returns a new Command to make DVD player or speaker mute/unmute.
SetPositionCommand returns a new Command which sets curtain devices' position.
StartCommand returns a new Command which starts vacuuming.
StopCommand returns a new Command which stops vacuuming.
PlayerStopCommand returns a new Command to make DVD player or speaker stop.
ToggleCommand returns a new Command which toggles state of color bulb, strip light or plug mini.
TurnOffCommand returns a nw Command which turns off Bot, plug, Curtain, Humidifier, or so on.
TurnOnCommand returns a new Command which turns on Bot, Plug, Curtain, Humidifier, or so on.
LockCommand returns a new Command which rotates the Lock device to unlocked position.
VolumeAddCommand returns a new Command which is for volume up.
VolumeSubCommand returns a new Command which is for volume up.
WithDebug configures the client to print debug logs.
WithEndpoint allows you to set an endpoint of SwitchBot API.
WithHTTPClient allows you to pass your http client for a SwitchBot API client.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Bot is SwitchBot Bot Model No.
No description provided by the author
CeilingLight is SwitchBot Ceiling Light Model No.
CeilingLightPro is SwitchBot Ceiling Light Pro Model No.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ColorBulb is SwitchBot Color Bulb Model No.
No description provided by the author
No description provided by the author
ContactSensor is SwitchBot Contact Sensor Model No.
No description provided by the author
Curtain is SwitchBot Curtain Model No.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Hub is generally referred to these devices, SwitchBot Hub Model No.
HubMini is SwitchBot Hub Mini Model No.
HubPlus is SwitchBot Hub Plus Model No.
Humidifier is SwitchBot Humidifier Model No.
IndoorCam is SwitchBot Indoor Cam Model No.
No description provided by the author
KeyPad is SwitchBot Lock Model No.
KeyPadTouch is SwitchBot Lock Model No.
No description provided by the author
Lock is SwitchBot Lock Model No.
No description provided by the author
No description provided by the author
Meter is SwitchBot Thermometer and Hygrometer Model No.
MeterPlusJP is SwitchBot Thermometer and Hygrometer Plus (JP) Model No.
MeterPlusJP is SwitchBot Thermometer and Hygrometer Plus (JP) Model No.
MeterPlusUS is SwitchBot Thermometer and Hygrometer Plus (US) Model No.
No description provided by the author
MotionSensor is SwitchBot Motion Sensor Model No.
No description provided by the author
No description provided by the author
PanTiltCam is SwitchBot Pan/Tilt Cam Model No.
PanTiltCam2K is SwitchBot Pan/Tilt Cam 2K Model No.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Plug is SwitchBot Plug Model No.
PlugMiniJP is SwitchBot Plug Mini (JP) Model No.
PlugMiniUS is SwitchBot Plug Mini (US) Model No.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
RobotVacuumCleanerS1 is SwitchBot Robot Vacuum Cleaner S1 Model No.
RobotVacuumCleanerS1Plus is SwitchBot Robot Vacuum Cleaner S1 Plus Model No.
No description provided by the author
No description provided by the author
SmartFan is SwitchBot Smart Fan Model No.
No description provided by the author
No description provided by the author
No description provided by the author
StripLight is SwitchBot LED Strip Light Model No.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Device represents a physical SwitchBot device.
No description provided by the author
DeviceService handles API calls related to devices.
No description provided by the author
No description provided by the author
No description provided by the author
InfraredDevice represents a virtual infrared remote device.
KeyListItem is an item for keyList, which maintains a list of passcodes.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Scene represents a manual scene created by the current user.
SceneService handles API calls related to scenes.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
Command is an interface which represents Commands for devices to be used (*Client).Device().Command() method.
# Type aliases
ACFanSpeed represents a fan speed mode for air conditioner.
ACMode represents a mode for air conditioner.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SetPositionMode represents a mode for curtain devices' set position mode.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author