Documentation
¶
Index ¶
- Constants
- Variables
- func GetCapability[C Capability](d SmarthomeDevice) (r C)
- type Button
- type ButtonPress
- type Capabilities
- type Capability
- type Client
- func (c *Client) AddMACs(cl *DeviceList) (err error)
- func (c *Client) AddProfiles(cl *DeviceList)
- func (c *Client) Close()
- func (c *Client) Copy() *Client
- func (c *Client) CustomRequest(method string, urlPath string, data url.Values) (statusCode int, body string, err error)
- func (c *Client) GetAvailableProfiles() (profiles map[string]Profile, err error)
- func (c *Client) GetCLientList() (clients DeviceList, err error)
- func (c *Client) GetDeviceInfos(devIdentifier string, dest interface{}) (err error)
- func (c *Client) GetEventLog() (logEvents []LogMessage, err error)
- func (c *Client) GetEventLogUntil(id int) (logEvents []LogMessage, err error)
- func (c *Client) GetProfileUIDFromDevice(deviceUID string) (profileUID string, err error)
- func (c *Client) GetSmarthomeDevices() (dl *SHDevicelist, err error)
- func (c *Client) GetSmarthomeDevicesFilter(requiredCapabilities []string) (dl *SHDevicelist, err error)
- func (c *Client) GetTrafficStats() (ts TrafficStatistics, err error)
- func (c *Client) Initialize() error
- func (c *Client) IsInitialized() bool
- func (c *Client) SID() string
- func (c *Client) SetCustomHTTPClient(client *http.Client)
- func (c *Client) SetIP(deviceUID string, ip string, static bool) (err error)
- func (c *Client) SetName(deviceUID string, newName string) (err error)
- func (c *Client) SetProfileForDevice(deviceUID string, profileUID string) (err error)
- func (c *Client) String() string
- type Device
- type DeviceList
- type ETSIUnitInfo
- type HFAlert
- type HFColorControl
- type HFInterface
- type HFKeepAlive
- type HFLevelControl
- type HFOnOff
- type HFOpenClose
- type HFOpenCloseConfig
- type HFSimpleButton
- type HFSuotaUpdate
- type HanFun
- type HanFunUnit
- func (h *HanFunUnit) Device() *SmarthomeDevice
- func (h *HanFunUnit) GetRawProperties() (s map[string]string, err error)
- func (h *HanFunUnit) IsUnitOfType(t interface{}) bool
- func (h *HanFunUnit) Reload(c *Client) error
- func (h *HanFunUnit) String() string
- func (h *HanFunUnit) UnmarshalProperty(propertyKey string, dest interface{}) error
- type HanFunUnits
- type Hkr
- func (h *Hkr) DECTDeactivateBoost(c *Client) (err error)
- func (h *Hkr) DECTDeactivateWindowOpen(c *Client) (err error)
- func (h *Hkr) DECTGetAbsenk(c *Client) (string, error)
- func (h *Hkr) DECTGetAbsenkNumeric(c *Client) (float64, error)
- func (h *Hkr) DECTGetKomfort(c *Client) (string, error)
- func (h *Hkr) DECTGetKomfortNumeric(c *Client) (float64, error)
- func (h *Hkr) DECTGetSoll(c *Client) (r string, err error)
- func (h *Hkr) DECTGetSollNumeric(c *Client) (float64, error)
- func (h *Hkr) DECTSetSoll(c *Client, sollTemp interface{}) error
- func (h *Hkr) DECTSetSollMax(c *Client) error
- func (h *Hkr) DECTSetSollOff(c *Client) error
- func (h *Hkr) DECTSetWindowOpen(c *Client, d time.Duration) (tm time.Time, err error)
- func (h *Hkr) Device() *SmarthomeDevice
- func (h *Hkr) FetchSummerTime(c *Client) (err error)
- func (h *Hkr) GetAbsenk() (r string)
- func (h *Hkr) GetAbsenkNumeric() float64
- func (h *Hkr) GetBoostEndtime() (t 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() (t time.Time)
- func (h *Hkr) GetSoll() (r string)
- func (h *Hkr) GetSollNumeric() float64
- func (h *Hkr) GetWindowOpenEndtime() (t 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) PyaDisableAllHolidays(pya *PyAdapter) (err error)
- func (h *Hkr) PyaDisableCurrentHoliday(pya *PyAdapter) (err error)
- func (h *Hkr) PyaDisableHoliday(pya *PyAdapter, hol Holiday) (err error)
- func (h *Hkr) PyaDisableSummerTime(pya *PyAdapter) (err error)
- func (h *Hkr) PyaFetchInformation(pya *PyAdapter) (err error)
- func (h *Hkr) PyaSetHolidays(pya *PyAdapter, holidays Holidays) (err error)
- func (h *Hkr) PyaSetSummerTime(pya *PyAdapter, st SummerTime) (err error)
- func (h *Hkr) PyaSetZeitschaltung(pya *PyAdapter, z Zeitschaltung) (err error)
- func (h *Hkr) Reload(c *Client) error
- func (h *Hkr) SetBoost(c *Client, d time.Duration) (tm time.Time, err error)
- func (h *Hkr) String() string
- type HkrPyaInformation
- type Holiday
- type Holidays
- type LogMessage
- type Profile
- type PyAdapter
- type SHDevicelist
- type SlotTemplate
- type SmarthomeDevice
- func (d *SmarthomeDevice) DECTGetName(c *Client) (string, error)
- func (d *SmarthomeDevice) DECTIsSwitchPrsent(c *Client) (bool, error)
- func (d *SmarthomeDevice) DECTSetName(c *Client, name string) error
- func (d *SmarthomeDevice) HasCapability(cap string) bool
- func (d *SmarthomeDevice) IsSwitchPrsent() bool
- func (d *SmarthomeDevice) Reload(cl *Client) error
- func (d *SmarthomeDevice) String() string
- type SummerTime
- type Tag
- type Temperature
- func (t *Temperature) DECTGetCelsiusNumeric(c *Client) (float64, error)
- func (t *Temperature) DECTGetDeviceStats(c *Client) (ts TemperatureStats, err error)
- func (t *Temperature) Device() *SmarthomeDevice
- func (t *Temperature) GetCelsiusNumeric() float64
- func (t *Temperature) GetOffsetNumeric() float64
- func (t *Temperature) Name() string
- func (t *Temperature) PyaSetOffset(pya *PyAdapter, offset float64) (err error)
- func (t *Temperature) Reload(c *Client) error
- func (t *Temperature) String() string
- type TemperatureStats
- type TrafficForDuration
- type TrafficStatistics
- type ZeitSlot
- type Zeitschaltung
- func (z *Zeitschaltung) SlotFromStrings(weekday time.Weekday, start string, end string) (err error)
- func (z *Zeitschaltung) SlotFromTemplate(data SlotTemplate) (err error)
- func (z *Zeitschaltung) SlotsFromTemplates(data []SlotTemplate) (err error)
- func (z Zeitschaltung) String() string
- func (z *Zeitschaltung) ToValues() map[string]string
- func (z *Zeitschaltung) Validate() error
Constants ¶
const ( // DefaultSid is an invalid session in order to perform and // identify logouts. DefaultSid = "0000000000000000" // DefaultExpires is the amount of time of inactivity before // the FRITZ!Box automatically closes a session. DefaultExpires = 10 * time.Minute )
const ( RefreshSession = true Timeout = 10 * time.Second RefreshSessionDelay = 5 * time.Minute )
const ( CHanfun = "HAN-FUN Gerät" CLicht = "Licht/Lampe" CAlarm = "Alarm-Sensor" CButton = "AVM-Button" 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 = "lang" EvTastendruckLang = "kurz" )
Beschreibung inkl. Fehler aus der Doku übernommen ;)
Variables ¶
var ( // ErrInvalidCred is the error returned by auth when // login attempt is not successful. ErrInvalidCred = errors.New("fritzbox: invalid credentials") // ErrExpiredSess means that Client was too long inactive. ErrExpiredSess = errors.New("fritzbox: session expired") )
var MaskTranslStr = []string{CHanfun, "", CLicht, "", CAlarm, CButton, CHKR, CEnergieMesser, CTempSensor, CSteckdose, CRepeater, CMikrofon, "", CHanfunUnit, "", CSchaltbar, CDimmbar, CLampeMitFarbtemp, CRollladen}
Functions ¶
func GetCapability ¶
func GetCapability[C Capability](d SmarthomeDevice) (r C)
Types ¶
type Button ¶
type Button struct { CapName string Buttons []ButtonPress Batterylow string Battery string // contains filtered or unexported fields }
func (*Button) Device ¶
func (b *Button) Device() *SmarthomeDevice
type ButtonPress ¶
type ButtonPress struct { ID string `json:"-id"` Type string Name string `json:"name"` Identifier string `json:"-identifier"` LastPressedTimeStamp string `json:"lastpressedtimestamp"` }
func (ButtonPress) GetLastPressTime ¶
func (bp ButtonPress) GetLastPressTime() (t time.Time)
GetLastPressTime converts the last-press-time string to a time-struct
func (ButtonPress) String ¶
func (bp ButtonPress) String() string
type Capabilities ¶
type Capabilities map[string]Capability
Capabilities is a map of all available capabilities. 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
type Capability ¶
type Capability interface { Name() string String() string Device() *SmarthomeDevice // contains filtered or unexported methods }
type Client ¶
type Client struct { BaseUrl string Username string Password string // contains filtered or unexported fields }
func (*Client) AddMACs ¶
func (c *Client) AddMACs(cl *DeviceList) (err error)
func (*Client) AddProfiles ¶
func (c *Client) AddProfiles(cl *DeviceList)
AddProfiles gets the profile for every device and adds it into an already existing Client-list. Warning: This will send one request per device, meaning it will take multiple seconds to complete. Alternatively, call GetProfileUIDFromDevice only for the devices you need
func (*Client) CustomRequest ¶
func (c *Client) CustomRequest(method string, urlPath string, data url.Values) (statusCode int, body string, err error)
CustomRequest allows one to send a custom request. The method can be http.MethodPost or http.MethodGet. The urlPath should always only be the path (for example "data.lua"), get-queries are set via the data-field. See examples.
func (*Client) GetAvailableProfiles ¶
GetAvailableProfiles returns a map, where the Profile-Object is accessible via the profile-UID
func (*Client) GetCLientList ¶
func (c *Client) GetCLientList() (clients DeviceList, err error)
func (*Client) GetDeviceInfos ¶
func (*Client) GetEventLog ¶
func (c *Client) GetEventLog() (logEvents []LogMessage, err error)
func (*Client) GetEventLogUntil ¶
func (c *Client) GetEventLogUntil(id int) (logEvents []LogMessage, err error)
GetEventLogUntil returns all log messages newer than the given id.
func (*Client) GetProfileUIDFromDevice ¶
GetProfileUIDFromDevice returns the UID of the profile that is assigned to the given device The return can be empty, for example for the fritzbox itself. This should be accounted for.
func (*Client) GetSmarthomeDevices ¶
func (c *Client) GetSmarthomeDevices() (dl *SHDevicelist, err error)
func (*Client) GetSmarthomeDevicesFilter ¶
func (c *Client) GetSmarthomeDevicesFilter(requiredCapabilities []string) (dl *SHDevicelist, err error)
func (*Client) GetTrafficStats ¶
func (c *Client) GetTrafficStats() (ts TrafficStatistics, err error)
func (*Client) Initialize ¶
func (*Client) IsInitialized ¶
func (*Client) SetCustomHTTPClient ¶
func (*Client) SetIP ¶
SetIP sets the IP address of a device like you would using the interface. Static indicated whether the given IP should be static and should always be true when changing the IP. Having it set to false is the same as un-ticking the checkbox in the edit dialog.
func (*Client) SetName ¶
SetName sets the name of a device. The name may only contain letters (a-z, A-Z), numerals (0-9), and hyphens (-).
func (*Client) SetProfileForDevice ¶
SetProfileForDevice (mainly untested) sets the profile from the profileUID to the device with the given deviceUID. Assigning the guest-Profile does not work when guest-wifi is off (makes sense), otherwise it might work
type Device ¶
type Device struct { UID string `json:"UID"` Parent string `json:"parent"` Category string `json:"category"` Profile Profile OwnClientDevice bool `json:"own_client_device"` Dist int `json:"dist"` Switch bool `json:"switch"` Devtype string `json:"devtype"` MAC string `json:"mac"` // Note: AddMACs must be called for this field to not be empty Ownentry bool `json:"ownentry"` Stateinfo struct { GuestOwe bool `json:"guest_owe"` Active bool `json:"active"` Meshable bool `json:"meshable"` Guest bool `json:"guest"` Online bool `json:"online"` Blocked bool `json:"blocked"` Realtime bool `json:"realtime"` NotalloWed bool `json:"notallowed"` InternetBlocked bool `json:"internetBlocked"` } `json:"stateinfo"` Conn string `json:"conn"` Master bool `json:"master"` Detailinfo struct { Edit struct { Pid string `json:"pid"` Params struct { Dev string `json:"dev"` BackToPage string `json:"back_to_page"` } `json:"params"` } `json:"edit"` Portrelease bool `json:"portrelease"` } `json:"detailinfo"` Updateinfo struct { State string `json:"state"` } `json:"updateinfo"` Gateway bool `json:"gateway"` Nameinfo struct { Name string `json:"name"` } `json:"nameinfo"` Children []interface{} `json:"children"` Conninfo struct { Kind string `json:"kind"` Speed string `json:"speed"` Bandinfo []struct { Band int `json:"band"` SpeedTx int `json:"speed_tx"` SpeedRx int `json:"speed_rx"` Speed string `json:"speed"` Desc string `json:"desc"` } `json:"bandinfo"` Usedbands int `json:"usedbands"` Desc string `json:"desc"` } `json:"conninfo"` Ipinfo string `json:"ipinfo"` }
type 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 HFAlert ¶
type HFAlert struct { State string `json:"state"` LastChangeTime string `json:"lastalertchgtimestamp"` }
func (HFAlert) GetLastAlertTimestamp ¶
GetLastAlertTimestamp converts the last change timestamp into go time struct
func (HFAlert) IsAlertActive ¶
IsAlertActive returns true is alert is active
type HFColorControl ¶
type HFColorControl struct { }
func (HFColorControl) String ¶
func (hfcc HFColorControl) String() string
type HFInterface ¶
type HFInterface interface { String() string // contains filtered or unexported methods }
type HFKeepAlive ¶
type HFKeepAlive struct { }
func (HFKeepAlive) String ¶
func (hfka HFKeepAlive) String() string
type HFLevelControl ¶
type HFLevelControl struct { }
func (HFLevelControl) String ¶
func (hflc HFLevelControl) String() string
type HFOpenClose ¶
type HFOpenClose struct { }
func (HFOpenClose) String ¶
func (hfoc HFOpenClose) String() string
type HFOpenCloseConfig ¶
type HFOpenCloseConfig struct { }
func (HFOpenCloseConfig) String ¶
func (hfocc HFOpenCloseConfig) String() string
type HFSimpleButton ¶
type HFSimpleButton struct { }
func (HFSimpleButton) String ¶
func (hfsb HFSimpleButton) String() string
type HFSuotaUpdate ¶
type HFSuotaUpdate struct { }
func (HFSuotaUpdate) String ¶
func (hfsu HFSuotaUpdate) String() string
type HanFun ¶
type HanFun struct { CapName string Units HanFunUnits // A single HanFun-Device can potentially consist of multiple units // contains filtered or unexported fields }
func (*HanFun) Device ¶
func (hf *HanFun) Device() *SmarthomeDevice
func (*HanFun) GetInterface ¶
func (hf *HanFun) GetInterface(i interface{}) interface{}
GetInterface returns a pointer to the requested interface if present, nil if not. For example: [...].GetInterface(HFAlert{}).(HFAlert)
func (*HanFun) HasInterface ¶
HasInterface returns true, if the given HanFun-Interface is present in the current devices' units For example: [...].HasInterface(HFAlert{})
type HanFunUnit ¶
type HanFunUnit struct { RawProperties map[string]json.RawMessage // 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) ETSIUnitInfo ETSIUnitInfo Interface HFInterface // contains filtered or unexported fields }
func (*HanFunUnit) Device ¶
func (h *HanFunUnit) Device() *SmarthomeDevice
func (*HanFunUnit) GetRawProperties ¶
func (h *HanFunUnit) GetRawProperties() (s map[string]string, err error)
GetRawProperties returns the local interface-values as a string in json.
func (*HanFunUnit) IsUnitOfType ¶
func (h *HanFunUnit) IsUnitOfType(t interface{}) bool
IsUnitOfType returns true if the units' interface is of the given type For example [...].IsUnitOfType(HFAlert{})
func (*HanFunUnit) Reload ¶
func (h *HanFunUnit) Reload(c *Client) error
Reload fetches the device-information for this unit from the fritzbox and updates the structs' values
func (*HanFunUnit) String ¶
func (h *HanFunUnit) String() string
func (*HanFunUnit) UnmarshalProperty ¶
func (h *HanFunUnit) UnmarshalProperty(propertyKey string, dest interface{}) error
UnmarshalProperty unmarshals a property into the given interface
type HanFunUnits ¶
type HanFunUnits []*HanFunUnit
func (HanFunUnits) String ¶
func (hfus HanFunUnits) String() string
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 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 // HkrUnstableInformation contains Information, that is not usually accessible via the API. // Empty by default. Call PyaFetchInformation on the Hkr to fill it using the PyAdapter. // SummerTime can be also fetched using FetchSummerTime (without PYA) or PyaFetchSummertime (with PYA) HkrUnstableInformation HkrPyaInformation `json:"-"` // 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) Device ¶
func (h *Hkr) Device() *SmarthomeDevice
func (*Hkr) FetchSummerTime ¶
FetchSummerTime fetches the SummerTime-Frame for the HKR. It does not return anything, but instead fills the SummerTimeFrame-Field for the Hkr. If Pya is already initialized and logged in, using the Function PyaFetchSummertime is generally preferable.
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 No API-requests are made. Instead, all this does is convert the local value. Only functions with the DECT-Prefix communicate with the fritzbox.
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 ¶
func (*Hkr) PyaDisableAllHolidays ¶
func (*Hkr) PyaDisableCurrentHoliday ¶
PyaDisableCurrentHoliday disables the currently active Holiday using the PYA. If no Holiday is currently active, an error is returned.
func (*Hkr) PyaDisableHoliday ¶
PyaDisableHoliday disables the given Holiday using the PYA.
func (*Hkr) PyaDisableSummerTime ¶
PyaDisableSummerTime disables the SummerTime for the HKR.
func (*Hkr) PyaFetchInformation ¶
PyaFetchInformation fetches the SummerTimeFrame, the Zeitschaltung and the Holiday-Fields for HkrUnstableInformation. It does not return anything, but instead fills the HkrUnstableInformation-Field of the Hkr. There is only one Method to fill all three fields at once, as they are all fetched using the same initial request, thus making fetching all three of them separately much slower than just fetching them together. This Method is preferred over FetchSummerTime, as it does not require parsing the HTML-Response, thus (hopefully) making it more stable.
func (*Hkr) PyaSetHolidays ¶
PyaSetHolidays sets the Holidays for the HKR. Please see the Documentation for Holidays.
func (*Hkr) PyaSetSummerTime ¶
func (h *Hkr) PyaSetSummerTime(pya *PyAdapter, st SummerTime) (err error)
PyaSetSummerTime sets the SummerTime for the HKR. Only Day/Month of the Time-Values is required. The Helper-Method DateFromMD can be used to create the Time-Values.
func (*Hkr) PyaSetZeitschaltung ¶
func (h *Hkr) PyaSetZeitschaltung(pya *PyAdapter, z Zeitschaltung) (err error)
PyaSetZeitschaltung sets the Zeitschaltung for the HKR. Please see the Documentation for Zeitschaltung.
type HkrPyaInformation ¶
type HkrPyaInformation struct { SummerTime SummerTime Zeitschaltung Zeitschaltung Holidays Holidays }
HkrPyaInformation contains Information, that is not usually accessible via the API. Empty by default. Call PyaFetchInformation on the Hkr to fill it using the PyAdapter.
type Holiday ¶
type Holiday struct { ID int StartDay int StartMonth int StartHour int EndDay int EndMonth int EndHour int Enabled int }
Holiday is a single Holiday. It consists of a Start and End time, as well as an ID. For creating Holidays, use Holidays.AddHoliday.
func (*Holiday) GetEndDate ¶
GetEndDate converts the End-Values to a time.Time-Struct
func (*Holiday) GetStartDate ¶
GetStartDate converts the Start-Values to a time.Time-Struct
type Holidays ¶
Holidays is the Struct that is used to set Holidays for the HKR. The FritzBox allows a maximum of 4 Holidays.
func (*Holidays) AddHoliday ¶
AddHoliday adds a Holiday to the Holidays-Struct. Helper Method. No Request is sent. It returns an error if the maximum amount of Holidays is reached. Holidays added via this Method are enabled by default. There can be 0-4 Holidays total.
func (*Holidays) ToValues ¶
ToValues converts the Holidays to a map[string]string, which is the Format the FritzBox expects.
func (*Holidays) Validate ¶
func (h *Holidays) Validate(stf SummerTime) error
Validate checks if the Holidays are valid. It returns an error if the Holidays are invalid. Holidays are invalid, if any Holidays overlap, or if the Start is after the End-Date of the same Holiday.
type LogMessage ¶
type PyAdapter ¶
type PyAdapter struct { Client *Client Debug bool BrowserDebug bool // DriverArgs are the arguments that are passed to the chromedriver using options.add_argument() DriverArgs []string // contains filtered or unexported fields }
PyAdapter is a struct that controls the Python Adapter to Selenium. The Python Implementation of Selenium Wire is used to fetch the Arguments that are required for specific Requests.
Starting a Python-Adapter will result in a Chromedriver being started in the Background and a Session for the Fritz!Box being created. This Session is automatically refreshed periodically, unless RefreshSession is set to false. For more Information, see the Readme (todo)
func (*PyAdapter) GetArgsHKR ¶
func (*PyAdapter) StartAdapter ¶
StartAdapter starts the Python Script, logs in and starts the sessionRefresher if RefreshSession is set to true.
func (*PyAdapter) StopPyAdapter ¶
type SHDevicelist ¶
type SHDevicelist struct { Version string Fwversion string Devices []SmarthomeDevice // contains filtered or unexported fields }
func (*SHDevicelist) Reload ¶
func (dl *SHDevicelist) Reload(c *Client) error
func (*SHDevicelist) String ¶
func (dl *SHDevicelist) String() string
type SlotTemplate ¶
SlotTemplate is a helper for creating Slots. It consists of a Weekday, a Start and an End time. To create a Slot for Monday, from 11 AM - 3 PM (11-15:00), use SlotTemplate{time.Monday, "11:00", "15:00"} The Slots created this Way can then be added to the Zeitschaltung using Zeitschaltung.SlotFromTemplate or Zeitschaltung.SlotsFromTemplates
type SmarthomeDevice ¶
type SmarthomeDevice struct { Identifier string ID string Fwversion string Manufacturer string Productname string Txbusy string Name string Present string Capabilities Capabilities }
SmarthomeDevice is the main type for fritz-smarthome-devices. It only holds values all devices have, all other properties are handled in their respective capabilities.
func (*SmarthomeDevice) DECTGetName ¶
func (d *SmarthomeDevice) DECTGetName(c *Client) (string, error)
DECTGetName fetches device-Name from the fritzbox and updates internally stored value.
func (*SmarthomeDevice) DECTIsSwitchPrsent ¶
func (d *SmarthomeDevice) DECTIsSwitchPrsent(c *Client) (bool, error)
DECTIsSwitchPrsent fetches current status from the fritzbox and updates internally stored value. Note: According to the documentation, it may take multiple minutes for the status to update after a device disconnected.
func (*SmarthomeDevice) DECTSetName ¶
func (d *SmarthomeDevice) DECTSetName(c *Client, name string) error
DECTSetName updates device Name based on identifier and updates internal values if successful
func (*SmarthomeDevice) HasCapability ¶
func (d *SmarthomeDevice) HasCapability(cap string) bool
HasCapability returns true, if device has given capability. Use capability-constants.
func (*SmarthomeDevice) IsSwitchPrsent ¶
func (d *SmarthomeDevice) IsSwitchPrsent() bool
IsSwitchPrsent returns true if device is present. Uses locally stored value.
func (*SmarthomeDevice) Reload ¶
func (d *SmarthomeDevice) Reload(cl *Client) error
func (*SmarthomeDevice) String ¶
func (d *SmarthomeDevice) String() string
type SummerTime ¶
type SummerTime struct { IsEnabled bool StartDay string StartMonth string EndDay string EndMonth string }
SummerTime is the field that holds Information about the Start- and End-Date of the SummerTime-Frame set for the HKR. The struct only holds the raw Information as Strings. To get the actual Dates, use GetStartDate and GetEndDate. To fetch the Data, use FetchSummerTime (without PYA) or PyaFetchSummertime (with PYA).
func (*SummerTime) FromDates ¶
func (stf *SummerTime) FromDates(start time.Time, end time.Time)
FromDates allows the Creation of a SummerTime struct using two dates
func (*SummerTime) GetEndDate ¶
func (stf *SummerTime) GetEndDate() time.Time
GetEndDate returns a formatted time.Time-Struct for the End of the SummerTime-Frame
func (*SummerTime) GetStartDate ¶
func (stf *SummerTime) GetStartDate() time.Time
GetStartDate returns a formatted time.Time-Struct for the Start of the SummerTime-Frame
func (*SummerTime) IsEmpty ¶
func (stf *SummerTime) IsEmpty() bool
IsEmpty returns true, if the SummerTime is empty or not enabled.
func (SummerTime) String ¶
func (stf SummerTime) String() string
func (*SummerTime) Validate ¶
func (stf *SummerTime) Validate(holidays Holidays) (err error)
Validate checks, if the SummerTime is valid. For this, it needs the Holidays, as SummerTime and Holidays cannot overlap. Validation happens automatically on the call of PyaSetSummerTime, with no additional time cost for fetching the holidays.
type Temperature ¶
type Temperature struct { CapName string Celsius string `json:"celsius"` Offset string `json:"offset"` // contains filtered or unexported fields }
func (*Temperature) DECTGetCelsiusNumeric ¶
func (t *Temperature) DECTGetCelsiusNumeric(c *Client) (float64, error)
DECTGetCelsiusNumeric is the same as GetIstNumeric, 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 *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() *SmarthomeDevice
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
func (*Temperature) PyaSetOffset ¶
func (t *Temperature) PyaSetOffset(pya *PyAdapter, offset float64) (err error)
PyaSetOffset sets the temperature offset for the device using the PyAdapter
func (*Temperature) Reload ¶
func (t *Temperature) Reload(c *Client) error
Reload fetches the current device and updates the current capability
func (*Temperature) String ¶
func (t *Temperature) String() string
type TemperatureStats ¶
func (TemperatureStats) String ¶
func (ts TemperatureStats) String() string
type TrafficForDuration ¶
type TrafficForDuration struct { BytesSentHigh string `json:"BytesSentHigh"` BytesSentLow string `json:"BytesSentLow"` BytesReceivedHigh string `json:"BytesReceivedHigh"` BytesReceivedLow string `json:"BytesReceivedLow"` MBSent int MBReceived int }
The TrafficForDuration struct contains network statistics. Only MBSent and MBReceived are real values. The rest are raw values returned by the backend.
func (*TrafficForDuration) String ¶
func (tfd *TrafficForDuration) String() string
type TrafficStatistics ¶
type TrafficStatistics struct { LastMonth TrafficForDuration `json:"LastMonth"` ThisWeek TrafficForDuration `json:"ThisWeek"` Today TrafficForDuration `json:"Today"` Yesterday TrafficForDuration `json:"Yesterday"` ThisMonth TrafficForDuration `json:"ThisMonth"` }
func (*TrafficStatistics) String ¶
func (ts *TrafficStatistics) String() string
type Zeitschaltung ¶
type Zeitschaltung struct {
Tage []Tag
}
Zeitschaltung is a struct that holds the Values for the HKR-Timer in the Format that is expected by the Fritzbox. It consists of all days of the week, which in turn consist of ZeitSlots.
func (*Zeitschaltung) SlotFromStrings ¶
SlotFromStrings creates a Slot from a Weekday and two Strings (Start and End time) and adds it to the Zeitschaltung.
func (*Zeitschaltung) SlotFromTemplate ¶
func (z *Zeitschaltung) SlotFromTemplate(data SlotTemplate) (err error)
SlotFromTemplate creates a Slot from a SlotTemplate and adds it to the Zeitschaltung.
func (*Zeitschaltung) SlotsFromTemplates ¶
func (z *Zeitschaltung) SlotsFromTemplates(data []SlotTemplate) (err error)
SlotsFromTemplates creates Slots from multiple SlotTemplates and adds them to the Zeitschaltung.
func (Zeitschaltung) String ¶
func (z Zeitschaltung) String() string
func (*Zeitschaltung) ToValues ¶
func (z *Zeitschaltung) ToValues() map[string]string
ToValues converts the Zeitschaltung to a map[string]string, which is the Format the FritzBox expects.
func (*Zeitschaltung) Validate ¶
func (z *Zeitschaltung) Validate() error
Validate checks if the Zeitschaltung is valid. It returns an error if the Zeitschaltung is invalid. This Method is automatically called when PyaSetZeitschaltung is called, but it may be called in addition manually to check User-Input.
Source Files
¶
- auth_client.go
- auth_session.go
- capability.go
- capability_button.go
- capability_hanfun.go
- capability_hkr.go
- capability_temperature.go
- fritz_device.go
- fritz_devicelist.go
- fritz_logs.go
- fritz_profile.go
- fritz_statistics.go
- hanfun_interfaces.go
- hanfun_unit.go
- pyAdapter.go
- smarthome.go
- smarthome_constants.go
- smarthome_device.go
- smarthome_devicelist.go
- smarthome_extdevicelist.go