fritz_api

Fritz!Box Home Automation API Client for Elixir (documentation).

Installation

Add fritz_api to your list of dependencies in mix.exs:

def deps do
  [
    {:fritz_api, "~> 1.0"}
  ]
end

Usage

iex> FritzApi.Client.start("admin", "changeme")
iex> FritzApi.Client.get_device_list_infos()
{: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
  }
}]}
iex> FritzApi.Client.set_switch_off("687690315761")
:ok
iex> FritzApi.Client.get_temperature("687690315761")
{:ok, 23.5}

Options

There are a number of supported options, documented here, that can be added when starting the FritzApi.Client.

iex> FritzApi.Client.start("admin", "changeme", [base: "https://192.168.0.1", ssl: [{:versions, [:'tlsv1.2']}]])

Starting in Supervision Tree

# in your application.ex

def start(_type, _args) do
  children = [
    {FritzApi.Client, username: @username, password: @password, opts: @opts}
  ]

  # ...
end

References