Giter Club home page Giter Club logo

smartfritz's Introduction

smartfritz

Node module to communicate with a AVM FritzBox and FRITZ!DECT 200 (smart home hardware) providing the following functions:

  • Get the session ID (getSessionID)
  • Get the switch (FRITZ!DECT 200) State (getSwitchState)
  • Set the switch (FRITZ!DECT 200) ON (setSwitchOn)
  • Set the switch (FRITZ!DECT 200) OFF (setSwitchOff)
  • Get the switch (FRITZ!DECT 200) Power (getSwitchPower)
  • Get the switch (FRITZ!DECT 200) Energy (getSwitchEnergy)
  • Get the switch (FRITZ!DECT 200) List (getSwitchList)
  • Get the DeviceListInfos (FRITZ!DECT 200) as XML (getDeviceListInfos) >FritzOS 6.10
  • Get the phone list (getPhoneList)
  • Set the guest wlan (setGuestWLan)
  • Get the guest wlan settings (getGuestWLan)

correction of package.json with main for "out of the box" function.

For AVM FRITZ!DECT 200 control you need to know your Actuator identification number (AIN)

Install

npm install smartfritz

Testing the Examples

node fritz02_devicelistinfos.js

Output similar to:
Fritz!Session ID: 171775fcb855bc17
Switches AIDs: 087610087001,087510717012,087610101971

How to use

Get the session ID default: as URL "fritz.box" is used as default paramter

var fritz = require('smartfritz');

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

Get the session ID with own URL: use your Fritz!Box IP when "fritz.box" is not working.

var fritz = require('smartfritz');

var moreParam = { url:"192.168.178.1" };
fritz.getSessionID("user", "password", function(sid){
    console.log(sid);
}, moreParam);

Get the Switch AID List:

var fritz = require('smartfritz');

fritz.getSessionID("user", "password", function(sid){
  
  console.log("Fritz!Session ID: "+sid);
  fritz.getSwitchList(sid,function(listinfos){
      console.log("Switches AIDs: "+listinfos);
  });

});

Get the switch Power (FRITZ!DECT 200):

var fritz = require('smartfritz');

fritz.getSwitchPower(sid, aid, function(sid){
    console.log(sid);
});

Get the switch Energy (FRITZ!DECT 200):

var fritz = require('smartfritz');

fritz.getSwitchEnergy(sid, aid, function(sid){
    console.log(sid);
});

Get the switch State (DECT200):

var fritz = require('smartfritz');

fritz.getSwitchState(sid, aid, function(sid){
    console.log(sid);
});

Set the switch State ON (DECT200):

var fritz = require('smartfritz');

fritz.setSwitchOn(sid, aid, function(sid){
    console.log(sid);
});

Set the switch State OFF (DECT200):

var fritz = require('smartfritz');

fritz.setSwitchOff(sid, aid, function(sid){
    console.log(sid);
});

Get the phone list:

var fritz = require('smartfritz');

fritz.getPhoneList(sid,function(calls){
    console.log(calls);
});

Enable or disable guest wlan:

var fritz = require('smartfritz');

fritz.setGuestWLan(sid, true, function(enabled){
    console.log("Guest WLan Enabled: "+enabled);
});

Get guest wlan settings:

var fritz = require('smartfritz');

fritz.getGuestWLan(sid, function(settings){
    console.log(settings);
});

AHA-HTTP Interface

AHA - Avm Home Interface

https://fritz.box/webservices/homeautoswitch.lua?ain=&switchcmd=&sid=

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

Thanks to // Code base from:

  • steffen.timm for the basic communication function
  • thk4711 for the FRITZ!DECT 200 codes
  • AVM for providing the good AHA-HTTP-Interface document

smartfritz's People

Contributors

nischelwitzer avatar

Stargazers

Sam avatar Martin[S] avatar ~ mimic ~ avatar  avatar James Macfie avatar Dirk avatar  avatar Benjamin Urban avatar David K avatar Alexander Brickwedde avatar Florian Wendelborn avatar  avatar  avatar  avatar spddl avatar Mario avatar Christian Lins avatar Sascha Hagedorn avatar Cornelius Schiffer avatar

Watchers

James Cloos avatar  avatar  avatar  avatar Eweol avatar

smartfritz's Issues

Add https support

The current implementation uses http. https would be appreciated for allowing external access to the "at home" fritz box. It might make sense to switch from http to request or the request-promise module for this purpose.

Seems To Be Broken

fritz.getSessionID(options.user, options.password, (sessionID) => {
    this.sessionID = sessionID;
    console.log(`fritz: ${sessionID}`);
    fritz.setGuestWLan(sessionID, true, (enabled) => {
        console.log(`Guest WLAN ${enabled ? 'enabled' : 'disabled'}`);
    });
});

Successfully manages to get a sessionID, then crashes like this:

fritz: somethingSomething
/home/pi/code/home/node_modules/smartfritz/lib/smartfritz.js:70
            options.ssid || (options.ssid = /"wlan:settings\/guest_ssid"\] = "([^"]*)"/g.exec(data)[1]);
                                                                                                   ^

TypeError: Cannot read property '1' of null
    at IncomingMessage.<anonymous> (/home/pi/code/home/node_modules/smartfritz/lib/smartfritz.js:70:100)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:903:12)
    at doNTCallback2 (node.js:439:9)
    at process._tickCallback (node.js:353:17)

Hardware: Fritz!Box 3490, latest firmware.

This also affects node2fritz, so it seems to be some API change.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.