fritz_api v0.1.0 FritzApi View Source
API Client for the Fritz!Box Home Automation HTTP Interface
Link to this section Summary
Types
- base: The base url of the fritzbox. Defaults to “http://fritz.box”
- ssl: SSL options supported by the ssl erlang module
Functions
Get essential information of all smart home devices
Get a session ID
Get the total energy usage (kWh) of the switch
Get the actuator identification numbers (AIN) of all known switches
Get the name of the actor
Get the current power consumption (Watt) of the switch
Get the current connection state of the actor
Get the current state of the switch
Get the last measured temperature (Celsius) of the actor
Turn off the switch
Turn on the switch
Toggle the switch
Link to this section Types
- base: The base url of the fritzbox. Defaults to “http://fritz.box”
- ssl: SSL options supported by the ssl erlang module
Link to this section Functions
get_device_list_infos(String.t, opts) :: {:error, any} | {:ok, FritzApi.DeviceListInfos.t}
Get essential information of all smart home devices.
Example
iex> FritzApi.get_device_list_infos(sid)
{:ok, [%{
ain: "687690315761",
fwversion: "03.87",
id: 21,
manufacturer: "AVM",
name: "FRITZ!DECT #1",
powermeter: %{energy: 0.475, power: 0.0},
present: true,
productname: "FRITZ!DECT 200",
switch: %{
devicelock: false,
lock: false,
mode: "manuell",
state: false
},
temperature: %{
celsius: 23.5,
offset: 0.0
}
}]}
Get a session ID.
A valid session ID is required in order to interact with the FritzBox API.
Each application should only acquire a single session ID since the number of sessions to a FritzBox is limited.
In principle, each session ID has a validity of 60 Minutes whereby the validity period gets extended with every access to the API. However, if any application tries to access the API with an invalid session ID, all other sessions get terminated.
Example
iex> FritzApi.get_session_id("admin", "changeme")
{:ok, "879b972027084f61"}
Get the total energy usage (kWh) of the switch.
Example
iex> FritzApi.get_switch_energy(sid, "687690315761")
{:ok, 0.475}
Get the actuator identification numbers (AIN) of all known switches.
Example
iex> FritzApi.get_switch_list(sid, opts)
{:ok, ["687690315761"]}
Get the name of the actor.
Example
iex> FritzApi.get_switch_name(sid, "687690315761")
{:ok, "FRITZ!DECT #1"}
Get the current power consumption (Watt) of the switch.
Example
iex> FritzApi.get_switch_power(sid, "687690315761")
{:ok, 0.0}
Get the current connection state of the actor.
Example
iex> FritzApi.get_switch_present(sid, "687690315761")
{:ok, :connected}
Get the current state of the switch.
Example
iex> FritzApi.get_switch_state(sid, "687690315761")
{:ok, :off}
Get the last measured temperature (Celsius) of the actor.
Example
iex> FritzApi.get_temperature(sid, "687690315761")
{:ok, 23.5}
Turn off the switch.
Example
iex> FritzApi.set_switch_off(sid, "687690315761")
:ok
Turn on the switch.
Example
iex> FritzApi.set_switch_on(sid, "687690315761")
:ok
Toggle the switch.
Example
iex> FritzApi.set_switch_toggle(sid, "687690315761")
{:ok, :off}