• This repository has been archived on 27/Jan/2023
  • Stars
    star
    139
  • Rank 262,177 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Home automation API for Fritz!Box, Fritz!DECT and FRITZ!Powerline devices

fritzapi

NPM Version NPM Downloads Build status Donate

Home automation node API for Fritz!Box, Fritz!DECT and FRITZ!Powerline devices.

homebridge-fritz and pimatic-fritz are built on fritzapi.

Functions

General functions

  • Get the Fritz!OS version getOSVersion
  • Get the session ID getSessionID
  • Get device list as XML getDeviceListInfos >Fritz!OS 6.10
  • Get device list getDeviceList >Fritz!OS 6.10
  • Get device list with filter criteria applied getDeviceListFiltered >Fritz!OS 6.10
  • Get device getDevice >Fritz!OS 6.10
  • Get temperature getTemperature - polyfill
  • Get presence getPresence - polyfill
  • Get template list as XML getTemplateListInfos >Fritz!OS 7.0
  • Get template list getTemplateList >Fritz!OS 7.0
  • Get template list applyTemplate >Fritz!OS 7.0

Note

getTemperature works for DECT repeaters but is not available on the FRITZ!Powerline 546E WLAN set and will always return NaN.

While getTemperature works for outlets, it is not available for (outlet) groups that can be created through the Fritz!Box user interface.

getDeviceListInfos was named getDeviceListInfo in earlier versions. For consistency with the official Fritz!Box API the name has been changed. The getDeviceListInfo name is deprecated and will be removed in a future release. In general, use of getDeviceListInfos is discouraged as the equivalent getDeviceList function which returns an object interface instead of XML is easier to use.

Fritz!DECT 200 and 210 outlet functions (includes FRITZ!Powerline 546E)

  • Get list getSwitchList
  • Get state getSwitchState
  • Set on setSwitchOn
  • Set off setSwitchOff
  • Toggle setSwitchToggle
  • Get power getSwitchPower
  • Get energy getSwitchEnergy
  • Get presence status getSwitchPresence
  • Get name getSwitchName
  • Get basic device stats as XML getBasicDeviceStats >Fritz!OS 7.0

For controlling AVM Fritz!DECT 200 devices the actuator identification number (AIN) is needed. The AIN can be obtained using getSwitchList which returns a list of AINs or the more general getDeviceList function which returns a verbose device list structure as JSON.

Fritz!DECT 100 functions

The Fritz!DECT 100 DECT repeater AIN does only appear in the getDeviceList output. It supports retrieving the repeater's temperature.

Fritz!DECT 300, 301 and CometDECT thermostat functions

Thermostat functions are only available as of Fritz!OS 6.36

  • Get list getThermostatList - polyfill
  • Set target temperature setTempTarget, supports 'ON'/'OFF' to enable/disable thermostat
  • Get target temperature getTempTarget
  • Get comfort temperature getTempComfort
  • Get night temperature getTempNight
  • Get battery charge getBatteryCharge (uses UI scraping, may be unstable)
  • Get window open getWindowOpen (uses UI scraping, may be unstable)

Fritz!DECT 500 and Telekom bulb functions

Bulb functions are only available as of Fritz!OS 7.20

  • Get List of all bulbs getBulbList
  • Get List of all bulbs supporting colors getColorBulbList
  • Switch bulb on/off or toggle it setSimpleOnOff
  • Dimm a bulb setLevel, 0 - 255
  • Dimm a bulb setLevelPercentage, 0 - 100
  • Set the color and saturation setColor, see note 1
  • Set the color temperature setColorTemperature, see note 2

Note 1
The color api calls of the FritzBox accept only a predefined set of values. To get easy access to the predefined values fritzapi accepts the following values as the color:
red, orange, yellow, lime, green, turquoise, cyan, lightblue, blue, purple, magenta, pink
The saturation can be 0, 1 or 2 to select one of the predefined saturation values for the color.

Note 2
The color temperature api calls of the FritzBox accept only a predefined set of values. Valid values are 2700, 3000, 3400,3800, 4200, 4700, 5300, 5900 and 6500.
Other values are adjusted by fritzapi to one of the above values.

WLAN functions

  • Get the guest wlan settings getGuestWlan
  • Set the guest wlan setGuestWlan

Note

getGuestWlan returns a structure containing all wifi settings found in the Fritz!Box UI. The setGuestWlan function accepts either a settings structure such as this or a single boolean value.

