hue

package
v1.17.2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FuncMap for template rendering
	FuncMap = template.FuncMap{
		"battery": func(value uint) 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 float32) 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 map[string]Group, id string) string {
			if group, ok := groups[id]; ok {
				return group.Name
			}
			return ""
		},
	}
)
View Source
var (
	// States available states of lights
	States = map[string]map[string]interface{}{
		"off": {
			"on":             false,
			"transitiontime": 30,
		},
		"long_off": {
			"on":             false,
			"transitiontime": 300,
		},
		"on": {
			"on":             true,
			"transitiontime": 30,
			"sat":            0,
			"bri":            255,
		},
		"half": {
			"on":             true,
			"transitiontime": 30,
			"sat":            0,
			"bri":            96,
		},
		"dimmed": {
			"on":             true,
			"transitiontime": 30,
			"sat":            0,
			"bri":            0,
		},
		"long_on": {
			"on":             true,
			"transitiontime": 3000,
			"sat":            0,
			"bri":            255,
		},
	}
)

Functions

This section is empty.

Types

type APIScene

type APIScene struct {
	Lightstates map[string]map[string]interface{} `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    map[string]interface{} `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 interface {
	Handler() http.Handler
	TemplateFunc(http.ResponseWriter, *http.Request) (string, int, map[string]interface{}, error)
	Start(<-chan struct{})
}

App stores informations and secret of API

func New

func New(config Config, registerer prometheus.Registerer, renderer renderer.App) (App, error)

New creates new App from Config

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 {
	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 {
	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) FindStateName

func (s Schedule) FindStateName(scenes map[string]Scene) (output string)

FindStateName finds matching state's name

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

Jump to

Keyboard shortcuts

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