config

package
v0.2024.4 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DaylightDimming

type DaylightDimming struct {
	// Segments configures generated Thresholds based on some parameters
	// if Thresholds has any values, this will be ignored
	Segments *ThresholdSegments `json:"segments,omitempty"`
	// Thresholds configures a mapping between measured lux levels and output brightness of lights.
	// With Thresholds you can say "below 300 lux set brightness to 80%, below 700 lux set to 50%".
	// The threshold with the highest BelowLux value below the measured lux level will be selected.
	Thresholds []LevelThreshold `json:"thresholds,omitempty"`
	// PercentageTowardsGoal configures how quickly we reach our goal. If set to 50 then we calculate the desired level
	// from the lookup table and then go half way between current and desired.
	// A new lux reading will come in based on that light level; we will approach the goal, always undershooting.
	PercentageTowardsGoal float32 `json:"percentageTowardsGoal,omitempty"`
}

type LevelThreshold

type LevelThreshold struct {
	BelowLux     float32 `json:"belowLux,omitempty"`
	LevelPercent float32 `json:"levelPercent,omitempty"`
}

type Mode

type Mode struct {
	// UnoccupiedOffDelay configures how long we wait after the most recent occupancy sensor reported unoccupied before
	// we turn the light off.
	UnoccupiedOffDelay jsontypes.Duration `json:"unoccupiedOffDelay,omitempty"`
	// DaylightDimming configures how the brightness measured in the space affects the luminosity of the lights that
	// are on.
	DaylightDimming *DaylightDimming `json:"daylightDimming,omitempty"`
	// Levels to use when the lights are on or off. If present overrides daylight dimming.
	OnLevelPercent  *float32 `json:"onLevelPercent,omitempty"`
	OffLevelPercent *float32 `json:"offLevelPercent,omitempty"`
}

type ModeOption

type ModeOption struct {
	Name        string `json:"name,omitempty"`
	DisableAuto bool   `json:"disableAuto,omitempty"` // causes the automation to no do anything
	Mode
	Start *jsontypes.Schedule `json:"start,omitempty"`
	End   *jsontypes.Schedule `json:"end,omitempty"`
}

type Root

type Root struct {
	auto.Config

	OccupancySensors  []string `json:"occupancySensors,omitempty"`
	Lights            []string `json:"lights,omitempty"`
	BrightnessSensors []string `json:"brightnessSensors,omitempty"`

	Mode // default mode
	// Modes describe modes of operation and when they should be active by default.
	Modes []ModeOption `json:"modes,omitempty"`

	ModeSource   string `json:"modeSource,omitempty"` // the device name to read the active mode from
	ModeValueKey string `json:"modeName,omitempty"`   // the name of the mode value in ModeSource that represents the active mode. Defaults to lighting.mode

	// Devices implementing the Button trait will be used to switch the lights on and off when clicked once.
	OnButtons     []string `json:"onButtons,omitempty"`
	OffButtons    []string `json:"offButtons,omitempty"`
	ToggleButtons []string `json:"toggleButtons,omitempty"`

	// Now returns the current time. It's configurable for testing purposes, typically for testing the logic.
	Now func() time.Time `json:"-"`
}

Root represent the configuration parameters available for the lighting automation. This should be convertable to/from json.

func Default

func Default() Root

func Read

func Read(data []byte) (Root, error)

type ThresholdSegments

type ThresholdSegments struct {
	MinLux int `json:"minLux,omitempty"`
	MaxLux int `json:"maxLux,omitempty"`
	// defaults to 0!
	MinLevel int `json:"minLevel,omitempty"`
	// defaults to 100 (if 0), max 100
	MaxLevel int `json:"maxLevel,omitempty"`
	// defaults to 100 (if 0)
	Steps int `json:"steps,omitempty"`
}

ThresholdSegments will generate one LevelThreshold per step, with each threshold LevelPercent being evenly spread between MinLevel and MaxLevel, and each threshold BelowLux being evenly spread between MinLux and MaxLux

Jump to

Keyboard shortcuts

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