Documentation
¶
Overview ¶
Package panel exports functions related to a Nanoleaf Canvas controller
Index ¶
- Constants
- type APIPath
- type AuthToken
- type Brightness
- type ColourMode
- type Hue
- type Panel
- func (panel *Panel) Apply(settings *StateSettings) error
- func (panel *Panel) GetNewToken() (AuthToken, error)
- func (panel *Panel) GetStateSettings() (*StateSettings, error)
- func (panel *Panel) Off() error
- func (panel *Panel) On() error
- func (panel *Panel) SetAPIAddr(apiAddr string) error
- func (panel *Panel) SetBrightness(brightness Brightness) error
- func (panel *Panel) SetHue(hue Hue) error
- func (panel *Panel) SetSaturation(saturation Saturation) error
- func (panel *Panel) SetTemperature(temperature Temperature) error
- func (panel *Panel) SetToken(token AuthToken)
- type PowerState
- type Saturation
- type StateSettings
- type Temperature
Constants ¶
const ( // On is true On PowerState = true // Off is false Off PowerState = false // APIPathState is the path for the power on/off state APIPathState APIPath = "state" // APIPathNew is the path for token credentials APIPathNew APIPath = "new" // MinimumTemperature lowest colour temperature in Kelvin MinimumTemperature Temperature = 1200 // MaximumTemperature highest colour temperature in Kelvin MaximumTemperature Temperature = 6500 // MinimumBrightness lowest possible Brightness MinimumBrightness Brightness = 0 // MaximumBrightness lowest possible Brightness MaximumBrightness Brightness = 100 // MinimumHue lowest possible Hue MinimumHue Hue = 0 // MaximumHue highest possible Hue MaximumHue Hue = 360 // MinimumSaturation lowest possible saturation MinimumSaturation Saturation = 0 // MaximumSaturation highest possible saturation MaximumSaturation Saturation = 100 // ColourModeTemperature is the API's colourMode name for temperature ColourModeTemperature ColourMode = "ct" // ColourModeHueSaturation is the API's colourMode name for hue/saturation ColourModeHueSaturation ColourMode = "hs" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIPath ¶
type APIPath string
APIPath is the path after the auth-token, eg "state". See related consts
type ColourMode ¶
type ColourMode string
ColourMode describes the current method for setting colour, either "ct" or "hs", for temperature or hue/saturation
type Panel ¶
type Panel struct {
Status status
// contains filtered or unexported fields
}
Panel is a Nanoleaf panel
func (*Panel) Apply ¶
func (panel *Panel) Apply(settings *StateSettings) error
Apply adjusts multiple settings in a single request. NOTE: As of firmware v1.5.0, the Canvas returns a 404 when multiple settings are sent -- although it does actually succeed at applying the change. Given this bug, consider discarding the returned error here.
func (*Panel) GetNewToken ¶
GetNewToken attempts to get a new auth token from the panel. The panel must be in pairing mode for this to work. See notes under the API section 5.1, Authorization - https://forum.nanoleaf.me/docs/openapi the token is returned, and stored on the current panel object. The user should take care to save the returned token for future use.
func (*Panel) GetStateSettings ¶
func (panel *Panel) GetStateSettings() (*StateSettings, error)
GetStateSettings returns the current state of the panel, omitting fields which are not really in use, such as hue when the colour mode is temperature, as they would fail to apply together. This is somewhat buggy, as the returned values are generally incorrect if the panel was configured by something other than direct API calls, such as via mobile app.
func (*Panel) SetAPIAddr ¶
SetAPIAddr sets the address to be used when communicating with the API. Must be a valid URI.
func (*Panel) SetBrightness ¶
func (panel *Panel) SetBrightness(brightness Brightness) error
SetBrightness adjusts panel brightness
func (*Panel) SetSaturation ¶
func (panel *Panel) SetSaturation(saturation Saturation) error
SetSaturation adjusts panel saturation 0 - 100
func (*Panel) SetTemperature ¶
func (panel *Panel) SetTemperature(temperature Temperature) error
SetTemperature adjusts panel colour by Kelvin temperature 1200 - 6500
type StateSettings ¶
type StateSettings struct {
Brightness *brightnessSetting `json:"brightness,omitempty"`
Temperature *temperatureSetting `json:"ct,omitempty"`
Hue *hueSetting `json:"hue,omitempty"`
Saturation *saturationSetting `json:"saturation,omitempty"`
ColourMode *ColourMode `json:"colorMode,omitempty"`
On *onSetting `json:"on,omitempty"`
}
StateSettings settings for the panel display
func (*StateSettings) SetBrightness ¶
func (settings *StateSettings) SetBrightness(brightness Brightness)
SetBrightness is a helper function that allows updating a StateSettings object with shorthand eg "settings.SetBrightness(20)"
func (*StateSettings) SetHue ¶
func (settings *StateSettings) SetHue(hue Hue)
SetHue is a helper function that allows updating a StateSettings object with shorthand eg "settings.SetHue(20)"
func (*StateSettings) SetSaturation ¶
func (settings *StateSettings) SetSaturation(saturation Saturation)
SetSaturation is a helper function that allows updating a StateSettings object with shorthand eg "settings.SetSaturation(20)"
func (*StateSettings) SetTemperature ¶
func (settings *StateSettings) SetTemperature(temperature Temperature)
SetTemperature is a helper function that allows updating a StateSettings object with shorthand eg "settings.SetTemperature(1200)"
func (*StateSettings) Validate ¶
func (settings *StateSettings) Validate()
Validate adjusts settings to required min/max