Documentation ¶
Overview ¶
Package kizcool provides a high-level client to the Overkiz IoT API, used by velux, somfy and other vendors to control velux devices with a Tahoma box.
Index ¶
- Constants
- func Output(w io.Writer, format string, obj interface{}) error
- func SupportsCommand(device Device, command Command) bool
- type Action
- type ActionGroup
- type Command
- type CommandDefinition
- type CommandExecutionStateChangedEvent
- type Device
- type DeviceDefinition
- type DeviceState
- type DeviceStateChangedEvent
- type DeviceURL
- type EndUserLoginEvent
- type Event
- type Events
- type ExecID
- type ExecutionEvent
- type ExecutionRegisteredEvent
- type ExecutionStateChangedEvent
- type GatewayAliveEvent
- type GatewayDownEvent
- type GatewayEvent
- type GatewaySynchronizationEndedEvent
- type GatewaySynchronizationStartedEvent
- type GenericEvent
- type Kiz
- func (k *Kiz) Close(device Device) (ExecID, error)
- func (k *Kiz) Execute(ag ActionGroup) (ExecID, error)
- func (k *Kiz) GetActionGroups() ([]ActionGroup, error)
- func (k *Kiz) GetDevice(deviceURL DeviceURL) (Device, error)
- func (k *Kiz) GetDeviceByText(text string) (Device, error)
- func (k *Kiz) GetDeviceState(deviceURL DeviceURL, stateName StateName) (DeviceState, error)
- func (k *Kiz) GetDevices() ([]Device, error)
- func (k *Kiz) Login() error
- func (k *Kiz) Off(device Device) (ExecID, error)
- func (k *Kiz) On(device Device) (ExecID, error)
- func (k *Kiz) Open(device Device) (ExecID, error)
- func (k *Kiz) PollEvents() (Events, error)
- func (k *Kiz) PollEventsContinuous(ev chan<- Event, e chan<- error, finish <-chan struct{})
- func (k *Kiz) PollEventsContinuousWithSleepTime(ev chan<- Event, e chan<- error, finish <-chan struct{}, ...)
- func (k *Kiz) RefreshStates() error
- func (k *Kiz) SessionID() string
- func (k *Kiz) SetClosure(device Device, position int) (ExecID, error)
- func (k *Kiz) SetIntensity(device Device, intensity int) (ExecID, error)
- func (k *Kiz) Stop(device Device) (ExecID, error)
- type RefreshAllDevicesStatesCompletedEvent
- type StateDefinition
- type StateName
- type StateType
Constants ¶
const ( CmdClose = "close" CmdDown = "down" CmdIdentify = "identify" CmdOff = "off" CmdOn = "on" CmdOpen = "open" CmdSetIntensity = "setIntensity" CmdSetClosure = "setClosure" CmdStartIdentify = "startIdentify" CmdStop = "stop" CmdStopIdentify = "stopIdentify" CmdUp = "up" )
CommandNames
Variables ¶
This section is empty.
Functions ¶
func Output ¶
Output prints the given object to the writer in the desired format format can be 'text', 'json' or 'yaml'
func SupportsCommand ¶
SupportsCommand returns true if the command is supported by the device.
Types ¶
type Action ¶
type Action struct { DeviceURL DeviceURL `json:"deviceURL,omitempty"` Commands []Command `json:"commands,omitempty"` }
Action defines a list of commands
type ActionGroup ¶
type ActionGroup struct { CreationTime int `json:"creationTime,omitempty"` LastUpdateTime int `json:"lastUpdateTime,omitempty"` Label string `json:"label,omitempty"` Shortcut bool `json:"shortcut,omitempty"` NotificationTypeMask int `json:"notificationTypeMask,omitempty"` NotificationCondition string `json:"notificationCondition,omitempty"` Actions []Action `json:"actions,omitempty"` OID string `json:"oid,omitempty"` }
ActionGroup is a list of Actions in sequence, with metadata. Think "scenario".
func ActionGroupWithOneCommand ¶
func ActionGroupWithOneCommand(device Device, command Command) (ActionGroup, error)
ActionGroupWithOneCommand returns an action group with a single command for the device
type Command ¶
type Command struct { Type int `json:"type,omitempty"` Name string `json:"name,omitempty"` Parameters interface{} `json:"parameters,omitempty"` }
Command describes a command (duh)
type CommandDefinition ¶
type CommandDefinition struct { CommandName string `json:"commandName,omitempty"` Nparams int `json:"nparams,omitempty"` }
CommandDefinition describes the fields of a Command
type CommandExecutionStateChangedEvent ¶
type CommandExecutionStateChangedEvent struct { GenericEvent DeviceURL DeviceURL `json:"deviceURL,omitempty"` ExecID ExecID `json:"execID,omitempty"` SetupOID string `json:"setupOID,omitempty"` NewState string `json:"newState,omitempty"` FailureType string `json:"failureType,omitempty"` FailureTypeCode int `json:"failureTypeCode,omitempty"` Rank int `json:"rank,omitempty"` }
CommandExecutionStateChangedEvent indicates a change in the state of the execution of a command
type Device ¶
type Device struct { CreationTime int LastUpdateTime int Label string DeviceURL DeviceURL Shortcut bool ControllableName string Definition DeviceDefinition States []DeviceState Available bool Enabled bool PlaceOID string Widget string Type int OID string UIClass string }
Device representation of a single device
type DeviceDefinition ¶
type DeviceDefinition struct { Commands []CommandDefinition States []StateDefinition WidgetName string UIClass string QualifiedName string Type string }
DeviceDefinition describes the fields of a Device
type DeviceState ¶
DeviceState encodes a device state
type DeviceStateChangedEvent ¶
type DeviceStateChangedEvent struct { GenericEvent SetupOID string `json:"setupOID,omitempty"` DeviceURL DeviceURL `json:"deviceURL,omitempty"` DeviceStates []DeviceState `json:"deviceStates,omitempty"` }
DeviceStateChangedEvent indicates a change in the state of a device
type DeviceURL ¶
type DeviceURL string
DeviceURL is the full device URL including prefix e.g. io://1111-0000-4444/12345678
type EndUserLoginEvent ¶
type EndUserLoginEvent struct { GenericEvent SetupOID string `json:"setupOID,omitempty"` UserID string `json:"userId,omitempty"` UserAgentType string `json:"userAgentType,omitempty"` }
EndUserLoginEvent happens when a user authenticates
type Events ¶
type Events []Event
Events is a slide of Event, used for unmarshalling several events of unknown type from json
func (*Events) UnmarshalJSON ¶
UnmarshalJSON unmarshals an event from json, detecting the right event type
type ExecutionEvent ¶
type ExecutionEvent struct { ExecID ExecID `json:"execID,omitempty"` SetupOID string `json:"setupOID,omitempty"` SubType int `json:"subType,omitempty"` Type int `json:"type,omitempty"` }
ExecutionEvent is the minimal set of fields shared by all Execution events
type ExecutionRegisteredEvent ¶
type ExecutionRegisteredEvent struct { GenericEvent ExecutionEvent Label string `json:"label,omitempty"` Metadata string `json:"metadata,omitempty"` TriggerID string `json:"triggerId,omitempty"` Actions []Action `json:"actions,omitempty"` }
ExecutionRegisteredEvent indicates an execution has been registered
type ExecutionStateChangedEvent ¶
type ExecutionStateChangedEvent struct { GenericEvent ExecutionEvent NewState string `json:"newState,omitempty"` OldState string `json:"oldState,omitempty"` OwnerKey string `json:"ownerKey,omitempty"` TimeToNextState int `json:"timeToNextState,omitempty"` }
ExecutionStateChangedEvent indicates a change in the state of an execution
type GatewayAliveEvent ¶
type GatewayAliveEvent struct { GenericEvent GatewayEvent }
GatewayAliveEvent indicates the gateway is accessible again
type GatewayDownEvent ¶
type GatewayDownEvent struct { GenericEvent GatewayEvent }
GatewayDownEvent indicates the gateway has become unreachable
type GatewayEvent ¶
type GatewayEvent struct {
GatewayID string `json:"gatewayId,omitempty"`
}
GatewayEvent indicates an event related to a gateway
type GatewaySynchronizationEndedEvent ¶
type GatewaySynchronizationEndedEvent struct { GenericEvent GatewayEvent }
GatewaySynchronizationEndedEvent indicates the end of synchronization of a gateway
type GatewaySynchronizationStartedEvent ¶
type GatewaySynchronizationStartedEvent struct { GenericEvent GatewayEvent }
GatewaySynchronizationStartedEvent indicates the start of synchronization of a gateway
type GenericEvent ¶
type GenericEvent struct { Timestamp int `json:"timestamp,omitempty"` Name string `json:"name,omitempty"` }
GenericEvent is the minimal set of fields shared by all events
func (*GenericEvent) Kind ¶
func (e *GenericEvent) Kind() string
Kind returns a partial text description of the event
type Kiz ¶
type Kiz struct {
// contains filtered or unexported fields
}
Kiz high-level client
func New ¶
New returns an initialized Kiz sessionID is optional and used for external caching of sessions
func NewWithAPIClient ¶
NewWithAPIClient returns an initialized Kiz from an existing API client
func (*Kiz) Execute ¶
func (k *Kiz) Execute(ag ActionGroup) (ExecID, error)
Execute runs an action group and returns a (job) ExecID
func (*Kiz) GetActionGroups ¶
func (k *Kiz) GetActionGroups() ([]ActionGroup, error)
GetActionGroups returns the list of action groups defined on the box
func (*Kiz) GetDeviceByText ¶
GetDeviceByText returns a Device from a text string If first tries to match a DeviceURL. If no match, it tries to match a device Label
func (*Kiz) GetDeviceState ¶
func (k *Kiz) GetDeviceState(deviceURL DeviceURL, stateName StateName) (DeviceState, error)
GetDeviceState returns the current state with name stateName for the device with URL deviceURL
func (*Kiz) GetDevices ¶
GetDevices returns the list of devices
func (*Kiz) Login ¶
Login to the api server to obtain a session ID cookie This is normally called automatically from the methods that need it
func (*Kiz) PollEvents ¶
PollEvents polls for events on the stored listener
func (*Kiz) PollEventsContinuous ¶
PollEventsContinuous calls PollEventsContinuousWithSleepTime with a reasonable polling interval
func (*Kiz) PollEventsContinuousWithSleepTime ¶
func (k *Kiz) PollEventsContinuousWithSleepTime(ev chan<- Event, e chan<- error, finish <-chan struct{}, sleepTime time.Duration)
PollEventsContinuousWithSleepTime polls for events at given intervals and sends received events and errors on given channels. In case of error, polling will resume after a moment. Close the finish channel to indicate that this method should stop polling and return. It can be used in a goroutine.
func (*Kiz) RefreshStates ¶
RefreshStates tells the server send the state of all devices as events
func (*Kiz) SessionID ¶
SessionID is the latest known sessionID value It can be used for caching sessions externally.
func (*Kiz) SetClosure ¶
SetClosure sets the device closure/position to given value
func (*Kiz) SetIntensity ¶
SetIntensity sets the light intensity to given value
type RefreshAllDevicesStatesCompletedEvent ¶
type RefreshAllDevicesStatesCompletedEvent struct { GenericEvent GatewayEvent ProtocolType int `json:"protocolType,omitempty"` }
RefreshAllDevicesStatesCompletedEvent indicates the end of a request to get the state of all devices
type StateDefinition ¶
StateDefinition describes the fields of a State
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package api provides a low-level client to the overkiz api JSON responses are not unmarshalled and are returned as-is.
|
Package api provides a low-level client to the overkiz api JSON responses are not unmarshalled and are returned as-is. |
cmd
|
|
Package config provides handling of configuration through a config file
|
Package config provides handling of configuration through a config file |