Documentation
¶
Index ¶
- Constants
- Variables
- func BlendColor(e *EffectRoutine, light *Light, last_color colorful.Color)
- func HclLoop(done chan bool, light *Light)
- func HsvLoop(done chan bool, light *Light)
- func RainbowLoop(done chan bool, light *Light)
- func SendState(l *Light, last_color colorful.Color)
- func UpdateColorState(dest *ColorState, req *restful.Request)
- func WrapLight(l *Light) interface{}
- func WrapLights(l map[string]*Light) map[string]interface{}
- func WriteDELETESuccess(response *restful.Response, ids []string)
- func WriteError(response *restful.Response, errorType int, addr string, ...)
- func WritePOSTSuccess(response *restful.Response, ids []string)
- func WritePUTSuccess(response *restful.Response, fields map[string]interface{})
- func WritePUTSuccessExplicit(response *restful.Response, fields map[string]interface{})
- type ColorState
- type Command
- type Config
- type ConfigInfo
- type Developer
- type EffectRoutine
- type ErrorResponse
- type Group
- type GroupInfo
- type Light
- type LightInfo
- type LightResource
- func (l *LightResource) ImportSchedules(configfile string)
- func (l LightResource) PersistState(light *Light, id string)
- func (l LightResource) RegisterConfigApi(container *restful.Container)
- func (l LightResource) RegisterGroupsApi(container *restful.Container)
- func (l LightResource) RegisterLightsApi(container *restful.Container)
- func (l LightResource) RegisterSchedulesApi(container *restful.Container)
- func (l LightResource) RestoreState()
- type LuxLight
- type LuxState
- type Schedule
- type State
- type SuccessResponse
- type UpdateInfo
- type UserInfo
- type Xy
Constants ¶
View Source
const ( Ex_Color_Light = "Extended color light" Dimmable_Light = "Dimmable light" On_Off_Plug_Light = "On/Off plug-in unit" )
Light Types
View Source
const ( JSONError = 2 ResourceError = 3 ValueError = 7 ROGroupError = 305 )
Error Types
View Source
const LightGroup string = "LightGroup"
View Source
const Lightsource string = "Lightsource"
View Source
const Luminaire string = "Luminaire"
Variables ¶
View Source
var ErrorDescriptions map[int]string = map[int]string{ JSONError: "body contains invalid JSON", ResourceError: "resource, {{.resource}}, not available", ValueError: "invalid value, {{.value}}, for parameter, {{.parameter}}", ROGroupError: "It is not allowed to update or delete group of this type", }
View Source
var ErrorStatusCodes map[int]int = map[int]int{ JSONError: 400, ResourceError: 404, ValueError: 400, ROGroupError: 403, }
Offical API returns 200 on error?
Functions ¶
func BlendColor ¶
func BlendColor(e *EffectRoutine, light *Light, last_color colorful.Color)
func UpdateColorState ¶
func UpdateColorState(dest *ColorState, req *restful.Request)
func WrapLights ¶
func WriteDELETESuccess ¶
func WriteError ¶
func WritePOSTSuccess ¶
func WritePUTSuccess ¶
func WritePUTSuccessExplicit ¶
Unfortunately the Hue API seems to be inconsistant in response format
Types ¶
type ColorState ¶
type ColorState struct {
LightID string `json:"-" gorm:"primary_key"`
Alert string `json:"alert"`
Bri uint8 `json:"bri"`
BriInc int16 `json:"bri_inc,omitempty"`
Ct uint16 `json:"ct"`
Effect string `json:"effect"`
EffectSpread float64 `json:"effectspread,omitempty"`
Hue uint16 `json:"hue"`
On bool `json:"on"`
TransitionTime uint16 `json:"transitiontime,omitempty"`
Sat uint8 `json:"sat"`
Xy Xy `json:"xy" gorm:"embedded"`
Colormode string `json:"colormode"`
*EffectRoutine `gorm:"-"`
}
func (*ColorState) GetColor ¶
func (state *ColorState) GetColor() (c colorful.Color)
type Command ¶
type Command struct {
Address string `json:"address"`
Body json.RawMessage `json:"body"`
Method string `json:"method"`
}
type ConfigInfo ¶
type ConfigInfo struct {
Name string `json:"name"`
Mac string `json:"mac"`
Dhcp bool `json:"dhcp"`
Ipaddress string `json:"ipaddress"`
Netmask string `json:"netmask"`
Gateway string `json:"gateway"`
Proxyaddress string `json:"proxyaddress"`
Proxyport int `json:"proxyport"`
UTC string `json:"UTC"`
Whitelist map[string]Developer `json:"whitelist"`
Swversion string `json:"swversion"`
//Apiversion string `json:"apiversion"` // 1.2.1 +
Swupdate UpdateInfo `json:"swupdate"`
Portalservices bool `json:"portalservices"`
}
func NewConfigInfo ¶
func NewConfigInfo() *ConfigInfo
type EffectRoutine ¶
type ErrorResponse ¶
type Group ¶
type Group struct {
GroupInfo
State *ColorState `json:"action"`
ReadOnly bool `json:"-"`
Lights []*Light `json:"-"`
}
func NewGroup ¶
func NewGroup(l *LightResource, i GroupInfo, s *ColorState, ro bool) *Group
func (Group) GetNumPixels ¶
type LightInfo ¶
type LightInfo struct {
// Api def limits these strings to certain length, FIXME if doesn't work
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
ModelId string `json:"modelid,omitempty"`
SwVersion string `json:"swversion,omitempty"`
// Api def claims unimplemented atm, FIXME if doesn't work
PointSymbol map[string]string `json:"pointsymbol"`
}
type LightResource ¶
type LightResource struct {
Lights map[string]*Light `json:"lights"`
Groups map[string]*Group `json:"groups"`
Schedules map[string]*Schedule `json:"schedules"`
*ConfigInfo `json:"config"`
DB *gorm.DB `json:"-"`
}
func (*LightResource) ImportSchedules ¶
func (l *LightResource) ImportSchedules(configfile string)
func (LightResource) PersistState ¶
func (l LightResource) PersistState(light *Light, id string)
func (LightResource) RegisterConfigApi ¶
func (l LightResource) RegisterConfigApi(container *restful.Container)
func (LightResource) RegisterGroupsApi ¶
func (l LightResource) RegisterGroupsApi(container *restful.Container)
func (LightResource) RegisterLightsApi ¶
func (l LightResource) RegisterLightsApi(container *restful.Container)
func (LightResource) RegisterSchedulesApi ¶
func (l LightResource) RegisterSchedulesApi(container *restful.Container)
func (LightResource) RestoreState ¶
func (l LightResource) RestoreState()
type LuxState ¶
type LuxState struct {
*State
Ct bool `json:"ct,omitempty"`
Hue bool `json:"hue,omitempty"`
Sat bool `json:"sat,omitempty"`
Xy bool `json:"xy,omitempty"`
Colormode bool `json:"colormode,omitempty"`
}
Omit color fields for white only lights
type Schedule ¶
type Schedule struct {
Name string `json:"name"`
Description string `json:"description"`
Command Command `json:"command"`
LocalTime string `json:"localtime"`
Time string `json:"time"`
Created string `json:"created"`
Status string `json:"status"`
Autodelete bool `json:"autodelete"`
Timer *time.Timer `json:"-"`
Schedules map[string]*Schedule `json:"-"`
ID string `json:"-"`
}
type State ¶
type State struct {
Reachable bool `json:"reachable"`
*ColorState
}
type SuccessResponse ¶
type SuccessResponse struct {
Field interface{} `json:"success"`
}
type UpdateInfo ¶
Click to show internal directories.
Click to hide internal directories.