v2

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: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse

type APIResponse[T any] struct {
	Data   []T `json:"data"`
	Errors []struct {
		Description string `json:"description"`
	} `json:"errors"`
}

APIResponse description

type App

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

App stores information and secret of API

func New

func New(config Config, meterProvider metric.MeterProvider) (*App, error)

New creates new App from Config

func (*App) Groups

func (a *App) Groups() []Group

Groups list available groups

func (*App) Sensors

func (a *App) Sensors() []MotionSensor

func (*App) Start

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

Start worker

func (*App) UpdateGroup

func (a *App) UpdateGroup(ctx context.Context, id string, on bool, brightness float64, transitionTime time.Duration) (Group, error)

UpdateGroup status

func (*App) UpdateSensor

func (a *App) UpdateSensor(ctx context.Context, id string, enabled bool) (MotionSensor, error)

type Color added in v1.23.0

type Color struct {
	XY struct {
		X float64 `json:"x"`
		Y float64 `json:"y"`
	} `json:"xy"`
}

type ColorTemperature added in v1.23.0

type ColorTemperature struct {
	Mirek int `json:"mirek"`
}

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 Device

type Device struct {
	ProductData struct {
		ManufacturerName string `json:"manufacturer_name"`
		ModelID          string `json:"model_id"`
		ProductArchetype string `json:"product_archetype"`
		ProductName      string `json:"product_name"`
		SoftwareVersion  string `json:"software_version"`
		Certified        bool   `json:"certified"`
	} `json:"product_data"`
	Metadata struct {
		Archetype string `json:"archetype"`
		Name      string `json:"name"`
	} `json:"metadata"`
	ID       string            `json:"id"`
	IDV1     string            `json:"id_v1"`
	Type     string            `json:"type"`
	Services []deviceReference `json:"services"`
}

Device description

type DeviceByID

type DeviceByID []Device

DeviceByID sort Device by ID

func (DeviceByID) Len

func (a DeviceByID) Len() int

func (DeviceByID) Less

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

func (DeviceByID) Swap

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

type DevicePower

type DevicePower struct {
	Owner      deviceReference `json:"owner"`
	ID         string          `json:"id"`
	PowerState struct {
		BatteryState string `json:"battery_state"`
		BatteryLevel int64  `json:"battery_level"`
	} `json:"power_state"`
}

DevicePower description

type DevicePowerByOwner

type DevicePowerByOwner []DevicePower

DevicePowerByOwner sort DevicePower by Owner

func (DevicePowerByOwner) Len

func (a DevicePowerByOwner) Len() int

func (DevicePowerByOwner) Less

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

func (DevicePowerByOwner) Swap

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

type Dimming

type Dimming struct {
	Brightness float64 `json:"brightness"`
}

type Event

type Event struct {
	Type string `json:"type"`
	Data []struct {
		Motion           *MotionValue      `json:"motion,omitempty"`
		ColorTemperature *ColorTemperature `json:"color_temperature,omitempty"`
		Color            *Color            `json:"color,omitempty"`
		Dimming          *Dimming          `json:"dimming,omitempty"`
		On               *On               `json:"on,omitempty"`
		Enabled          *bool             `json:"enabled,omitempty"`
		Owner            deviceReference   `json:"owner"`
		ID               string            `json:"id"`
		Type             string            `json:"type"`
		PowerState       struct {
			BatteryState string `json:"battery_state"`
			BatteryLevel int64  `json:"battery_level"`
		}
		Light struct {
			Level int64 `json:"light_level"`
		} `json:"light"`
		Temperature struct {
			Temperature float64 `json:"temperature"`
		} `json:"temperature"`
	} `json:"data"`
}

Event from the server sent event

type Group

type Group struct {
	GroupedLights map[string]GroupedLight
	ID            string
	Name          string
	Lights        []*Light
	Bridge        bool
	Plug          bool
}

Group description

func (Group) AnyOn

func (g Group) AnyOn() bool

AnyOn checks if any lights in the group is on

type GroupByTypeAndName

type GroupByTypeAndName []Group

GroupByTypeAndName sort Group by Type then, Name

func (GroupByTypeAndName) Len

func (a GroupByTypeAndName) Len() int

func (GroupByTypeAndName) Less

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

func (GroupByTypeAndName) Swap

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

type GroupedLight

type GroupedLight struct {
	ID    string `json:"id"`
	Alert struct {
		ActionValues []string `json:"action_values"`
	} `json:"alert"`
	Dimming Dimming `json:"dimming"`
	On      On      `json:"on"`
}

GroupedLight description

type Light

type Light struct {
	ID       string `json:"id"`
	Metadata struct {
		Archetype string `json:"archetype"`
		Name      string `json:"name"`
	} `json:"metadata"`
	On               On               `json:"on"`
	Dimming          Dimming          `json:"dimming"`
	Color            Color            `json:"color"`
	ColorTemperature ColorTemperature `json:"color_temperature"`
}

type LightLevel

type LightLevel struct {
	Owner deviceReference `json:"owner"`
	ID    string          `json:"id"`
	Light struct {
		LightLevel      int64 `json:"light_level"`
		LightLevelValid bool  `json:"light_level_valid"`
	} `json:"light"`
	Enabled bool `json:"enabled"`
}

type LightLevelByOwner

type LightLevelByOwner []LightLevel

func (LightLevelByOwner) Len

func (a LightLevelByOwner) Len() int

func (LightLevelByOwner) Less

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

func (LightLevelByOwner) Swap

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

type Motion

type Motion struct {
	Owner   deviceReference `json:"owner"`
	ID      string          `json:"id"`
	Motion  MotionValue     `json:"motion"`
	Enabled bool            `json:"enabled"`
}

type MotionByOwner

type MotionByOwner []Motion

func (MotionByOwner) Len

func (a MotionByOwner) Len() int

func (MotionByOwner) Less

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

func (MotionByOwner) Swap

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

type MotionSensor

type MotionSensor struct {
	ID           string  `json:"id"`
	MotionID     string  `json:"motion_id"`
	Name         string  `json:"name"`
	BatteryState string  `json:"battery_state"`
	LightLevel   int64   `json:"light_level"`
	Temperature  float64 `json:"temperature"`
	BatteryLevel int64   `json:"battery_level"`
	Enabled      bool    `json:"enabled"`
	Motion       bool    `json:"motion"`
}

type MotionSensorByName

type MotionSensorByName []MotionSensor

func (MotionSensorByName) Len

func (a MotionSensorByName) Len() int

func (MotionSensorByName) Less

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

func (MotionSensorByName) Swap

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

type MotionValue

type MotionValue struct {
	Motion      bool `json:"motion"`
	MotionValid bool `json:"motion_valid"`
}

type On

type On struct {
	On bool `json:"on"`
}

type Room

type Room struct {
	ID       string `json:"id"`
	Metadata struct {
		Name string `json:"name"`
	} `json:"metadata"`
	Services []deviceReference `json:"services"`
	Children []deviceReference `json:"children"`
}

Room description

type Temperature

type Temperature struct {
	Owner       deviceReference `json:"owner"`
	ID          string          `json:"id"`
	Temperature struct {
		Temperature      float64 `json:"temperature"`
		TemperatureValid bool    `json:"temperature_valid"`
	} `json:"temperature"`
	Enabled bool `json:"enabled"`
}

type TemperatureByOwner

type TemperatureByOwner []Temperature

func (TemperatureByOwner) Len

func (a TemperatureByOwner) Len() int

func (TemperatureByOwner) Less

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

func (TemperatureByOwner) Swap

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

Jump to

Keyboard shortcuts

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