All functions have been tested on Fritz!OS 6.20/6.36/6.51 using the Fritz!Box 7390 and on Fritz!OS 6.50 on Fritz!Box 6490. The WLAN functions may be less stable.

Installation

npm install fritzapi

Usage

Object-oriented interface

The object-oriented interface is the recommended way of using fritzapi.

Get the list of switch AINs using a customer Fritz!Box address:

var Fritz = require('fritzapi').Fritz;

var f = new Fritz("user", "password", "http://192.168.178.1");

f.getSwitchList().then(function(ains){
  console.log(f.getSID());
  console.log(ains);
});

Functional interface

Get the session ID using default Fritz!Box address (http://fritz.box):

var fritz = require('fritzapi');

fritz.getSessionID("user", "password").then(function(sid) {
    console.log(sid);
});

Get the list of switch AINs using a custom Fritz!Box address with self-signed certificate:

fritz.getSessionID("user", "password", {
  url: "192.168.178.1",
  strictSSL: false         // workaround DEPTH_ZERO_SELF_SIGNED_CERT SSL error
}).then(function(sid) {
  console.log(sid);

  // note that the options/url need be carries through every single api call
  fritz.getSwitchList(sid, options).then(function(ains){
    console.log(ains);
  });
});

Note The functional interface may be deprecated in a future version of the library.

Device details

Below is the output of getDeviceList for reference.

The list was produced for various Fritz devices I've had around. It might have changed in the meantime depending on device firmware or Fritz HTTP API version. These definitions remain cached by the Fritz!Box even if the device is no longer connected. The device presence is indicated by the present attribute.

Powerline

{ identifier: '34:31:C4:DB:F6:C7',
  id: '20000',
  functionbitmask: '640',
  fwversion: '06.20',
  manufacturer: 'AVM',
  productname: 'FRITZ!Powerline 546E',
  present: '0',
  name: 'FRITZ!Powerline 546E',
  switch: { state: '', mode: '', lock: '' },
  powermeter: { power: '', energy: '' } }

Outlets

{ identifier: '087610103568',
  id: '17',
  functionbitmask: '35712',
  fwversion: '04.16',
  manufacturer: 'AVM',
  productname: 'FRITZ!DECT 200',
  present: '1',
  name: 'FRITZ!DECT 200 #1',
  switch: { state: '', mode: '', lock: '', devicelock : '' },
  simpleonoff { state: '' },
  powermeter: { voltage: '', power: '', energy: '' }, 
  temperature: { celsius: '', offset: '' }
  }

{ identifier: '116570031825',    
  id: '18',
  functionbitmask: '640',
  fwversion: '03.67',
  manufacturer: 'AVM',
  productname: 'FRITZ!DECT 210',
  present: '0',
  name: 'FRITZ!DECT 210 #3',
  switch: { state: '', mode: '', lock: '' },
  powermeter: { power: '', energy: '' } }

DECT Repeater

{ identifier: '116570002527',
  id: '20',
  functionbitmask: '1024',
  fwversion: '03.64',
  manufacturer: 'AVM',
  productname: 'FRITZ!DECT Repeater 100',
  present: '0',
  name: 'FRITZ!DECT Rep 100 #5' }

Thermostats

{ identifier: '109710195784',
  id: '17',
  functionbitmask: '320',
  fwversion: '03.54',
  manufacturer: 'AVM',
  productname: 'Comet DECT',
  present: '1',
  txbusy: '0'
  name: 'Comet DECT',
  battery: '90'
  batterylow: '0'
  temperature: { celsius: '', offset: '' },
  hkr: { tist: '49', tsoll: '253', absenk: '32', komfort: '42', lock: '1', devicelock: '1', errorcode: '0',  
         windowopenactiv: '0', windowopenactiveendtime: '0', boostactive: '0', boostactiveendtime: '0', 
         battery: '90', batterylow: '0', summeractive: '1', holidayactive: '0',
         nextchange: { endperiod: '1598907600', tchange: '32' }} }

HANFUN

As of Fritz!OS 7 the HANFUN devices have their own bitmask 1:

{ identifier: '119340326786',
  id: '406',
  functionbitmask: '1',
  fwversion: '00.00',
  manufacturer: '0x0feb',
  productname: 'HAN-FUN',
  present: '1',
  name: 'HAN-FUN #1' }

HANFUN functions are accessible as "HANFUN unit" devices. Bitmask consists of HANFUN unit (bit 13) plus actual function (in this case ALARM, bit 3):

{ identifier: '119340326786-1',
  id: '2000',
  functionbitmask: '8208',
  fwversion: '0.0',
  manufacturer: '0x0feb',
  productname: 'HAN-FUN',
  present: '1',
  name: 'no name',
  etsiunitinfo: { etsideviceid: '406', unittype: '514', interfaces: '256' },
  alert: { state: '1' } }

or a color bulb:

{ identifier: '127010028190-1',
  id: '2000',
  functionbitmask: '237572',
  fwversion: '0.0',
  manufacturer: '0x319d',
  productname: 'HAN-FUN',
  present: '0',
  txbusy: '0'
  name: 'Bulb 1',
  simpleonoff { state: '1' },
  levelcontrol: { level: '255', levelpercentage: '100' },
  colorcontrol: { supported_modes: '5', current_mode: '1', hue: '35', saturation: '214', temperature: '' },
  etsiunitinfo: { etsideviceid: '406', unittype: '278', interfaces: '512,514,513' } }

AHA HTTP Interface Documentation

http://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AHA-HTTP-Interface.pdf

Acknowledgements

Thanks to:

  • AVM for providing free test devices and the AHA-HTTP interface document
  • EUROtronic Technology GmbH for providing free CometDECT thermostat sample
  • nischelwitzer for the basic js implementation (https://github.com/nischelwitzer/smartfritz)
  • steffen.timm for the basic communication function
  • thk4711 for the FRITZ!DECT 200 codes

More Repositories

1

homebridge-fritz

Homebridge platform for Fritz!Box router and supported DECT devices
JavaScript
74
star
2

videodb

The videoDB media collection software
PHP
65
star
3

beats4pi

Docker image to build elastic/beats for Raspberry Pi
Shell
41
star
4

vzero

VZero - the Wireless zero-config controller for volkszaehler.org
C++
24
star
5

AdaPi

Python ports of Adafruit libraries for use with the Raspberry Pi
Python
19
star
6

gravo

Grafana for Volkszaehler
Go
15
star
7

grafana-darksky

DarkSky weather and forecast data for Grafana
TypeScript
9
star
8

goelster

Go interface for Elster CAN devices
Go
8
star
9

pimatic-fritz

Pimatic plugin for Fritz!Box SmartHome and FritzDect!200 Node
CoffeeScript
8
star
10

syno-elk-docker

Synology adoption of sebp/elk
8
star
11

vzvis

Simple visualization for Volkszaehler
JavaScript
7
star
12

canprogs

Mirror of can_progs http://www.juerg5524.ch/list_data.php
PHP
5
star
13

discovergy

Discovergy API client
PHP
4
star
14

dbcopy

Configurable database backup tool for volkszaehler.org
PHP
3
star
15

moode

Moode audio distribution
PHP
3
star
16

vzmon

Solar generation mobile phone monitoring app for volkszaehler.org
JavaScript
3
star
17

ingress

Universal data mapper for Volkszähler smart meter
Go
2
star
18

vscode-sublime-cmd-shift-d

SublimeText Cmd-Shift-D shortcut behaviour for VSCode
TypeScript
2
star
19

spotify-web-api-extensions

Guzzle Adapter for use with SpotifyWebApi
PHP
2
star
20

chartjs-plugin-axispadding

Chart.js plugin to add scale label padding to inner axes
JavaScript
2
star
21

node-red-contrib-watchdog

A watchdog node for node-red
HTML
1
star
22

node-red-ebusd-volkszaehler

ebusd logging to volkszaehler for vaillant heating
JavaScript
1
star
23

mozilla-isp

ISP configuration provider using Mozilla ISP database
PHP
1
star
24

pimatic-volkszaehler

Volkszaehler plugin for pimatic automation server
CoffeeScript
1
star
25

gosml

Go port of volkszaehler/libsml
Go
1
star
26

ebusd-logging

My personal node-red ebusd logging setup
1
star
27

node-red-contrib-volkszaehler

NodeRED nodes for volkszaehler.org API
JavaScript
1
star
28

homie

Go implementation of the Homie IoT device spec
Go
1
star
29

Fire2016

Fire2012 FastLED simulation installed in IKEA lamp
C++
1
star
30

node-red-contrib-change-detect

Change detection node for node-red
JavaScript
1
star