Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

smartfritz-promise

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smartfritz-promise - npm Package Compare versions

Comparing version 0.5.3 to 0.5.5

.npmignore

74

example.js

@@ -11,4 +11,4 @@ /**

var username = DEFINE HERE;
var password = DEFINE HERE;
var username = "andig";
var password = "Nothing!28";

@@ -19,43 +19,51 @@

fritz.getDeviceListInfoArray(sid).then(function(res) {
console.log(res);
});
// fritz.getGuestWlan(sid).then(function(res) {
// console.log(res);
// });
// display switch information
fritz.getSwitchList(sid).then(function(switches) {
console.log("Switches: " + switches);
// fritz.getSwitchList(sid).then(function(switches) {
// console.log("Switches: " + switches);
if (switches.length) {
fritz.getSwitchName(sid, switches[0]).then(function(name) {
console.log("Switch name [" + switches[0] + "]: " + name);
// if (switches.length) {
// fritz.getSwitchName(sid, switches[0]).then(function(name) {
// console.log("Switch name [" + switches[0] + "]: " + name);
fritz.getSwitchPresence(sid, switches[0]).then(function(presence) {
console.log("Switch presence [" + switches[0] + "]: " + presence);
// fritz.getSwitchPresence(sid, switches[0]).then(function(presence) {
// console.log("Switch presence [" + switches[0] + "]: " + presence);
fritz.getSwitchState(sid, switches[0]).then(function(state) {
console.log("Switch state [" + switches[0] + "]: " + state);
});
// fritz.getSwitchState(sid, switches[0]).then(function(state) {
// console.log("Switch state [" + switches[0] + "]: " + state);
// });
fritz.getTemperature(sid, switches[0]).then(function(temp) {
console.log("Switch temperature [" + switches[0] + "]: " + temp + "°C");
});
});
});
}
});
// fritz.getTemperature(sid, switches[0]).then(function(temp) {
// console.log("Switch temperature [" + switches[0] + "]: " + temp + "°C");
// });
// });
// });
// }
// });
// display thermostat information
fritz.getThermostatList(sid).then(function(thermostats) {
console.log("Thermostats: " + thermostats);
// fritz.getThermostatList(sid).then(function(thermostats) {
// console.log("Thermostats: " + thermostats);
if (thermostats.length) {
fritz.getTemperature(sid, thermostats[0]).then(function(temp) {
console.log("Thermostat temperature [" + thermostats[0] + "]: " + temp + '°C');
});
// if (thermostats.length) {
// fritz.getTemperature(sid, thermostats[0]).then(function(temp) {
// console.log("Thermostat temperature [" + thermostats[0] + "]: " + temp + '°C');
// });
fritz.getTempTarget(sid, thermostats[0]).then(function(temp) {
console.log("Get Target temperature [" + thermostats[0] + "]: " + temp + '°C');
});
// fritz.getTempTarget(sid, thermostats[0]).then(function(temp) {
// console.log("Get Target temperature [" + thermostats[0] + "]: " + temp + '°C');
// });
fritz.setTempTarget(sid, thermostats[0], 22.0).then(function(temp) {
console.log("Set Target temperature [" + thermostats[0] + "]: " + temp + '°C');
});
}
});
// fritz.setTempTarget(sid, thermostats[0], 22.0).then(function(temp) {
// console.log("Set Target temperature [" + thermostats[0] + "]: " + temp + '°C');
// });
// }
// });
});
{
"name": "smartfritz-promise",
"version": "0.5.3",
"version": "0.5.5",
"description": "SmartHome for Fritz!Box and Dect!200 Node to communicate with AVM FritzBox over the aha-http-interface",

@@ -34,4 +34,4 @@ "author": {

"cheerio": "^0.19.0",
"querystring": ">=0.2.0",
"request": ">=2.45.*",
"extend": "^3.0.0",
"xml2json-light": "^1.0.4"

@@ -38,0 +38,0 @@ },

@@ -8,2 +8,3 @@ # smartfritz

- Get the session ID (`getSessionID`)
- Get device list (`getDeviceList`) >FritzOS 6.10
- Get device list as XML (`getDeviceListInfo`) >FritzOS 6.10

@@ -43,3 +44,3 @@ - Get temperature (`getTemperature`)

All functions have been tested on FritzOS 6.20/6.36 / FritzBox 7390. The WLAN functions may be less stable.
All functions have been tested on FritzOS 6.20/6.36/6.51 using the FritzBox 7390. The WLAN functions may be less stable.

@@ -46,0 +47,0 @@ ### Deprecated functions

@@ -20,18 +20,10 @@ /**

var parser = require('xml2json-light');
var extend = require('extend');
// #############################################################################
var defaults = { url: 'http://fritz.box' };
function extend()
{
for (var i=1; i<arguments.length; i++)
for (var key in arguments[i])
if (arguments[i].hasOwnProperty(key))
arguments[0][key] = arguments[i][key];
return arguments[0];
}
// run command for selected device
function executeCommand(sid, command, ain, options, path)
{
var req = extend({ url: 'http://fritz.box' }, options || {});
var req = extend({}, defaults, options || {});
req.url += path || '/webservices/homeautoswitch.lua?0=0';

@@ -99,14 +91,2 @@

/**
* Return devices array
*/
function getDeviceListInfoArray(sid, options) {
return module.exports.getDeviceListInfo(sid, options).then(function(devicelistinfo) {
var devices = parser.xml2json(devicelistinfo);
// extract devices as array
devices = [].concat((devices.devicelist || {}).device || []);
return Promise.resolve(devices);
});
}
/*

@@ -205,2 +185,12 @@ * Temperature conversion

module.exports.getDeviceList = function(sid, options)
{
return module.exports.getDeviceListInfo(sid, options).then(function(devicelistinfo) {
var devices = parser.xml2json(devicelistinfo);
// extract devices as array
devices = [].concat((devices.devicelist || {}).device || []);
return Promise.resolve(devices);
});
}
// get temperature- both switches and thermostats are supported

@@ -291,3 +281,3 @@ module.exports.getTemperature = function(sid, ain, options)

{
return getDeviceListInfoArray(sid, options).then(function(devices) {
return module.exports.getDeviceListInfo(sid, options).then(function(devices) {
// get thermostats- right now they're only available via the XML api

@@ -375,4 +365,3 @@ var thermostats = devices.filter(function(device) {

return new Promise(function(resolve, reject) {
var req = extend({
url: 'http://fritz.box',
var req = extend({}, defaults, {
method: 'POST',

@@ -379,0 +368,0 @@ form: settings

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc