fritz_api v1.0.2 FritzApi View Source
Fritz!Box Home Automation API Client for Elixir
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 actors.
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 switching state.
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(sid, opts \\ [])
View Sourceget_device_list_infos(String.t(), opts()) :: {:error, any()} | {:ok, [FritzApi.Actor.t()]}
Get essential information of all smart home devices.
Example
iex> FritzApi.get_device_list_infos(sid)
{:ok, [%FritzApi.Actor{
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: :manual,
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.
Returns {:ok, nil}
if the state is unkown.
Example
iex> FritzApi.get_switch_energy(sid, "687690315761")
{:ok, 0.475}
Get the actuator identification numbers (AIN) of all known actors.
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.
Returns {:ok, nil}
if the state is unkown.
Example
iex> FritzApi.get_switch_power(sid, "687690315761")
{:ok, 0.0}
Get the current connection state of the actor.
Returns {:ok, nil}
if the connection state is unkown.
Example
iex> FritzApi.get_switch_present(sid, "687690315761")
{:ok, true}
Get the current switching state.
Returns {:ok, nil}
if the state is unkown.
Example
iex> FritzApi.get_switch_state(sid, "687690315761")
{:ok, false}
Get the last measured temperature (Celsius) of the actor.
Returns {:ok, nil}
if the temperature could not be measured.
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}