somnego

package module
v0.0.0-...-9592bdf Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

README

somnogo - control your Somneo from go

  1. Install and import the somnego dependency:
import "github.com/IPnator/somnego"
  1. Create a Somneo instance:
device := somnego.Somneo{Host: "<IP-or-local-domain>"}
  1. Do whatever you want - load information, control light
// Load device details
details, err := device.GetDeviceDetails()

// Turn main light on
err = device.TurnMainLightOn()

// Set main light level (in percent)
err = device.SetMainLightLevel(85)

// Get sensor data such as humidity
sensorData, err := device.GetSensorData()
fmt.Printf("Humidity: %v\n", sensorData.AverageHumidity)

// and more…

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ActiveAlarmsEndpoint string = "/di/v1/products/1/wualm/aalms"
View Source
var AlarmEnvironmentEndpoint string = "/di/v1/products/1/wualm/aenvs"
View Source
var DeviceDetailsEndpoint string = "/upnp/description.xml"
View Source
var DuskLightThemesEndpoint string = "/di/v1/products/1/files/dusklightthemes"
View Source
var DuskSettingsEndpoint string = "`/di/v1/products/1/wudsk"
View Source
var LightEndpoint string = "/di/v1/products/1/wulgt" // GET || PUT
View Source
var LightThemesEndpoint string = "/di/v1/products/1/files/lightthemes"
View Source
var SensorDataEnpoint string = "/di/v1/products/1/wusrd"
View Source
var WakeUpAlarmStatusEndpoint string = "/di/v1/products/1/wualm"
View Source
var WakeUpStatusEndpoint string = "/di/v1/products/1/wusts"
View Source
var WakeupPlayEndpoint string = "/di/v1/products/1/wuply"
View Source
var WakeupTonesEndpoint string = "/di/v1/products/1/files/wakeup"
View Source
var WindDownDuskEndpoint string = "/di/v1/products/1/files/winddowndusk"

Functions

func GET

func GET(url string) ([]byte, error)

func PUT

func PUT[T any](url string, payload T) ([]byte, error)

func SendRequest

func SendRequest(url string, method string, payload *[]byte) ([]byte, error)

Types

type ActiveAlarms

type ActiveAlarms struct {
	Year       [16]int `json:"ayear"` // Year of the alarm
	Month      [16]int `json:"amnth"` // Month (0-11)
	Day        [16]int `json:"alday"` // Day of the month
	DayBitMask [16]int `json:"daynm"` // Weekdays as bitmask (e.g., 254 = Mon-Sun)
	Hour       [16]int `json:"almhr"` // Hour (0-23)
	Minute     [16]int `json:"almmn"` // Minute (0-59)
}

Active alarms

type AlarmEnvironment

type AlarmEnvironment struct {
	ProfilesEnabled [16]bool `json:"prfen"`
	ProfileValues   [16]bool `json:"prfvs"`
	PowerSave       [48]int  `json:"pwrsv"`
}

Alarm environment settings

type DeviceDetails

type DeviceDetails struct {
	SpecVersion DeviceDetailsSpecVersion `xml:"specVersion"`
	Device      DeviceDetailsDevice      `xml:"device"`
}

Device details (XML representation)

type DeviceDetailsDevice

type DeviceDetailsDevice struct {
	DeviceType   string `xml:"deviceType"`
	FriendlyName string `xml:"friendlyName"`
	Manufacturer string `xml:"manufacturer"`
	ModelName    string `xml:"modelName"`
	ModelNumber  string `xml:"modelNumber"`
	UDN          string `xml:"UDN"`
	CppId        string `xml:"cppId"`
}

type DeviceDetailsSpecVersion

type DeviceDetailsSpecVersion struct {
	Major int `xml:"major"`
	Minor int `xml:"minor"`
}

type DuskSettings

type DuskSettings struct {
	IsOn         bool   `json:"onoff"`
	CurveType    int    `json:"curve"`
	Duration     int    `json:"durat"`
	ControlType  int    `json:"ctype"`
	SoundType    int    `json:"sndtp"`
	SoundDevice  string `json:"snddv"`
	SoundChannel string `json:"sndch"`
	SoundLevel   int    `json:"sndlv"`
	SoundStatus  int    `json:"sndss"`
}

type LightStatus

type LightStatus struct {
	LightLevel   int   `json:"ltlvl"`
	IsOn         bool  `json:"onoff"`
	Temperature  bool  `json:"tempy"`
	ControlType  int   `json:"ctype"`
	NightLight   bool  `json:"ngtlt"`
	WakeUpCurve  []int `json:"wucrv"`
	PWMOn        bool  `json:"pwmon"`
	PWMValues    []int `json:"pwmvs"`
	DimmerManual int   `json:"diman"`
}

type LightThemes

type LightThemes map[string]Tone

Light themes

