Documentation
¶
Overview ¶
Package nuki provides an simple implementation of the bridge api Versoin: v1.7 (30.03.2018)
Index ¶
- Constants
- Variables
- func ErrorFromStatus(status int) error
- type Action
- type AuthReponse
- type AutoGenerated
- type Bridge
- type BridgesResponse
- type CallbackReponse
- type Callbacks
- type Client
- type ConfigAuthResponse
- type Ds
- type InfoResponse
- type LastKnownState
- type ListResponse
- type LockActionResponse
- type LockStateResponse
- type Log
- type LogResponse
- type Nuki
- func (n *Nuki) Auth() (*AuthReponse, error)
- func (n *Nuki) CallbackAdd(nukiURL string) (*CallbackReponse, error)
- func (n *Nuki) CallbackList() (*CallbackReponse, error)
- func (n *Nuki) CallbackRemove(callbackID int) (*CallbackReponse, error)
- func (n *Nuki) ClearLog() error
- func (n *Nuki) ConfigAuth(enable bool) (*ConfigAuthResponse, error)
- func (n *Nuki) FWUpdate() error
- func (n *Nuki) FactoryReset() error
- func (n *Nuki) Info() (*InfoResponse, error)
- func (n *Nuki) List() ([]ListResponse, error)
- func (n *Nuki) LockAction(nukiID int, action Action, noWait bool) (*LockActionResponse, error)
- func (n *Nuki) LockState(nukiID int) (*LockStateResponse, error)
- func (n *Nuki) Log() (*LogResponse, error)
- func (n *Nuki) Reboot() error
- func (n *Nuki) Token() string
- func (n *Nuki) Unpair(nukiID int) (*UnpairResponse, error)
- type Option
- type ScanResult
- type State
- type UnpairResponse
- type Versions
Constants ¶
const ( StateUncalibrated State = 0 StateLocked State = 1 StateUnlocking State = 2 StateUnlocked State = 3 StateLocking State = 4 StateUnlatched State = 5 StateUnlockedLockNgo State = 6 StateUnlatching State = 7 StateMotorBlocked State = 254 StateUndefined State = 255 ActionUnlock Action = 1 ActionLock Action = 2 ActionUnlatch Action = 3 ActionLockNgo Action = 4 ActionLockNgoWithUnlatch Action = 5 )
Variables ¶
var ( // ErrNotImplemented function not implemented ErrNotImplemented = errors.New("not implemented") // ErrAuthFailed Auth() failed ErrAuthFailed = errors.New("authentication failed") // ErrInvalidURL : 400 ErrInvalidURL = errors.New("given url is invalid or to long") // ErrInvalidToken : 401 ErrInvalidToken = errors.New("token is invalid") // ErrAuthDisabled : 403 ErrAuthDisabled = errors.New("authentication disabled") // ErrSmartLockUnknown : 404 ErrSmartLockUnknown = errors.New("given smart lock is unknown") // ErrSmartLockOffline : 503 ErrSmartLockOffline = errors.New("given smart lock is offline") // ErrUnknown : nobody knows ErrUnknown = errors.New("something went wrong") )
var ActionName = map[int]string{
1: "UNLOCK",
2: "LOCK",
3: "UNLATCH",
4: "LOCK_N_GO",
5: "LOCK_N_GO_WITH_UNLATCH",
}
var ActionValue = map[string]int{
"UNLOCK": 1,
"LOCK": 2,
"UNLATCH": 3,
"LOCK_N_GO": 4,
"LOCK_N_GO_WITH_UNLATCH": 5,
}
Action_Lock_value represents ...
var StateName = map[int]string{
0: "UNCALIBRATED",
1: "LOCKED",
2: "UNLOCKING",
3: "UNLOCKED",
4: "LOCKING",
5: "UNLATCHED",
6: "UNLOCKED_LOCK_N_GO",
7: "UNLATCHING",
254: "MOTOR_BLOCKED",
255: "UNDEFINED",
}
var StateValue = map[string]int{
"UNCALIBRATED": 0,
"LOCKED": 1,
"UNLOCKING": 2,
"UNLOCKED": 3,
"LOCKING": 4,
"UNLATCHED": 5,
"UNLOCKED_LOCK_N_GO": 6,
"UNLATCHING": 7,
"MOTOR_BLOCKED": 254,
"UNDEFINED": 255,
}
Functions ¶
func ErrorFromStatus ¶
ErrorFromStatus returns the matching error based on the given status code
Types ¶
type AuthReponse ¶
type AutoGenerated ¶
type AutoGenerated struct { }
type BridgesResponse ¶
type CallbackReponse ¶
type Client ¶
Client is the interface implemented by types that can deliver a http response based on the given request.
type ConfigAuthResponse ¶
type ConfigAuthResponse struct {
Success string `json:"success"`
}
type InfoResponse ¶
type LastKnownState ¶
type ListResponse ¶
type ListResponse struct { NukiID int `json:"nukiId"` Name string `json:"name"` LastKnownState LastKnownState `json:"lastKnownState"` }
type LockActionResponse ¶
type LockStateResponse ¶
type LogResponse ¶
type LogResponse []Log
type Nuki ¶
type Nuki struct {
// contains filtered or unexported fields
}
Nuki holds you access token and connection information
func NewNuki ¶
NewNuki returns a new nuki entrypoint without a token to request a new token, the auth function can be called. this connects to the bridge and stores the token internally.
func (*Nuki) Auth ¶
func (n *Nuki) Auth() (*AuthReponse, error)
Auth Enables the api (if not yet enabled) and returns the api token. If no api token has yet been set, a new (random) one is generated. When issuing this API-call the bridge turns on its LED for 30 seconds. The button of the bridge has to be pressed within this timeframe. Otherwise the bridge returns a negative success and no token.
func (*Nuki) CallbackAdd ¶
func (n *Nuki) CallbackAdd(nukiURL string) (*CallbackReponse, error)
CallbackAdd registers a new callback url
func (*Nuki) CallbackList ¶
func (n *Nuki) CallbackList() (*CallbackReponse, error)
CallbackList returns a CallbackReponse with all registered url callbacks
func (*Nuki) CallbackRemove ¶
func (n *Nuki) CallbackRemove(callbackID int) (*CallbackReponse, error)
CallbackRemove removes a previously added callback by ID
func (*Nuki) ConfigAuth ¶
func (n *Nuki) ConfigAuth(enable bool) (*ConfigAuthResponse, error)
ConfigAuth enables or disables the authorization via /auth and the publication of the local IP and port to the discovery URL The api token configured via the Nuki app when enabling the API enable: Flag (0 or 1) indicating whether or not the authorization should be enabled
func (*Nuki) FactoryReset ¶
FactoryReset performs a factory reset
func (*Nuki) Info ¶
func (n *Nuki) Info() (*InfoResponse, error)
Info returns all smart locks in range and some device information of the bridge itself
func (*Nuki) List ¶
func (n *Nuki) List() ([]ListResponse, error)
List returns all paired Smart Locks a valid token is required
func (*Nuki) LockAction ¶
LockAction performs a lock operation on the given smart lock given by the id action: the desired lock action noWait: indicating whether or not to wait for the lock action to complete and return its result
type Option ¶
type Option func(*Nuki)
Option allows additional options to be specified for a nuki client
func WithHTTPClient ¶
WithHTTPClient allows to set a Client when creating a Nuki.
type ScanResult ¶
type UnpairResponse ¶
type UnpairResponse struct {
Success string `json:"success"`
}