View Source FritzApi (fritz_api v3.0.0)

A Fritz!Box Home Automation API Client for Elixir.

Usage

iex> {:ok, client} = FritzApi.Client.new()
...>                 |> FritzApi.Client.login("admin", "changeme")

iex> FritzApi.set_switch_off(client, "687690315761")
:ok

iex> FritzApi.get_temperature(client, "687690315761")
{:ok, 23.5}

Configuration

The main way to configure FritzApi is through the options passed to FritzApi.Client.new/1.

To customize the behaviour of the HTTP client used by FritzApi, you can configure FritzApi through the application environment . For example, you can do this in config/runtime.exs:

# config/runtime.exs
config :fritz_api,
  # ...

You can use these options:

Summary

Types

Unique actor identifier.

Password of the FritzBox user.

Name of the FritzBox user.

Functions

Disable the target temperature of the radiator controller.

Enabele the target temperature of the radiator controller.

Get essential information of all smart home devices.

Get the comfort temperature (Celsius) set for time switching of the radiator controller.

Get the economy temperature (Celsius) set for time switching of the radiator controller.

Get the target temperature (Celsius) currently set for the radiator controller.

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.

Set the target temperature (Celsius) of the radiator controller.

Turn off the switch.

Turn on the switch.

Toggle the switch.

Types

@type ain() :: String.t()

Unique actor identifier.

@type password() :: String.t()

Password of the FritzBox user.

@type useranme() :: String.t()

Name of the FritzBox user.

Note

With FRITZ! OS 7.24 and later, the user name cannot be empty.

Functions

Link to this function

disable_hkr_target_temperature(client, ain)

View Source
@spec disable_hkr_target_temperature(FritzApi.Client.t(), ain()) ::
  {:error, FritzApi.Error.t()} | :ok

Disable the target temperature of the radiator controller.

Example

iex> FritzApi.disable_hkr_target_temperature(client, "687690315761")
{:ok, 23.5}
Link to this function

enable_hkr_target_temperature(client, ain)

View Source
@spec enable_hkr_target_temperature(FritzApi.Client.t(), ain()) ::
  {:error, FritzApi.Error.t()} | :ok

Enabele the target temperature of the radiator controller.

Example

iex> FritzApi.enable_hkr_target_temperature(client, "687690315761")
{:ok, 23.5}
Link to this function

get_device_list_infos(client)

View Source
@spec get_device_list_infos(FritzApi.Client.t()) ::
  {:error, FritzApi.Error.t()} | {:ok, [FritzApi.Actor.t()]}

Get essential information of all smart home devices.

Example

iex> FritzApi.get_device_list_infos(client)
{:ok, [%FritzApi.Actor{
   ain: "687690315761",
   alert: nil,
   functions: ["Energie Messgerät", "Temperatursensor",
     "Schaltsteckdose", "Mikrofon"],
   fwversion: "04.17",
   id: "1",
   manufacturer: "AVM",
   name: "Aussensteckdose",
   powermeter: %FritzApi.Powermeter{
     energy: 8.94,
     power: 0.0,
     voltage: 231.17
   },
   present: true,
   productname: "FRITZ!DECT 210",
   switch: %FritzApi.Switch{
     devicelock: false,
     lock: false,
     mode: :auto,
     state: false
   },
   temperature: %FritzApi.Temperature{
     celsius: 21.0,
     offset: 0.0
   }
 }]}
Link to this function

get_hkr_comfort_temperature(client, ain)

View Source
@spec get_hkr_comfort_temperature(FritzApi.Client.t(), ain()) ::
  {:error, FritzApi.Error.t()} | {:ok, :unknown | :on | :off | float()}

Get the comfort temperature (Celsius) set for time switching of the radiator controller.

Example

iex> FritzApi.get_hkr_comfort_temperature(client, "687690315761")
{:ok, 23.5}
Link to this function

get_hkr_economy_temperature(client, ain)

View Source
@spec get_hkr_economy_temperature(FritzApi.Client.t(), ain()) ::
  {:error, FritzApi.Error.t()} | {:ok, :unknown | :on | :off | float()}

Get the economy temperature (Celsius) set for time switching of the radiator controller.

Example

iex> FritzApi.get_hkr_economy_temperature(client, "687690315761")
{:ok, 23.5}
Link to this function