type SensorData

type SensorData struct {
	// Current values
	MeasuredLux      float64 `json:"mslux"` // Brightness in Lux
	MeasuredTemp     float64 `json:"mstmp"` // Temperature in °C
	MeasuredHumidity float64 `json:"msrhu"` // Humidity in %
	MeasuredSound    int     `json:"mssnd"` // Sound level

	// Average values
	AverageLux      float64 `json:"avlux"` // Average brightness
	AverageTemp     float64 `json:"avtmp"` // Average temperature
	AverageHumidity float64 `json:"avhum"` // Average humidity
	AverageSound    int     `json:"avsnd"` // Average sound level

	EnergyScore int `json:"enscr"` // Energy score
}

type Somneo

type Somneo struct {
	Host        string
	LightStatus *LightStatus
	SensorData  *SensorData
}

func (*Somneo) GetActiveAlarms

func (somneo *Somneo) GetActiveAlarms() (ActiveAlarms, error)

func (*Somneo) GetAlarmEnvironment

func (somneo *Somneo) GetAlarmEnvironment() (AlarmEnvironment, error)

func (*Somneo) GetDeviceDetails

func (somneo *Somneo) GetDeviceDetails() (DeviceDetails, error)

func (*Somneo) GetDuskLightThemes

func (somneo *Somneo) GetDuskLightThemes() (LightThemes, error)

func (*Somneo) GetDuskSettings

func (somneo *Somneo) GetDuskSettings() (DuskSettings, error)

func (*Somneo) GetLightStatus

func (somneo *Somneo) GetLightStatus() (LightStatus, error)

func (*Somneo) GetLightThemes

func (somneo *Somneo) GetLightThemes() (LightThemes, error)

func (*Somneo) GetSensorData

func (somneo *Somneo) GetSensorData() (SensorData, error)

func (*Somneo) GetWakeupAlarmStatus

func (somneo *Somneo) GetWakeupAlarmStatus() (WakeupAlarmStatus, error)

func (*Somneo) GetWakeupPlay

func (somneo *Somneo) GetWakeupPlay() (WakeupPlay, error)

func (*Somneo) GetWakeupStatus

func (somneo *Somneo) GetWakeupStatus() (WakeUpStatus, error)

func (*Somneo) GetWakeupTones

func (somneo *Somneo) GetWakeupTones() (WakeupTones, error)

func (*Somneo) GetWindDownDusk

func (somneo *Somneo) GetWindDownDusk() (WindDownDusk, error)

func (*Somneo) SetMainLightLevel

func (somneo *Somneo) SetMainLightLevel(percent float64) error

func (*Somneo) TurnMainLightOff

func (somneo *Somneo) TurnMainLightOff() error

func (*Somneo) TurnMainLightOn

func (somneo *Somneo) TurnMainLightOn() error

Control main light

func (*Somneo) TurnNightlightOff

func (somneo *Somneo) TurnNightlightOff() error

func (*Somneo) TurnNightlightOn

func (somneo *Somneo) TurnNightlightOn() error

Control night light

func (*Somneo) TurnOffAllLights

func (somneo *Somneo) TurnOffAllLights() error

type Tone

type Tone struct {
	Name string `json:"name"`
}

General tone struct

type WakeUpStatus

type WakeUpStatus struct {
	WakeUpStatus int  `json:"wusts"`
	ReadyToPair  bool `json:"rpair"`
	PreviewMode  bool `json:"prvmd"`
	StoreDemo    bool `json:"sdemo"`
	PowerSave    bool `json:"pwrsz"`
	CurrentValue int  `json:"nrcur"`
	WizardStatus int  `json:"wizrd"`
	Brightness   int  `json:"brght"`
	DisplayOn    bool `json:"dspon"`
	WakeUpTime   int  `json:"wutim"`
	DurationTime int  `json:"dutim"`
	CanUpdate    bool `json:"canup"`
	SunsetTime   int  `json:"sntim"`
}

type WakeupAlarmStatus

type WakeupAlarmStatus struct {
	SnoozeTime       int              `json:"snztm"`
	AlarmEnvironment AlarmEnvironment `json:"aenvs"`
	ActiveAlarms     ActiveAlarms     `json:"aalms"`
	ProfileShare     int              `json:"prfsh"`
}

type WakeupPlay

type WakeupPlay struct {
	IsOn         bool   `json:"onoff"`
	Temperature  bool   `json:"tempy"`
	SoundVolume  int    `json:"sdvol"`
	SoundStatus  int    `json:"sndss"`
	SoundDevice  string `json:"snddv"`
	SoundChannel string `json:"sndch"`
}

type WakeupTones

type WakeupTones map[string]Tone

Wakeup tones

type WindDownDusk

type WindDownDusk map[string]Tone

Wind down dust

Jump to

Keyboard shortcuts

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