Documentation
¶
Overview ¶
Package aha is a Go-Wrapper for the AHA HTTP Interface (AVM Home Automation HTTP Interface)
Index ¶
- Constants
- func GetCapability[C Capability](d Device) (r C)
- func GetDeviceInfos(c *fritzbox.Client, identifier string, dest Capability) (err error)
- func GetDeviceInfosRaw(c *fritzbox.Client, identifier string) (res json.RawMessage, err error)
- type Alert
- type Button
- type ButtonDevice
- type Capabilities
- type Capability
- type ColorControl
- type Device
- func (d *Device) DECTGetName(c *fritzbox.Client) (response string, err error)
- func (d *Device) DECTIsSwitchPresent(c *fritzbox.Client) (bool, error)
- func (d *Device) DECTSetName(c *fritzbox.Client, name string) error
- func (d *Device) HasCapability(cap string) bool
- func (d *Device) IsSwitchPresent() bool
- func (d *Device) String() string
- type DeviceList
- type ETSIUnitInfo
- type HFSuotaUpdate
- type HanFun
- type Hkr
- func (h *Hkr) DECTDeactivateBoost(c *fritzbox.Client) error
- func (h *Hkr) DECTDeactivateWindowOpen(c *fritzbox.Client) error
- func (h *Hkr) DECTGetAbsenk(c *fritzbox.Client) (string, error)
- func (h *Hkr) DECTGetAbsenkNumeric(c *fritzbox.Client) (float64, error)
- func (h *Hkr) DECTGetKomfort(c *fritzbox.Client) (string, error)
- func (h *Hkr) DECTGetKomfortNumeric(c *fritzbox.Client) (float64, error)
- func (h *Hkr) DECTGetSoll(c *fritzbox.Client) (r string, err error)
- func (h *Hkr) DECTGetSollNumeric(c *fritzbox.Client) (float64, error)
- func (h *Hkr) DECTSetSoll(c *fritzbox.Client, sollTemp any) error
- func (h *Hkr) DECTSetSollMax(c *fritzbox.Client) error
- func (h *Hkr) DECTSetSollOff(c *fritzbox.Client) error
- func (h *Hkr) DECTSetWindowOpen(c *fritzbox.Client, d time.Duration) (tm time.Time, err error)
- func (h *Hkr) Device() *Device
- func (h *Hkr) GetAbsenk() (r string)
- func (h *Hkr) GetAbsenkNumeric() float64
- func (h *Hkr) GetBoostEndtime() time.Time
- func (h *Hkr) GetErrorString() string
- func (h *Hkr) GetKomfort() (r string)
- func (h *Hkr) GetKomfortNumeric() float64
- func (h *Hkr) GetNextChangeTemperature() string
- func (h *Hkr) GetNextChangeTemperatureNumeric() float64
- func (h *Hkr) GetNextchangeEndtime() time.Time
- func (h *Hkr) GetSoll() (r string)
- func (h *Hkr) GetSollNumeric() float64
- func (h *Hkr) GetWindowOpenEndtime() time.Time
- func (h *Hkr) IsBatteryLow() bool
- func (h *Hkr) IsBoostActive() bool
- func (h *Hkr) IsHolidayActive() bool
- func (h *Hkr) IsSummerActive() bool
- func (h *Hkr) IsWindowOpen() bool
- func (h *Hkr) Name() string
- func (h *Hkr) Reload(c *fritzbox.Client) error
- func (h *Hkr) SetBoost(c *fritzbox.Client, d time.Duration) (tm time.Time, err error)
- func (h *Hkr) String() string
- type Interface
- type KeepAlive
- type LevelControl
- type OnOff
- type OpenClose
- type OpenCloseConfig
- type SimpleButton
- type Temperature
- func (t *Temperature) DECTGetCelsiusNumeric(c *fritzbox.Client) (float64, error)
- func (t *Temperature) DECTGetDeviceStats(c *fritzbox.Client) (ts TemperatureStats, err error)
- func (t *Temperature) Device() *Device
- func (t *Temperature) GetCelsiusNumeric() float64
- func (t *Temperature) GetOffsetNumeric() float64
- func (t *Temperature) Name() string
- func (t *Temperature) Reload(c *fritzbox.Client) error
- func (t *Temperature) String() string
- type TemperatureStats
- type Unit
- func (h *Unit) Device() *Device
- func (*Unit) FromJSON(m map[string]json.RawMessage, d *Device) (*Unit, error)
- func (h *Unit) GetRawProperties() (s map[string]string, err error)
- func (h *Unit) IsUnitOfType(t Interface) bool
- func (h *Unit) Reload(c *fritzbox.Client) error
- func (h *Unit) String() string
- func (h *Unit) UnmarshalProperty(propertyKey string, dest Interface) error
- type Units
Constants ¶
const ( TempOff = 253 // radiator off (snowflake) TempMax = 254 // radiator max CHanfun = "HAN-FUN Gerät" CLicht = "Licht/Lampe" CAlarm = "Alarm-Sensor" CButton = "AVM-ButtonDevice" CHKR = "Heizkörperregler" CEnergieMesser = "Energie Messgerät" CTempSensor = "Temperatursensor" CSteckdose = "Schaltsteckdose" CRepeater = "AVM DECT Repeater" CMikrofon = "Mikrofon" CHanfunUnit = "HAN-FUN-Units" // Sozusagen das "Kind" des Han-Fun-Geräts CSchaltbar = "an-/ausschaltbares Gerät/Steckdose/Lampe/Aktor" CDimmbar = "Gerät mit einstellbarem Dimm-, Höhen- bzw. Niveau-Level" CLampeMitFarbtemp = "Lampe mit einstellbarer Farbe/Farbtemperatur" CRollladen = "Rollladen(Blind) - hoch, runter, stop und level 0% bis 100 %" EvTastendruckKurz = "kurz" EvTastendruckLang = "lang" )
Beschreibung inkl. Fehler aus der Doku übernommen ;)
Variables ¶
This section is empty.
Functions ¶
func GetCapability ¶
func GetCapability[C Capability](d Device) (r C)
GetCapability returns the capability of the given type for the device.
func GetDeviceInfos ¶
func GetDeviceInfos(c *fritzbox.Client, identifier string, dest Capability) (err error)
GetDeviceInfos fetches the device information from the fritzbox and unmarshals the response into the given Capability. Note: For HanFun devices, this only fetches the parent device. HanFun units (child devices) are not populated. Use GetDeviceList to get HanFun devices with their units.
func GetDeviceInfosRaw ¶
GetDeviceInfosRaw fetches the device information from the fritzbox and returns the raw response converted to json.
Types ¶
type Alert ¶
type Alert struct {
State string `json:"state"`
LastChangeTime string `json:"lastalertchgtimestamp"`
}
func (Alert) GetLastAlertTimestamp ¶
GetLastAlertTimestamp converts the last change timestamp into go time struct
func (Alert) IsAlertActive ¶
IsAlertActive returns true if alert is active
type Button ¶
type Button struct {
ID string `json:"-id"`
Type string
Name string `json:"name"`
Identifier string `json:"-identifier"`
LastPressedTimeStamp string `json:"lastpressedtimestamp"`
}
Button is a part of the ButtonDevice capability A ButtonDevice can have multiple buttons
func (Button) GetLastPressTime ¶
GetLastPressTime converts the last-press-time string to a time-struct
type ButtonDevice ¶
type ButtonDevice struct {
CapName string
Buttons []Button
Batterylow string
Battery string
// contains filtered or unexported fields
}
ButtonDevice is the capability for a button
func (*ButtonDevice) Device ¶
func (b *ButtonDevice) Device() *Device
Device returns the device the capability belongs to
func (*ButtonDevice) Name ¶
func (b *ButtonDevice) Name() string
Name returns the name of the capability
func (*ButtonDevice) Reload ¶
func (b *ButtonDevice) Reload(c *fritzbox.Client) error
Reload reloads all client values
func (*ButtonDevice) String ¶
func (b *ButtonDevice) String() string
String returns a string representation of the capability
type Capabilities ¶
type Capabilities map[string]Capability
Capabilities is a map of the capabilities available for the device. They can be access using the Capability-Constants (starting with C, for example CHKR -> HeizungsKörperRegler, etc.) HasCapability can be used to check whether a device has a certain capability, without checking the map-keys.
func (Capabilities) String ¶
func (c Capabilities) String() string
String returns a string representation of the capabilities
type Capability ¶
type Capability interface {
Name() string
String() string
Device() *Device
// contains filtered or unexported methods
}
Capability is the interface for all capabilities. It is self-contained in that it has a reference to the device it belongs to.
type ColorControl ¶
type ColorControl struct {
}
func (ColorControl) String ¶
func (hfcc ColorControl) String() string
type Device ¶
type Device struct {
Identifier string
ID string
Fwversion string
Manufacturer string
Productname string
Txbusy string
Name string
Present string
Capabilities Capabilities
}
Device is the main type for aha-devices. It holds the values all devices have; all other properties are handled via the respective capabilities.
func (*Device) DECTGetName ¶
DECTGetName fetches device-Name from the fritzbox and updates internally stored value.
func (*Device) DECTIsSwitchPresent ¶
DECTIsSwitchPresent fetches the connection status from the fritzbox and updates the objects internal value. Note: According to the documentation, it may take multiple minutes for the status to update after a device disconnects.
func (*Device) DECTSetName ¶
DECTSetName updates device Name based on identifier and updates internal values if successful.
func (*Device) HasCapability ¶
HasCapability returns true, if device has given capability. Use capability-constants.
func (*Device) IsSwitchPresent ¶
IsSwitchPresent returns true if device is present.
type DeviceList ¶
type DeviceList struct {
Version string
Fwversion string
Devices []Device
// contains filtered or unexported fields
}
func GetDeviceList ¶
func GetDeviceList(c *fritzbox.Client) (*DeviceList, error)
GetDeviceList implements the getdevicelistinfos endpoint of the AHA-API and returns a DeviceList.
func GetDeviceListFilter ¶
func GetDeviceListFilter(c *fritzbox.Client, cap Capability) (dl *DeviceList, err error)
func (*DeviceList) String ¶
func (dl *DeviceList) String() string
String returns a string representation of the DeviceList.
type ETSIUnitInfo ¶
type ETSIUnitInfo struct {
ETSIDeviceID string `json:"etsideviceid"`
Interface string `json:"interfaces"`
UnitType string `json:"unittype"`
}
func (ETSIUnitInfo) GetInterfaceString ¶
func (e ETSIUnitInfo) GetInterfaceString() string
GetInterfaceString returns the units interface-type as a string (values taken from documentation)
func (ETSIUnitInfo) GetUnitString ¶
func (e ETSIUnitInfo) GetUnitString() string
GetUnitString returns the units type as a string (values taken from documentation)
func (ETSIUnitInfo) String ¶
func (e ETSIUnitInfo) String() string
type HFSuotaUpdate ¶
type HFSuotaUpdate struct {
}
func (HFSuotaUpdate) String ¶
func (hfsu HFSuotaUpdate) String() string
type HanFun ¶
type HanFun struct {
CapName string
Units Units // A single HanFun-Device can potentially consist of multiple units
// contains filtered or unexported fields
}
HanFun is the capability for a HanFun-Device HanFun is an open standard for smart home devices and is supported by the Fritz!Box
func (*HanFun) GetInterface ¶
GetInterface returns a pointer to the requested interface if present, nil if not. For example: [...].GetInterface(Alert{}).(Alert)
func (*HanFun) HasInterface ¶
HasInterface returns true, if the given HanFun-Interface is present in the current devices' units For example: [...].HasInterface(Alert{})
type Hkr ¶
type Hkr struct {
CapName string
Tsoll string `json:"tsoll"`
Absenk string `json:"absenk"`
Komfort string `json:"komfort"`
Lock string `json:"lock"` // Keylock (Tastensperre) configurated via Web-UI/API, activated automatically if summeractive or holdidayactive
Devicelock string `json:"devicelock"` // Same as lock, configurated manually on the device itself
Errorcode string `json:"errorcode"` // 0 = no error
Windowopenactiv string `json:"windowopenactiv"` // 1 if window currently detected as open. The typo is part of the official API.
Windowopenactiveendtime string `json:"windowopenactiveendtime"` // time in seconds until radiator turns back on
Boostactive string `json:"boostactive"` // same as window
Boostactiveendtime string `json:"boostactiveendtime"` // same as window
Batterylow string `json:"batterylow"` // 1 if battery low
Battery string `json:"battery"` // battery %
Nextchange struct {
Endperiod string `json:"endperiod"`
Tchange string `json:"tchange"`
} `json:"nextchange"`
Summeractive string `json:"summeractive"` // 1 if summer is currently active
Holidayactive string `json:"holidayactive"` // same as summer
// contains filtered or unexported fields
}
Hkr is the struct for HeizungsKörperRegler. Note: current temperature can be accessed via the temperature-capability.
func (*Hkr) DECTDeactivateBoost ¶
DECTDeactivateBoost turns boost off if currently enabled
func (*Hkr) DECTDeactivateWindowOpen ¶
func (*Hkr) DECTGetAbsenk ¶
DECTGetAbsenk is similar to DECTGetSoll
func (*Hkr) DECTGetAbsenkNumeric ¶
DECTGetAbsenkNumeric is similar to DECTGetSollNumeric
func (*Hkr) DECTGetKomfort ¶
DECTGetKomfort is similar to DECTGetSoll
func (*Hkr) DECTGetKomfortNumeric ¶
DECTGetKomfortNumeric is similar to DECTGetSollNumeric
func (*Hkr) DECTGetSoll ¶
DECTGetSoll sends an API-Request to get the current soll-temperature from the fritzbox/device itself. It will then update the current device locally and return the same output as GetSoll.
func (*Hkr) DECTGetSollNumeric ¶
DECTGetSollNumeric does the same as DECTGetSoll but returns the result like GetSollNumeric
func (*Hkr) DECTSetSoll ¶
DECTSetSoll sets the soll temperature to the given temperature (meaning 21.5 = 21.5 C). This method accepts float64/32, int and string (XX,X/ XX.X). Values with additional decimal places will be rounded to XX.0/XX.5 respectively. Only values from 8-28 are valid.
func (*Hkr) DECTSetSollMax ¶
DECTSetSollMax turns the soll-temperature on. Allegedly, it should use the last known temperature. However, for me, it just sets the radiator to MAX.
func (*Hkr) DECTSetSollOff ¶
DECTSetSollOff turns the soll-temperature off. The Hkr will show the snowflake in its display.
func (*Hkr) DECTSetWindowOpen ¶
func (*Hkr) GetAbsenkNumeric ¶
GetAbsenkNumeric is similar to GetSollNumeric
func (*Hkr) GetBoostEndtime ¶
GetBoostEndtime converts the endtime to a time-struct
func (*Hkr) GetErrorString ¶
GetErrorString returns the error-message for the respective error-code. Errorcode 0 means no error. The error-messages originate from the official docs.
func (*Hkr) GetKomfortNumeric ¶
GetKomfortNumeric is similar to GetSollNumeric
func (*Hkr) GetNextChangeTemperature ¶
GetNextChangeTemperature returns the temperature, that the next change will set it to (as string)
func (*Hkr) GetNextChangeTemperatureNumeric ¶
GetNextChangeTemperatureNumeric returns the temperature, that the next change will set it to (numeric)
func (*Hkr) GetNextchangeEndtime ¶
GetNextchangeEndtime returns the time of the next temperature-change
func (*Hkr) GetSoll ¶
GetSoll returns the same values as GetSollNumeric, but as a string. Instead of -1 and -2, it returns "OFF" or "MAX"
func (*Hkr) GetSollNumeric ¶
GetSollNumeric returns the current locally saved soll-temperature. It returns temperatures in Celsius from 8-28, as well as -1 (MAX) -2 (OFF).
func (*Hkr) GetWindowOpenEndtime ¶
func (*Hkr) IsBatteryLow ¶
IsBatteryLow returns true if the device reports battery low
func (*Hkr) IsBoostActive ¶
IsBoostActive returns true, if the boost is currently active
func (*Hkr) IsHolidayActive ¶
IsHolidayActive returns true, if holiday-mode is currently active
func (*Hkr) IsSummerActive ¶
IsSummerActive returns true, if summer-mode is currently active
func (*Hkr) IsWindowOpen ¶
type Interface ¶
type Interface interface {
String() string
// contains filtered or unexported methods
}
type LevelControl ¶
type LevelControl struct {
}
func (LevelControl) String ¶
func (hflc LevelControl) String() string
type OpenCloseConfig ¶
type OpenCloseConfig struct {
}
func (OpenCloseConfig) String ¶
func (hfocc OpenCloseConfig) String() string
type SimpleButton ¶
type SimpleButton struct {
}
func (SimpleButton) String ¶
func (hfsb SimpleButton) String() string
type Temperature ¶
type Temperature struct {
CapName string
Celsius string `json:"celsius"`
Offset string `json:"offset"`
// contains filtered or unexported fields
}
Temperature is the struct for the temperature capability.
func (*Temperature) DECTGetCelsiusNumeric ¶
func (t *Temperature) DECTGetCelsiusNumeric(c *fritzbox.Client) (float64, error)
DECTGetCelsiusNumeric is the same as GetCelsiusNumeric, but it will fetch the current value from the fritzbox and update the local state of the device before returning.
func (*Temperature) DECTGetDeviceStats ¶
func (t *Temperature) DECTGetDeviceStats(c *fritzbox.Client) (ts TemperatureStats, err error)
DECTGetDeviceStats returns the temperatures measured from the device in the last 24 hours
func (*Temperature) Device ¶
func (t *Temperature) Device() *Device
Device returns the device the capability belongs to
func (*Temperature) GetCelsiusNumeric ¶
func (t *Temperature) GetCelsiusNumeric() float64
GetCelsiusNumeric returns the temperature reading in float converted to the usual format (eg. 21.5)
func (*Temperature) GetOffsetNumeric ¶
func (t *Temperature) GetOffsetNumeric() float64
GetOffsetNumeric returns the temperature offset set for the device in float converted to the usual format (eg. 21.5)
func (*Temperature) Name ¶
func (t *Temperature) Name() string
Name returns the name of the capability
func (*Temperature) Reload ¶
func (t *Temperature) Reload(c *fritzbox.Client) error
Reload fetches the current device and updates the current capability
func (*Temperature) String ¶
func (t *Temperature) String() string
String returns a string representation of the capability
type TemperatureStats ¶
TemperatureStats is the struct for the temperature statistics. It contains the temperature values, often from the last 24 hours, the amount of values and the amount of seconds between measurements.
func (TemperatureStats) String ¶
func (ts TemperatureStats) String() string
String returns a string representation of the temperature statistics
type Unit ¶
type Unit struct {
// Saves all properties of the unit in raw json-messages.
// Does not include values already represented (values present in the device-struct, as well as etsi-unit-info)
// This allows access to functionality that may not yet be implemented.
RawProperties map[string]json.RawMessage
ETSIUnitInfo ETSIUnitInfo
Interface Interface
// contains filtered or unexported fields
}
Unit is a generic struct for a hanfun unit Hanfun is an open standard for smart home devices by the ULE Alliance that seems to be mostly dead in the water.
func (*Unit) GetRawProperties ¶
GetRawProperties returns the local interface-values as a string in json.
func (*Unit) IsUnitOfType ¶
IsUnitOfType returns true if the unit's interface is of the given type For example [...].IsUnitOfType(Alert{})
func (*Unit) Reload ¶
Reload fetches the device-information for this unit from the fritzbox and updates the structs' values