hue

package
v1.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FuncMap = template.FuncMap{
	"battery": func(value int64) string {
		switch {
		case value >= 90:
			return "battery-full?fill=limegreen"
		case value >= 75:
			return "battery-three-quarters?fill=limegreen"
		case value >= 50:
			return "battery-half?fill=darkorange"
		case value >= 25:
			return "battery-quarter?fill=darkorange"
		default:
			return "battery-empty?fill=salmon"
		}
	},
	"temperature": func(value float64) string {
		switch {
		case value >= 28:
			return "thermometer-full?fill=salmon"
		case value >= 24:
			return "thermometer-three-quarters?fill=darkorange"
		case value >= 18:
			return "thermometer-half?fill=limegreen"
		case value >= 14:
			return "thermometer-half?fill=darkorange"
		case value >= 10:
			return "thermometer-quarter?fill=darkorange"
		case value >= 4:
			return "thermometer-empty?fill=salmon"
		default:
			return "snowflake?fill=cornflowerblue"
		}
	},
	"groupName": func(groups []v2.Group, id string) string {
		for _, group := range groups {
			if group.ID == id {
				return group.Name
			}
		}
		return ""
	},
}

FuncMap for template rendering

View Source
var (
	// States available states of lights
	States = map[string]State{
		"off": {
			On:       false,
			Duration: time.Second * 3,
		},
		"long_off": {
			On:       false,
			Duration: time.Second * 30,
		},
		"on": {
			On:         true,
			Duration:   time.Second * 3,
			Brightness: 100,
		},
		"half": {
			On:         true,
			Duration:   time.Second * 3,
			Brightness: 50,
		},
		"dimmed": {
			On:         true,
			Duration:   time.Second * 3,
			Brightness: 0,
		},
		"long_on": {
			On:         true,
			Duration:   time.Minute * 5,
			Brightness: 100,
		},
	}
)

Functions

This section is empty.

Types

type APIScene

type APIScene struct {
	Lightstates map[string]State `json:"lightstates,omitempty"`
	Name        string           `json:"name,omitempty"`
	Lights      []string         `json:"lights,omitempty"`
	Recycle     bool             `json:"recycle"`
}

APIScene describe scene as from Hue API

type APISchedule

type APISchedule struct {
	Name      string `json:"name,omitempty"`
	Localtime string `json:"localtime,omitempty"`
	Command   Action `json:"command,omitempty"`
	Status    string `json:"status,omitempty"`
}

APISchedule describe schedule as from Hue API

type Action

type Action struct {
	Address string `json:"address,omitempty"`
	Body    any    `json:"body,omitempty"`
	Method  string `json:"method,omitempty"`
}

Action description

func (Action) GetGroup added in v1.11.0

func (a Action) GetGroup() string

GetGroup returns the group ID of the Action performed

type App

type App struct {
	// contains filtered or unexported fields
}

App stores information and secret of API

func New

func New(config Config, renderer *renderer.App, v2App *v2.App) (*App, error)

New creates new App from Config

func (*App) Handler added in v1.12.0

func (a *App) Handler() http.Handler

Handler for request. Should be use with net/http

func (*App) Start

func (a *App) Start(ctx context.Context)

Start worker

func (*App) TemplateFunc added in v1.12.0

func (a *App) TemplateFunc(w http.ResponseWriter, r *http.Request) (renderer.Page, error)

TemplateFunc for rendering GUI

type ByScheduleID added in v1.17.3

type ByScheduleID []Schedule

ByScheduleID sort Schedule by id

func (ByScheduleID) Len added in v1.17.3

func (a ByScheduleID) Len() int

func (ByScheduleID) Less added in v1.17.3

func (a ByScheduleID) Less(i, j int) bool

func (ByScheduleID) Swap added in v1.17.3

func (a ByScheduleID) Swap(i, j int)

type BySensorID added in v1.17.3

type BySensorID []Sensor

BySensorID sort Sensor by id

func (BySensorID) Len added in v1.17.3

func (a BySensorID) Len() int

func (BySensorID) Less added in v1.17.3

func (a BySensorID) Less(i, j int) bool

func (BySensorID) Swap added in v1.17.3

func (a BySensorID) Swap(i, j int)

type Condition

type Condition struct {
	Address  string `json:"address,omitempty"`
	Operator string `json:"operator,omitempty"`
	Value    string `json:"value,omitempty"`
}

Condition description

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config of package

func Flags

func Flags(fs *flag.FlagSet, prefix string) Config

Flags adds flags for configuring package

type Group

type Group struct {
	ID     string     `json:"id,omitempty"`
	Name   string     `json:"name,omitempty"`
	Lights []string   `json:"lights,omitempty"`
	State  groupState `json:"state,omitempty"`
	Tap    bool       `json:"tap,omitempty"`
}

Group description

type Light

type Light struct {
	ID    string     `json:"id,omitempty"`
	Type  string     `json:"type,omitempty"`
	State lightState `json:"state,omitempty"`
}

Light description

type Rule

type Rule struct {
	ID         string      `json:"-"`
	Status     string      `json:"status,omitempty"`
	Name       string      `json:"name,omitempty"`
	Actions    []Action    `json:"actions,omitempty"`
	Conditions []Condition `json:"conditions,omitempty"`
}

Rule description

type Scene

type Scene struct {
	ID string `json:"id,omitempty"`
	APIScene
}

Scene description

type Schedule

type Schedule struct {
	ID string `json:"id,omitempty"`
	APISchedule
}

Schedule description

func (Schedule) FormatLocalTime

func (s Schedule) FormatLocalTime() string

FormatLocalTime formats local time of schedules to human-readable version

type ScheduleConfig

type ScheduleConfig struct {
	Name      string
	Localtime string
	Group     string
	State     string
}

ScheduleConfig configuration (made simple)

type Sensor

type Sensor struct {
	ID     string       `json:"-"`
	Name   string       `json:"name,omitempty"`
	Type   string       `json:"type,omitempty"`
	State  sensorState  `json:"state,omitempty"`
	Config SensorConfig `json:"config,omitempty"`
}

Sensor description

type SensorConfig added in v1.11.1

type SensorConfig struct {
	Battery       uint `json:"battery,omitempty"`
	On            bool `json:"on"`
	LedIndication bool `json:"ledindication"`
}

SensorConfig description

type State added in v1.20.0

type State struct {
	On         bool          `json:"on"`
	Duration   time.Duration `json:"transitiontime"`
	Brightness uint64        `json:"bri"`
}

State description

func (State) V1 added in v1.20.0

func (s State) V1() map[string]interface{}

V1 transform state to its V1 version

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL