Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
Identifier string `xml:"identifier,attr"` // A unique ID like AIN, MAC address, etc.
ID string `xml:"id,attr"` // Internal device ID of the FRITZ!Box.
Functionbitmask string `xml:"functionbitmask,attr"` // Bitmask determining the functionality of the device: bit 6: Comet DECT, HKR, "thermostat", bit 7: energy measurment device, bit 8: temperature sensor, bit 9: switch, bit 10: AVM DECT repeater
Fwversion string `xml:"fwversion,attr"` // Firmware version of the device.
Manufacturer string `xml:"manufacturer,attr"` // Manufacturer of the device, usually set to "AVM".
Productname string `xml:"productname,attr"` // Name of the product, empty for unknown or undefined devices.
Present int `xml:"present"` // Device connected (1) or not (0).
Name string `xml:"name"` // The name of the device. Can be assigned in the web gui of the FRITZ!Box.
Switch Switch `xml:"switch"` // Only filled with sensible data for switch devices.
Powermeter Powermeter `xml:"powermeter"` // Only filled with sensible data for devices with an energy actuator.
Temperature Temperature `xml:"temperature"` // Only filled with sensible data for devices with a temperature sensor.
Thermostat Thermostat `xml:"hkr"` // Thermostat data, only filled with sensible data for HKR devices.
}
Device models a smart home device. This corresponds to the single entries of the xml that the FRITZ!Box returns. codebeat:disable[TOO_MANY_IVARS]
type Devicelist ¶
type Devicelist struct {
Devices []Device `xml:"device"`
}
Devicelist wraps a list of devices. This corresponds to the outer layer of the xml that the FRITZ!Box returns.
type Fritz ¶
type Fritz interface {
ListDevices() (*Devicelist, error)
ListLanDevices() (*LanDevices, error)
ListLogs() (*MessageLog, error)
InternetStats() (*TrafficMonitoringData, error)
SwitchOn(names ...string) error
SwitchOff(names ...string) error
Toggle(names ...string) error
Temperature(value float64, names ...string) error
}
Fritz API definition, guided by https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AHA-HTTP-Interface.pdf.
type LanDevices ¶
type LanDevices struct {
Network []NetworkElement `json:"network"`
}
LanDevices is the top-level wrapper for the FRITZ!Box answer upon a query for lan devices.
type MessageLog ¶
type MessageLog struct {
Messages []Message `json:"mq_log"`
}
MessageLog is the top-level wrapper for the FRITZ!Box answer upon a query for log events.
type NetworkElement ¶
type NetworkElement struct {
Name string `json:"name"`
IP string `json:"ip"`
Mac string `json:"mac"`
UID string `json:"UID"`
Dhcp string `json:"dhcp"`
Wlan string `json:"wlan"`
Ethernet string `json:"ethernet"`
Active string `json:"active"`
StaticDhcp string `json:"static_dhcp"`
ManuName string `json:"manu_name"`
Wakeup string `json:"wakeup"`
Deleteable string `json:"deleteable"`
Source string `json:"source"`
Online string `json:"online"`
Speed string `json:"speed"`
WlanUIDs string `json:"wlan_UIDs"`
AutoWakeup string `json:"auto_wakeup"`
Guest string `json:"guest"`
URL string `json:"url"`
WlanStationType string `json:"wlan_station_type"`
EthernetPort string `json:"ethernet_port"`
WlanShowInMonitor string `json:"wlan_show_in_monitor"`
Plc string `json:"plc"`
ParentalControlAbuse string `json:"parental_control_abuse"`
}
NetworkElement corresponds to a single entry in LanDevices. codebeat:disable[TOO_MANY_IVARS]
type NextChange ¶
type NextChange struct {
TimeStamp string `xml:"endperiod"` // Timestamp (epoch time) when the next temperature switch is scheduled.
Goal string `xml:"tchange"` // The temperature to switch to. Same unit convention as in Thermostat.Measured.
}
NextChange corresponds to the next HKR switch event.
type Powermeter ¶
type Powermeter struct {
Power string `xml:"power"` // Current power, refreshed approx every 2 minutes
Energy string `xml:"energy"` // Absolute energy consuption since the device started operating
}
Powermeter models a power measurement
type Switch ¶
type Switch struct {
State string `xml:"state"` // Switch state 1/0 on/off (empty if not known or if there was an error).
Mode string `xml:"mode"` // Switch mode manual/automatic (empty if not known or if there was an error).
Lock string `xml:"lock"` // Switch locked (box defined)? 1/0 (empty if not known or if there was an error).
DeviceLock string `xml:"devicelock"` // Switch locked (device defined)? 1/0 (empty if not known or if there was an error).
}
Switch models the state of a switch. codebeat:disable[TOO_MANY_IVARS]
type Temperature ¶
type Temperature struct {
Celsius string `xml:"celsius"` // Temperature measured at the device sensor in units of 0.1 °C. Negative and positive values are possible.
Offset string `xml:"offset"` // Temperature offset (set by the user) in units of 0.1 °C. Negative and positive values are possible.
}
Temperature models a temperature measurement.
type Thermostat ¶
type Thermostat struct {
Measured string `xml:"tist"` // Measured temperature.
Goal string `xml:"tsoll"` // Desired temperature, user controlled.
Saving string `xml:"absenk"` // Energy saving temperature.
Comfort string `xml:"komfort"` // Comfortable temperature.
NextChange NextChange `xml:"nextchange"` // The next scheduled temperature change.
Lock string `xml:"lock"` // Switch locked (box defined)? 1/0 (empty if not known or if there was an error).
DeviceLock string `xml:"devicelock"` // Switch locked (device defined)? 1/0 (empty if not known or if there was an error).
ErrorCode string `xml:"errorcode"` // Error codes: 0 = OK, 1 = ... see https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AHA-HTTP-Interface.pdf.
BatteryLow string `xml:"batterylow"` // "0" if the battery is OK, "1" if it is running low on capacity.
}
Thermostat models the "HKR" device. codebeat:disable[TOO_MANY_IVARS]
type TrafficMonitoringData ¶
type TrafficMonitoringData struct {
DownstreamInternet []float64 `json:"ds_current_bps"`
DownStreamMedia []float64 `json:"mc_current_bps"`
UpstreamRealtime []float64 `json:"prio_realtime_bps"`
UpstreamHighPriority []float64 `json:"prio_high_bps"`
UpstreamDefaultPriority []float64 `json:"prio_default_bps"`
UpstreamLowPriority []float64 `json:"prio_low_bps"`
}
TrafficMonitoringData holds the data for the up- and downstream traffic reported by the FRITZ!Box. codebeat:disable[TOO_MANY_IVARS]
func (TrafficMonitoringData) BitsPerSecond ¶
func (d TrafficMonitoringData) BitsPerSecond() TrafficMonitoringData
BitsPerSecond returns a TrafficMonitoringData with metrics in units of bits/second.
func (TrafficMonitoringData) KiloBitsPerSecond ¶
func (d TrafficMonitoringData) KiloBitsPerSecond() TrafficMonitoringData
KiloBitsPerSecond returns a TrafficMonitoringData with metrics in units of kbits/second.