💾 Archived View for code.pfad.fr › fritzgox › aha captured on 2023-09-08 at 15:52:32. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-07-10)
-=-=-=-=-=-=-
import "code.pfad.fr/fritzgox/aha"
package aha allows to interact with the AVM Home Automation HTTP Interface (AHA), to control the connected smart devices.
const ThermostatTempOff = ThermostatTemp(0)
const ThermostatTempOn = ThermostatTemp(37)
const ThermostatTempUndefined = ThermostatTemp(-1)
func LoginV2(c *Client) error
LoginV2 asks the fritzbox for the PBKDF2 challenge on login.
func TrustOnFirstUse(c *Client) error
TrustOnFirstUse retrieves the certificate and marks it as trusted for subsequent calls.
type Client struct { URL url.URL Transport *http.Transport // if Username is empty, it will be auto-discovered Username string LoginV2 bool // contains filtered or unexported fields }
func NewClient(addr, password string, options ...Option) (*Client, error)
NewClient creates a new client to interact with the AHA interface.
func (c *Client) GetDeviceListInfos() (info *DeviceListInfos, err error)
GetDeviceListInfos returns the connected smart devices.
func (c *Client) SetThermostatBoost(identifier string, d time.Duration) error
SetThermostatBoost
func (c *Client) SetThermostatTargetTemp(identifier string, t ThermostatTemp) error
SetThermostatTargetTemp
type Device struct { Identifier string `xml:"identifier,attr"` ID string `xml:"id,attr"` Function DeviceFunction `xml:"functionbitmask,attr"` FirmwareVersion string `xml:"fwversion,attr"` Manufacturer string `xml:"manufacturer,attr"` Productname string `xml:"productname,attr"` Present bool `xml:"present"` Txbusy bool `xml:"txbusy"` Name string `xml:"name"` BatteryLow bool `xml:"batterylow"` BatteryLevel int `xml:"battery"` TemperatureSensor *TemperatureSensor `xml:"temperature"` Thermostat *Thermostat `xml:"hkr"` }
type DeviceFunction uint64
const ( DeviceHANFUN DeviceFunction = 1 << iota DeviceLight DeviceAlarm DeviceButton DeviceThermostat DeviceEnergieSensor DeviceTemperatureSensor DeviceSwitch )
type DeviceListInfos struct { XMLName xml.Name `xml:"devicelist"` Version string `xml:"version,attr"` FirmwareVersion string `xml:"fwversion,attr"` Devices []Device `xml:"device"` }
type Float32Tenth float32
func (f Float32Tenth) String() string
func (f *Float32Tenth) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
type Option func(*Client) error
func TrustCertificate(bs []byte) Option
TrustCertificate adds a PEM certificate to be trusted. Be aware that self-signed certificates may be re-created on reboot. You might prefer to use TrustOnFirstUse.
See also [https://en.avm.de/service/knowledge-base/dok/FRITZ-Box-7490/1523_Downloading-your-FRITZ-Box-s-certificate-and-importing-it-to-your-computer/]
func WithUsername(username string) Option
WithUsername disables the auto-discovery of the username.
type TemperatureSensor struct { Celsius Float32Tenth `xml:"celsius"` // adjusted temperature Offset Float32Tenth `xml:"offset"` // operated adjustment }
type Thermostat struct { // you should use the TemperatureSensor instead of ActualTemp ActualTemp ThermostatTemp `xml:"tist"` TargetTemp ThermostatTemp `xml:"tsoll"` LowTemp ThermostatTemp `xml:"absenk"` ComfortTemp ThermostatTemp `xml:"komfort"` APILocked bool `xml:"lock"` DeviceLocked bool `xml:"devicelock"` ErrorCode int `xml:"errorcode"` WindowOpened bool `xml:"windowopenactiv"` WindowOpenedUntil UnixSecond `xml:"windowopenactiveendtime"` BoostActive bool `xml:"boostactive"` BoostActiveUntil UnixSecond `xml:"boostactiveendtime"` BatteryLow bool `xml:"batterylow"` BatteryLevel int `xml:"battery"` NextChange struct { At UnixSecond `xml:"endperiod"` WishTemp ThermostatTemp `xml:"tchange"` } `xml:"nextchange"` SummerActive bool `xml:"summeractive"` HolidayActive bool `xml:"holidayactive"` }
type ThermostatTemp float32
func (t ThermostatTemp) String() string
func (t *ThermostatTemp) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
type UnixSecond struct{ time.Time }
func (u *UnixSecond) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
https://codeberg.org/pfad.fr/fritzgox
git clone
https://codeberg.org/pfad.fr/fritzgox.git git@codeberg.org:pfad.fr/fritzgox.git