get_hkr_target_temperature(client, ain)

View Source
@spec get_hkr_target_temperature(FritzApi.Client.t(), ain()) ::
  {:error, FritzApi.Error.t()} | {:ok, :unknown | :on | :off | float()}

Get the target temperature (Celsius) currently set for the radiator controller.

Example

iex> FritzApi.get_hkr_target_temperature(client, "687690315761")
{:ok, 23.5}
Link to this function

get_switch_energy(client, ain)

View Source
@spec get_switch_energy(FritzApi.Client.t(), ain()) ::
  {:error, FritzApi.Error.t()} | {:ok, :unknown | float()}

Get the total energy usage (kWh) of the switch.

Returns {:ok, :unknown} if the state is unknown.

Example

iex> FritzApi.get_switch_energy(client, "687690315761")
{:ok, 0.475}
@spec get_switch_list(FritzApi.Client.t()) ::
  {:error, FritzApi.Error.t()} | {:ok, [ain()]}

Get the actuator identification numbers (AIN) of all known actors.

Example

iex> FritzApi.get_switch_list(client)
{:ok, ["687690315761"]}
Link to this function

get_switch_name(client, ain)

View Source
@spec get_switch_name(FritzApi.Client.t(), ain()) ::
  {:error, FritzApi.Error.t()} | {:ok, String.t()}

Get the name of the actor.

Example

iex> FritzApi.get_switch_name(client, "687690315761")
{:ok, "FRITZ!DECT #1"}
Link to this function

get_switch_power(client, ain)

View Source
@spec get_switch_power(FritzApi.Client.t(), ain()) ::
  {:error, FritzApi.Error.t()} | {:ok, :unknown | float()}

Get the current power consumption (Watt) of the switch.

Returns {:ok, :unknown} if the state is unknown.

Example

iex> FritzApi.get_switch_power(client, "687690315761")
{:ok, 0.0}
Link to this function

get_switch_present(client, ain)

View Source
@spec get_switch_present(FritzApi.Client.t(), ain()) ::
  {:error, FritzApi.Error.t()} | {:ok, boolean()}

Get the current connection state of the actor.

Example

iex> FritzApi.get_switch_present(client, "687690315761")
{:ok, true}
Link to this function

get_switch_state(client, ain)

View Source
@spec get_switch_state(FritzApi.Client.t(), ain()) ::
  {:error, FritzApi.Error.t()} | {:ok, :unknown | :on | :off}

Get the current switching state.

Returns {:ok, :unknown} if the state is unknown.

Example

iex> FritzApi.get_switch_state(client, "687690315761")
{:ok, :on}
Link to this function

get_temperature(client, ain)

View Source
@spec get_temperature(FritzApi.Client.t(), ain()) ::
  {:error, FritzApi.Error.t()} | {:ok, :unknown | float()}

Get the last measured temperature (Celsius) of the actor.

Returns {:ok, :unknown} if the temperature could not be measured.

Example

iex> FritzApi.get_temperature(client, "687690315761")
{:ok, 23.5}
Link to this function

set_hkr_target_temperature(client, ain, temp)

View Source
@spec set_hkr_target_temperature(FritzApi.Client.t(), ain(), 8..28) ::
  {:error, FritzApi.Error.t()} | :ok

Set the target temperature (Celsius) of the radiator controller.

Example

iex> FritzApi.set_hkr_target_temperature(client, "687690315761", 21.5)
{:ok, 23.5}
Link to this function

set_switch_off(client, ain)

View Source
@spec set_switch_off(FritzApi.Client.t(), ain()) :: {:error, FritzApi.Error.t()} | :ok

Turn off the switch.

Example

iex> FritzApi.set_switch_off(client, "687690315761")
:ok
Link to this function

set_switch_on(client, ain)

View Source
@spec set_switch_on(FritzApi.Client.t(), ain()) :: {:error, FritzApi.Error.t()} | :ok

Turn on the switch.

Example

iex> FritzApi.set_switch_on(client, "687690315761")
:ok
Link to this function

set_switch_toggle(client, ain)

View Source
@spec set_switch_toggle(FritzApi.Client.t(), ain()) ::
  {:error, FritzApi.Error.t()} | {:ok, :on | :off}

Toggle the switch.

Example

iex> FritzApi.set_switch_toggle(client, "687690315761")
{:ok, :off}