All Projects → FlorianWendelborn → fritz-box

FlorianWendelborn / fritz-box

Licence: MIT License
📦 Promise-based JavaScript FRITZ!Box API.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to fritz-box

HomeApp
A little smart home app for Philips Hue and other devices
Stars: ✭ 54 (+285.71%)
Mutual labels:  home-automation, smarthome, fritz-box
homeassistant
Home Assistant Config
Stars: ✭ 50 (+257.14%)
Mutual labels:  home-automation, smarthome
homify
🏡 Open-source home automation / smarthome platform running on PHP (Laravel).
Stars: ✭ 45 (+221.43%)
Mutual labels:  home-automation, smarthome
ioBroker.homepilot20
Rademacher Homepilot 2.0 (version >= 5.0.39)
Stars: ✭ 19 (+35.71%)
Mutual labels:  home-automation, smarthome
ioBroker.hm-rpc
Connects HomeMatic Interface-Processes to ioBroker
Stars: ✭ 55 (+292.86%)
Mutual labels:  home-automation, smarthome
ioBroker.openhab
Connect ioBroker with openHAB
Stars: ✭ 13 (-7.14%)
Mutual labels:  home-automation, smarthome
home-assistant-opentherm-thermostat
Home Assistant OpenTherm Thermostat
Stars: ✭ 26 (+85.71%)
Mutual labels:  home-automation, smarthome
ad-alexatalkingclock
Alexa (or other Smart Speakers) tell you the time without asking every hour. Please ⭐️if you like my app :)
Stars: ✭ 30 (+114.29%)
Mutual labels:  home-automation, smarthome
zigbee
Database of Zigbee devices compatible with third party gateways: ZHA, deCONZ, Zigbee2MQTT, Tasmota, ZiGate, ioBroker,
Stars: ✭ 117 (+735.71%)
Mutual labels:  home-automation, smarthome
ioBroker.knx
connect KNX via eibd
Stars: ✭ 46 (+228.57%)
Mutual labels:  home-automation, smarthome
ioBroker.denon
Denon AVR adapter for ioBroker
Stars: ✭ 15 (+7.14%)
Mutual labels:  home-automation, smarthome
libzwaveip
libzwaveip - Control Z-Wave devices from your IP network
Stars: ✭ 76 (+442.86%)
Mutual labels:  home-automation, smarthome
ambianic-edge
The core runtime engine for Ambianic Edge devices.
Stars: ✭ 98 (+600%)
Mutual labels:  home-automation, smarthome
ioBroker.mihome-vacuum
Control your Xiaomi vacuum cleaner
Stars: ✭ 96 (+585.71%)
Mutual labels:  home-automation, smarthome
node-red-contrib-loxone
Connect the Loxone Miniserver to node-red via the Websocket API
Stars: ✭ 65 (+364.29%)
Mutual labels:  home-automation, smarthome
Iobroker.javascript
Script engine for JavaScript and Blockly
Stars: ✭ 244 (+1642.86%)
Mutual labels:  home-automation, smarthome
Smart Home
⭐ (Almost) everything needed to run my smart home with Home Assistant and more!
Stars: ✭ 221 (+1478.57%)
Mutual labels:  home-automation, smarthome
Iobroker.js Controller
ioBroker controller
Stars: ✭ 238 (+1600%)
Mutual labels:  home-automation, smarthome
ioBroker.ecovacs-deebot
Control your Ecovacs Deebot vacuum cleaner with ioBroker
Stars: ✭ 36 (+157.14%)
Mutual labels:  home-automation, smarthome
ioBroker.jarvis
jarvis - just another remarkable vis
Stars: ✭ 129 (+821.43%)
Mutual labels:  home-automation, smarthome

fritz-box

Promise-based JavaScript FRITZ!Box API.

Examples

Basic

import FritzBox from 'fritz-box'

const box = new FritzBox({
	host: 'fritz.box',
	password: '...',
	username: '...'
})

const run = async () => {
	await box.getSession()
	const settings = await box.getGuestWLAN()
	settings.active = true
	settings.ssid = 'Example!'
	await box.setGuestWLAN(settings)
	console.log(await box.overview())
}

run()

IFTTT Notify

This will activate the guest WLAN and emit a IFTTT Maker channel notify event. If you create the fitting IFTTT recipe, this snippet should send you the WLAN password right to your smartphone.

import FritzBox from 'fritz-box'
import IFTTT from 'maker-ifttt'

const box = new FritzBox({
	host: 'fritz.box',
	password: '...',
	username: '...'
})
const maker = new IFTTT('IFTTT_MAKER_TOKEN')

const run = async () => {
	// generate a random 8-digit hex password
	const newPassword = crypto.randomBytes(4).toString('hex');

	// sign-in
	await box.getSession()

	// get current guest WLAN settings
	const settings = await box.getGuestWLAN()

	// set new password & turn on guest WLAN
	settings.key = newPassword
	settings.active = true
	await box.setGuestWLAN(settings)

	// send a message to IFTTT (optional)
	maker.triggerEvent('notify', `Guest WLAN password is ${password}.`, response =>
		response.on('data', chunk =>
			console.info('Response: ' + chunk)
		)
	)
}

run()

Installation

yarn add fritz-box

or

npm i fritz-box

API

default class FritzBox <>

({ host = 'fritz.box', password: String, username: String }: Object): FritzBox

Creates a new FritzBox with the given parameters.

const box = new FritzBox({
	host: 'fritz.box',
	password: '...',
	username: '...'
});

box.getSession

(): Promise

Attempts to log in and fetches a session ID.

;(async () => {
	const box = new FritzBox(/* ... */)
	await box.getSession()
	// fritz-box is now ready for use
})()

box.getGuestWLAN

(): Promise

Fetches the guest WLAN configuration from the FRITZ!Box.

;(async () => {
	const box = new FritzBox(/* ... */)
	await box.getSession()
	const settings = await box.getGuestWLAN()
})()

box.setGuestWLAN

(settings: Object): Promise

Applies the (modified) settings object.

;(async () => {
	const box = new FritzBox(/* ... */)
	await box.getSession()
	await box.setGuestWLAN(settings)
})()

box.overview

(): Promise

Returns the data contained in the overview tab of the FRITZ!Box user interface.

;(async () => {
	const box = new FritzBox(/* ... */)
	await box.getSession()
	console.log(await box.overview())
})()

box.getDeviceDetails

(id: String): Promise

Gathers more information about a specific device.

;(async () => {
	const box = new FritzBox(/* ... */)
	await box.getSession()
	console.log(await box.getDeviceDetails('some-id'))
})()

box.getLog

(type = 'all' : String): Promise

Returns log entries. Supported types: 'all', 'system', 'internet', 'wlan', 'usb'.

;(async () => {
	const box = new FritzBox(/* ... */)
	await box.getSession()
	console.log(await box.getLog())
})()

Disclaimer

Tested in FRITZ!OS 6.92 on a FRITZ!Box 7590.

FRITZ!Box and FRITZ!OS are registered trademarks of AVM. This project does not grant you any permissions to use them.

History

  • 1.2.0

    • add getLog
    • improve documentation
  • 1.1.0

    • directly throw errors
    • add getDeviceDetails
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].