Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@seydx/fritzbox

SeydX164MIT2.3.1

A promised based utilty for accessing a fritzbox via tr064

fritzbox, avm, tr-064, tr064, router, igd

readme

@seydx/fritzbox

A promise based library for accessing a fritzbox via TR-064 API of an AVM Fritz!Box. Forked from @ulfalfa

Features

This library is capable of:

  • Supports the complete command language of the TR-064 API of an Fritz!Box
  • No callback, only promises
  • SSL encryption and authentication

Install

npm install @seydx/fritzbox

Usage

Getting the info about the fritzbox

With the method exec you can access all services and actions in the fritz box even with parameters

const Fritzbox = require('@seydx/fritzbox');
const fritzbox = new Fritzbox({ username: 'test', password: 'testPwd123' });

// Async/Await:
async function getDeviceInfo () {
  try {
    const info = await fritzbox.exec(
      'urn:DeviceInfo-com:serviceId:DeviceInfo1',
      'GetInfo'
    );
    console.log(info);
  } catch (err) {
    console.error(err);
  }
}

Getting all currently known hosts by Fritz!Box

const Fritzbox = require('@seydx/fritzbox');
const fritzbox = new Fritzbox({ username: 'test', password: 'testPwd123' });

// Async/Await:
async function getHosts () {
  try {
    const allHosts = await fritzbox.getAllHosts();
    console.log(allHosts);
  } catch (err) {
    console.error(err);
  }
}

Retrieving all services with their corresponding actions

const Fritzbox = require('@seydx/fritzbox');
const fritzbox = new Fritzbox({ username: 'test', password: 'testPwd123' });

// Async/Await:
async function getServices () {
  try {
    const services = await fritzbox.describe();
    console.log(services);
  } catch (err) {
    console.error(err);
  }
}

changelog

Changelog

v2.3.1 - 2021-10-06

  • Minor bugfixes

v2.3.0 - 2021-09-19

  • Refactored getSmarthomeDevices
  • Better error debug
  • Minor bugfixes
  • Updated dependencies

v2.2.9 - 2021-06-28

  • Updated dependencies

v2.2.8 - 2021-06-28

  • Fix decoding user password

v2.2.7 - 2021-06-27

  • Added SOAP error message

v2.2.6 - 2021-06-22

  • Support other DECT buttons

v2.2.5 - 2021-06-20

  • Better error debug

v2.2.4 - 2021-06-21

  • Minor bugfixes

v2.2.3 - 2021-06-20

  • Better error debug

v2.2.2 - 2021-06-20

  • Better error debug

v2.2.1 - 2021-06-20

  • Bugfix

v2.2.0 - 2021-06-20

  • Bugfix

v2.1.9 - 2021-06-18

  • Support for buttons (2/4 channel)

v2.1.8 - 2021-06-15

  • Changed requestAHA(host, ain, sid, cmd) to requestAHA(host, cmd)

v2.1.7 - 2021-06-15

  • Revert back changes from v2.1.6

v2.1.6 - 2021-06-15

  • Fix smarthome device/group ain

v2.1.5 - 2021-06-15

  • Fix blind position data

v2.1.4 - 2021-06-15

  • Fix searchParams for reqeustAHA

v2.1.3 - 2021-06-14

  • Return object for requestLUA

v2.1.2 - 2021-06-14

  • Added blind (smarthome) support

v2.1.1 - 2021-06-14

  • Added more debug
  • v2.1.0 - 2021-06-14

  • Added new methods: fritzbox.getAllHostsV2(), fritzbox.getSmarthomeDevices()
  • Added new request types: requestAHA(..), requestLUA(..)

v2.0.5 - 2021-05-29

  • Fix special characters in URL

v2.0.4 - 2021-05-29

  • Fix special characters in URL

v2.0.3 - 2021-05-21

  • Better error handling

v2.0.2 - 2021-05-21

  • Switched to serviceId
  • Better error handling
  • Minor improvements and bugfixes

v2.0.1 - 2021-05-21

  • Better error handling

v2.0.0 - 2021-05-20

Breaking Changes

  • 1) Due to refractorization the module must be imported differently
//BEFORE
const { Fritzbox } = require('@seydx/fritzbox');
//import { Fritzbox } from ('@seydx/fritzbox');

//AFTER
const Fritzbox = require('@seydx/fritzbox');
//import Fritzbox from ('@seydx/fritzbox');
  • 2) The new version uses got instead of request. Therefore requests using requestXml must be changed, otherwise requests over HTTPS will result in self signed error.
const { requestXml } = require('@seydx/fritzbox/lib/request');

//BEFORE
async function myRequest() {
  try {
    const uri = 'https://<USERNAME>:<PASSWORD>@fritz.box:49443/<ENDPOINT>';
    const response = await requestXml({
      uri,
      {
        rejectUnauthorized: false
      }
    });
  } catch(err) {
    console.log(err);
  }
}


//AFTER
async function myRequest() {
  try {
    const uri = 'https://<USERNAME>:<PASSWORD>@fritz.box:49443/<ENDPOINT>';
    const response = await requestXml(uri, {
      https:{
        rejectUnauthorized: false
      }
    });
  } catch(err) {
    console.log(err);
  }
}

Notable Changes

  • The code has been refactored

Other Changes

  • Dependencies were updated

Bugfixes

  • Minor bugfixes

v1.x