domoticz-api-linker
Version:
Domoticz API Javascript Bridge Connector
2,726 lines • 97.5 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _regeneratorRuntime() {
_regeneratorRuntime = function () {
return exports;
};
var exports = {},
Op = Object.prototype,
hasOwn = Op.hasOwnProperty,
$Symbol = "function" == typeof Symbol ? Symbol : {},
iteratorSymbol = $Symbol.iterator || "@@iterator",
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
function define(obj, key, value) {
return Object.defineProperty(obj, key, {
value: value,
enumerable: !0,
configurable: !0,
writable: !0
}), obj[key];
}
try {
define({}, "");
} catch (err) {
define = function (obj, key, value) {
return obj[key] = value;
};
}
function wrap(innerFn, outerFn, self, tryLocsList) {
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
generator = Object.create(protoGenerator.prototype),
context = new Context(tryLocsList || []);
return generator._invoke = function (innerFn, self, context) {
var state = "suspendedStart";
return function (method, arg) {
if ("executing" === state) throw new Error("Generator is already running");
if ("completed" === state) {
if ("throw" === method) throw arg;
return doneResult();
}
for (context.method = method, context.arg = arg;;) {
var delegate = context.delegate;
if (delegate) {
var delegateResult = maybeInvokeDelegate(delegate, context);
if (delegateResult) {
if (delegateResult === ContinueSentinel) continue;
return delegateResult;
}
}
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
if ("suspendedStart" === state) throw state = "completed", context.arg;
context.dispatchException(context.arg);
} else "return" === context.method && context.abrupt("return", context.arg);
state = "executing";
var record = tryCatch(innerFn, self, context);
if ("normal" === record.type) {
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
return {
value: record.arg,
done: context.done
};
}
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
}
};
}(innerFn, self, context), generator;
}
function tryCatch(fn, obj, arg) {
try {
return {
type: "normal",
arg: fn.call(obj, arg)
};
} catch (err) {
return {
type: "throw",
arg: err
};
}
}
exports.wrap = wrap;
var ContinueSentinel = {};
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
var IteratorPrototype = {};
define(IteratorPrototype, iteratorSymbol, function () {
return this;
});
var getProto = Object.getPrototypeOf,
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function (method) {
define(prototype, method, function (arg) {
return this._invoke(method, arg);
});
});
}
function AsyncIterator(generator, PromiseImpl) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
if ("throw" !== record.type) {
var result = record.arg,
value = result.value;
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
invoke("next", value, resolve, reject);
}, function (err) {
invoke("throw", err, resolve, reject);
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
result.value = unwrapped, resolve(result);
}, function (error) {
return invoke("throw", error, resolve, reject);
});
}
reject(record.arg);
}
var previousPromise;
this._invoke = function (method, arg) {
function callInvokeWithMethodAndArg() {
return new PromiseImpl(function (resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
};
}
function maybeInvokeDelegate(delegate, context) {
var method = delegate.iterator[context.method];
if (undefined === method) {
if (context.delegate = null, "throw" === context.method) {
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
}
return ContinueSentinel;
}
var record = tryCatch(method, delegate.iterator, context.arg);
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
var info = record.arg;
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
}
function pushTryEntry(locs) {
var entry = {
tryLoc: locs[0]
};
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
}
function resetTryEntry(entry) {
var record = entry.completion || {};
record.type = "normal", delete record.arg, entry.completion = record;
}
function Context(tryLocsList) {
this.tryEntries = [{
tryLoc: "root"
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
}
function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) return iteratorMethod.call(iterable);
if ("function" == typeof iterable.next) return iterable;
if (!isNaN(iterable.length)) {
var i = -1,
next = function next() {
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
return next.value = undefined, next.done = !0, next;
};
return next.next = next;
}
}
return {
next: doneResult
};
}
function doneResult() {
return {
value: undefined,
done: !0
};
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
var ctor = "function" == typeof genFun && genFun.constructor;
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
}, exports.mark = function (genFun) {
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
}, exports.awrap = function (arg) {
return {
__await: arg
};
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
return this;
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
void 0 === PromiseImpl && (PromiseImpl = Promise);
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
return result.done ? result.value : iter.next();
});
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
return this;
}), define(Gp, "toString", function () {
return "[object Generator]";
}), exports.keys = function (object) {
var keys = [];
for (var key in object) keys.push(key);
return keys.reverse(), function next() {
for (; keys.length;) {
var key = keys.pop();
if (key in object) return next.value = key, next.done = !1, next;
}
return next.done = !0, next;
};
}, exports.values = values, Context.prototype = {
constructor: Context,
reset: function (skipTempReset) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
},
stop: function () {
this.done = !0;
var rootRecord = this.tryEntries[0].completion;
if ("throw" === rootRecord.type) throw rootRecord.arg;
return this.rval;
},
dispatchException: function (exception) {
if (this.done) throw exception;
var context = this;
function handle(loc, caught) {
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i],
record = entry.completion;
if ("root" === entry.tryLoc) return handle("end");
if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc"),
hasFinally = hasOwn.call(entry, "finallyLoc");
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
} else if (hasCatch) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
} else {
if (!hasFinally) throw new Error("try statement without catch or finally");
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
}
}
}
},
abrupt: function (type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
var record = finallyEntry ? finallyEntry.completion : {};
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
},
complete: function (record, afterLoc) {
if ("throw" === record.type) throw record.arg;
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
},
finish: function (finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
}
},
catch: function (tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if ("throw" === record.type) {
var thrown = record.arg;
resetTryEntry(entry);
}
return thrown;
}
}
throw new Error("illegal catch attempt");
},
delegateYield: function (iterable, resultName, nextLoc) {
return this.delegate = {
iterator: values(iterable),
resultName: resultName,
nextLoc: nextLoc
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
}
}, exports;
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
Object.defineProperty(subClass, "prototype", {
writable: false
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}
return _assertThisInitialized(self);
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived),
result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
if (_i == null) return;
var _arr = [];
var _n = true;
var _d = false;
var _s, _e;
try {
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function b64encode(data) {
return typeof window === 'undefined' ? b64encodeNode : b64encodeBrowser(data);
}
function b64encodeBrowser(data) {
return btoa(data);
}
function b64encodeNode(data) {
Buffer.from(data, 'base64');
}
var DomoticzApiConnector = /*#__PURE__*/function () {
function DomoticzApiConnector(options) {
_classCallCheck(this, DomoticzApiConnector);
_defineProperty(this, "hostname", '');
_defineProperty(this, "username", '');
_defineProperty(this, "password", '');
_defineProperty(this, "useSSL", void 0);
_defineProperty(this, "port", void 0);
_defineProperty(this, "endpoint", '');
this.hostname = options.hostname;
this.username = options.username != null ? options.username : '';
this.password = options.password != null ? options.password : '';
this.useSSL = options.useSSL != null ? options.useSSL : false;
this.port = options.port != null ? options.port : 80;
this.endpoint = this.url('json.htm');
}
_createClass(DomoticzApiConnector, [{
key: "url",
value: function url(uri) {
var proto = "http".concat(this.useSSL === true ? 's' : '', "://");
var host = this.hostname;
var port = this.port > 0 ? this.port : this.useSSL === true ? 443 : 80;
var username = this.username !== undefined ? b64encode(this.username) : '';
var password = this.password !== undefined ? b64encode(this.password) : '';
var credentials = "?username=".concat(username.toString(), "&password=").concat(password.toString());
return "".concat(proto).concat(host, ":").concat(port.toString(), "/").concat(uri).concat(credentials);
}
// DOMOTICZ NATIVE CALLS
}, {
key: "cameras",
value: function () {
var _cameras = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return this.domoticz({
type: 'cameras'
});
case 2:
return _context.abrupt("return", _context.sent);
case 3:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
function cameras() {
return _cameras.apply(this, arguments);
}
return cameras;
}()
}, {
key: "command",
value: function () {
var _command = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data, postData) {
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return this.domoticz(_objectSpread2({
type: 'command'
}, data), postData);
case 2:
return _context2.abrupt("return", _context2.sent);
case 3:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}));
function command(_x, _x2) {
return _command.apply(this, arguments);
}
return command;
}()
}, {
key: "hardware",
value: function () {
var _hardware = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return this.domoticz({
type: 'hardware'
});
case 2:
return _context3.abrupt("return", _context3.sent);
case 3:
case "end":
return _context3.stop();
}
}
}, _callee3, this);
}));
function hardware() {
return _hardware.apply(this, arguments);
}
return hardware;
}()
}, {
key: "devices",
value: function () {
var _devices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(data) {
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.next = 2;
return this.domoticz(_objectSpread2({
type: 'devices'
}, data));
case 2:
return _context4.abrupt("return", _context4.sent);
case 3:
case "end":
return _context4.stop();
}
}
}, _callee4, this);
}));
function devices(_x3) {
return _devices.apply(this, arguments);
}
return devices;
}()
}, {
key: "events",
value: function () {
var _events = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(data) {
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_context5.next = 2;
return this.domoticz(_objectSpread2({
type: 'events'
}, data));
case 2:
return _context5.abrupt("return", _context5.sent);
case 3:
case "end":
return _context5.stop();
}
}
}, _callee5, this);
}));
function events(_x4) {
return _events.apply(this, arguments);
}
return events;
}()
}, {
key: "notifications",
value: function () {
var _notifications = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(data) {
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
_context6.next = 2;
return this.domoticz(_objectSpread2({
type: 'notifications'
}, data));
case 2:
return _context6.abrupt("return", _context6.sent);
case 3:
case "end":
return _context6.stop();
}
}
}, _callee6, this);
}));
function notifications(_x5) {
return _notifications.apply(this, arguments);
}
return notifications;
}()
}, {
key: "scenes",
value: function () {
var _scenes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
_context7.next = 2;
return this.domoticz({
type: 'scenes'
});
case 2:
return _context7.abrupt("return", _context7.sent);
case 3:
case "end":
return _context7.stop();
}
}
}, _callee7, this);
}));
function scenes() {
return _scenes.apply(this, arguments);
}
return scenes;
}()
}, {
key: "setUsed",
value: function () {
var _setUsed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(data) {
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
_context8.next = 2;
return this.domoticz(_objectSpread2({
type: 'setUsed'
}, data));
case 2:
return _context8.abrupt("return", _context8.sent);
case 3:
case "end":
return _context8.stop();
}
}
}, _callee8, this);
}));
function setUsed(_x6) {
return _setUsed.apply(this, arguments);
}
return setUsed;
}()
}, {
key: "checkCredentials",
value: function () {
var _checkCredentials = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
_context9.next = 2;
return this.__generic('GET', "".concat(this.url('json.htm'), "&api-call"));
case 2:
return _context9.abrupt("return", _context9.sent);
case 3:
case "end":
return _context9.stop();
}
}
}, _callee9, this);
}));
function checkCredentials() {
return _checkCredentials.apply(this, arguments);
}
return checkCredentials;
}() // TOOLING
}, {
key: "get",
value: function () {
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(uri) {
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
while (1) {
switch (_context10.prev = _context10.next) {
case 0:
_context10.next = 2;
return this.__generic('GET', this.url("".concat(uri)));
case 2:
return _context10.abrupt("return", _context10.sent);
case 3:
case "end":
return _context10.stop();
}
}
}, _callee10, this);
}));
function get(_x7) {
return _get.apply(this, arguments);
}
return get;
}()
}, {
key: "domoticz",
value: function () {
var _domoticz = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(data, postData) {
var method;
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
while (1) {
switch (_context11.prev = _context11.next) {
case 0:
method = postData === undefined ? 'GET' : 'POST';
_context11.next = 3;
return this.__generic(method, this.endpoint.toString(), data, postData);
case 3:
return _context11.abrupt("return", _context11.sent);
case 4:
case "end":
return _context11.stop();
}
}
}, _callee11, this);
}));
function domoticz(_x8, _x9) {
return _domoticz.apply(this, arguments);
}
return domoticz;
}()
}, {
key: "login",
value: function () {
var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(username, password, rememberMe) {
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
while (1) {
switch (_context12.prev = _context12.next) {
case 0:
_context12.next = 2;
return this.__login(username, password, rememberMe);
case 2:
return _context12.abrupt("return", _context12.sent);
case 3:
case "end":
return _context12.stop();
}
}
}, _callee12, this);
}));
function login(_x10, _x11, _x12) {
return _login.apply(this, arguments);
}
return login;
}() // Want to write an new HTTP manager (other than fetch) just create a new
// DomoticzApiProvider[foobar].js and implement only this method.
// @ts-expect-error
}, {
key: "__generic",
value: function () {
var _generic = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(method, endpoint, data, content) {
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
while (1) {
switch (_context13.prev = _context13.next) {
case 0:
_context13.next = 2;
return new Promise(function () {
return null;
});
case 2:
return _context13.abrupt("return", _context13.sent);
case 3:
case "end":
return _context13.stop();
}
}
}, _callee13);
}));
function __generic(_x13, _x14, _x15, _x16) {
return _generic.apply(this, arguments);
}
return __generic;
}() // Not working everywhere because of CORS
// @ts-expect-error
}, {
key: "__login",
value: function () {
var _login2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(username, password, rememberMe) {
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
while (1) {
switch (_context14.prev = _context14.next) {
case 0:
_context14.next = 2;
return new Promise(function () {
return null;
});
case 2:
return _context14.abrupt("return", _context14.sent);
case 3:
case "end":
return _context14.stop();
}
}
}, _callee14);
}));
function __login(_x17, _x18, _x19) {
return _login2.apply(this, arguments);
}
return __login;
}()
}]);
return DomoticzApiConnector;
}();
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var md5$1 = {exports: {}};
/*
* JavaScript MD5
* https://github.com/blueimp/JavaScript-MD5
*
* Copyright 2011, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* https://opensource.org/licenses/MIT
*
* Based on
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for more info.
*/
(function (module) {
(function ($) {
/**
* Add integers, wrapping at 2^32.
* This uses 16-bit operations internally to work around bugs in interpreters.
*
* @param {number} x First integer
* @param {number} y Second integer
* @returns {number} Sum
*/
function safeAdd(x, y) {
var lsw = (x & 0xffff) + (y & 0xffff);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xffff)
}
/**
* Bitwise rotate a 32-bit number to the left.
*
* @param {number} num 32-bit number
* @param {number} cnt Rotation count
* @returns {number} Rotated number
*/
function bitRotateLeft(num, cnt) {
return (num << cnt) | (num >>> (32 - cnt))
}
/**
* Basic operation the algorithm uses.
*
* @param {number} q q
* @param {number} a a
* @param {number} b b
* @param {number} x x
* @param {number} s s
* @param {number} t t
* @returns {number} Result
*/
function md5cmn(q, a, b, x, s, t) {
return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b)
}
/**
* Basic operation the algorithm uses.
*
* @param {number} a a
* @param {number} b b
* @param {number} c c
* @param {number} d d
* @param {number} x x
* @param {number} s s
* @param {number} t t
* @returns {number} Result
*/
function md5ff(a, b, c, d, x, s, t) {
return md5cmn((b & c) | (~b & d), a, b, x, s, t)
}
/**
* Basic operation the algorithm uses.
*
* @param {number} a a
* @param {number} b b
* @param {number} c c
* @param {number} d d
* @param {number} x x
* @param {number} s s
* @param {number} t t
* @returns {number} Result
*/
function md5gg(a, b, c, d, x, s, t) {
return md5cmn((b & d) | (c & ~d), a, b, x, s, t)
}
/**
* Basic operation the algorithm uses.
*
* @param {number} a a
* @param {number} b b
* @param {number} c c
* @param {number} d d
* @param {number} x x
* @param {number} s s
* @param {number} t t
* @returns {number} Result
*/
function md5hh(a, b, c, d, x, s, t) {
return md5cmn(b ^ c ^ d, a, b, x, s, t)
}
/**
* Basic operation the algorithm uses.
*
* @param {number} a a
* @param {number} b b
* @param {number} c c
* @param {number} d d
* @param {number} x x
* @param {number} s s
* @param {number} t t
* @returns {number} Result
*/
function md5ii(a, b, c, d, x, s, t) {
return md5cmn(c ^ (b | ~d), a, b, x, s, t)
}
/**
* Calculate the MD5 of an array of little-endian words, and a bit length.
*
* @param {Array} x Array of little-endian words
* @param {number} len Bit length
* @returns {Array<number>} MD5 Array
*/
function binlMD5(x, len) {
/* append padding */
x[len >> 5] |= 0x80 << len % 32;
x[(((len + 64) >>> 9) << 4) + 14] = len;
var i;
var olda;
var oldb;
var oldc;
var oldd;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for (i = 0; i < x.length; i += 16) {
olda = a;
oldb = b;
oldc = c;
oldd = d;
a = md5ff(a, b, c, d, x[i], 7, -680876936);
d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
b = md5gg(b, c, d, a, x[i], 20, -373897302);
a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
d = md5hh(d, a, b, c, x[i], 11, -358537222);
c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
a = md5ii(a, b, c, d, x[i], 6, -198630844);
d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
a = safeAdd(a, olda);
b = safeAdd(b, oldb);
c = safeAdd(c, oldc);
d = safeAdd(d, oldd);
}
return [a, b, c, d]
}
/**
* Convert an array of little-endian words to a string
*
* @param {Array<number>} input MD5 Array
* @returns {string} MD5 string
*/
function binl2rstr(input) {
var i;
var output = '';
var length32 = input.length * 32;
for (i = 0; i < length32; i += 8) {
output += String.fromCharCode((input[i >> 5] >>> i % 32) & 0xff);
}
return output
}
/**
* Convert a raw string to an array of little-endian words
* Characters >255 have their high-byte silently ignored.
*
* @param {string} input Raw input string
* @returns {Array<number>} Array of little-endian words
*/
function rstr2binl(input) {
var i;
var output = [];
output[(input.length >> 2) - 1] = undefined;
for (i = 0; i < output.length; i += 1) {
output[i] = 0;
}
var length8 = input.length * 8;
for (i = 0; i < length8; i += 8) {
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << i % 32;
}
return output
}
/**
* Calculate the MD5 of a raw string
*
* @param {string} s Input string
* @returns {string} Raw MD5 string
*/
function rstrMD5(s) {
return binl2rstr(binlMD5(rstr2binl(s), s.length * 8))
}
/**
* Calculates the HMAC-MD5 of a key and some data (raw strings)
*
* @param {string} key HMAC key
* @param {string} data Raw input string
* @returns {string} Raw MD5 string
*/
function rstrHMACMD5(key, data) {
var i;
var bkey = rstr2binl(key);
var ipad = [];
var opad = [];
var hash;
ipad[15] = opad[15] = undefined;
if (bkey.length > 16) {
bkey = binlMD5(bkey, key.length * 8);
}
for (i = 0; i < 16; i += 1) {
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5c5c5c5c;
}
hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
return binl2rstr(binlMD5(opad.concat(hash), 512 + 128))
}
/**
* Convert a raw string to a hex string
*
* @param {string} input Raw input string
* @returns {string} Hex encoded string
*/
function rstr2hex(input) {
var hexTab = '0123456789abcdef';
var output = '';
var x;
var i;
for (i = 0; i < input.length; i += 1) {
x = input.charCodeAt(i);
output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f);
}
return output
}
/**
* Encode a string as UTF-8
*
* @param {string} input Input string
* @returns {string} UTF8 string
*/
function str2rstrUTF8(input) {
return unescape(encodeURIComponent(input))
}
/**
* Encodes input string as raw MD5 string
*
* @param {string} s Input string
* @returns {string} Raw MD5 string
*/
function rawMD5(s) {
return rstrMD5(str2rstrUTF8(s))
}
/**
* Encodes input string as Hex encoded string
*
* @param {string} s Input string
* @returns {string} Hex encoded string
*/
function hexMD5(s) {
return rstr2hex(rawMD5(s))
}
/**
* Calculates the raw HMAC-MD5 for the given key and data
*
* @param {string} k HMAC key
* @param {string} d Input string
* @returns {string} Raw MD5 string
*/
function rawHMACMD5(k, d) {
return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d))
}
/**
* Calculates the Hex encoded HMAC-MD5 for the given key and data
*
* @param {string} k HMAC key
* @param {string} d Input string
* @returns {string} Raw MD5 string
*/
function hexHMACMD5(k, d) {
return rstr2hex(rawHMACMD5(k, d))
}
/**
* Calculates MD5 value for a given string.
* If a key is provided, calculates the HMAC-MD5 value.
* Returns a Hex encoded string unless the raw argument is given.
*
* @param {string} string Input string
* @param {string} [key] HMAC key
* @param {boolean} [raw] Raw output switch
* @returns {string} MD5 output
*/
function md5(string, key, raw) {
if (!key) {
if (!raw) {
return hexMD5(string)
}
return rawMD5(string)
}
if (!raw) {
return hexHMACMD5(key, string)
}
return rawHMACMD5(key, string)
}
if (module.exports) {
module.exports = md5;
} else {
$.md5 = md5;
}
})(commonjsGlobal);
} (md5$1));
var md5 = md5$1.exports;
var DomoticzApiFetch = /*#__PURE__*/function (_DomoticzApiConnector) {
_inherits(DomoticzApiFetch, _DomoticzApiConnector);
var _super = _createSuper(DomoticzApiFetch);
function DomoticzApiFetch() {
_classCallCheck(this, DomoticzApiFetch);
return _super.apply(this, arguments);
}
_createClass(DomoticzApiFetch, [{
key: "__generic",
value: function () {
var _generic = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(method, endpoint, data, content) {
var uriParams, options, url, result;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
uriParams = data !== undefined ? dataToURI(data) : '';
options = {
method: method,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: content !== undefined ? JSON.stringify(content) : null
};
url = "".concat(endpoint).concat(uriParams);
console.log(url, options);
_context.next = 6;
return fetch(url, options);
case 6:
result = _context.sent;
_context.next = 9;
return result.json();
case 9:
return _context.abrupt("return", _context.sent);
case 10:
case "end":
return _context.stop();
}
}
}, _callee);
}));
function __generic(_x, _x2, _x3, _x4) {
return _generic.apply(this, arguments);
}
return __generic;
}()
}, {
key: "__login",
value: function () {
var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(username, password, rememberMe) {
var url, options, result;
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
url = 'json.htm?type=command¶m=logincheck';
options = {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: JSON.stringify({
username: encodeURIComponent(btoa(username)),
password: encodeURIComponent(md5(password)),
rememberme: rememberMe
})
};
_context2.next = 4;
return fetch(url, options);
case 4:
result = _context2.sent;
_context2.next = 7;
return result.json();
case 7:
return _context2.abrupt("return", _context2.sent);
case 8:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
function __login(_x5, _x6, _x7) {
return _login.apply(this, arguments);
}
return __login;
}()
}]);
return DomoticzApiFetch;
}(DomoticzApiConnector);
function dataToURI(data) {
return Object.entries(data).reduce(function (uri, _ref) {
var _ref2 = _slicedToArray(_ref, 2),
key = _ref2[0],
value = _ref2[1];
var valueStr = castToString(value);
return "".concat(uri, "&").concat(encodeURI(key), "=").concat(encodeURI(valueStr));
}, '');
}
function castToString(value) {
if (typeof value === 'string') return value;
if (typeof value === 'boolean') return value ? 'true' : 'false';
if (typeof value === 'number') return '' + value.toString();
return '';
}
var EDZ_COMMAND_PARAM;
(function (EDZ_COMMAND_PARAM) {
EDZ_COMMAND_PARAM["ADD_CAMERA"] = "addcamera";
EDZ_COMMAND_PARAM["ADD_LOG_MESSAGE"] = "addlogmessage";
EDZ_COMMAND_PARAM["ADD_SCENE_DEVICE"] = "addscenedevice";
EDZ_COMMAND_PARAM["ADD_SCENE_TIMER"] = "addscenetimer";
EDZ_COMMAND_PARAM["ADD_SCENE_CODE"] = "addscenecode";
EDZ_COMMAND_PARAM["ADD_HARDWARE"] = "addhardware";
EDZ_COMMAND_PARAM["ADD_TIMER_PLAN"] = "addtimerplan";
EDZ_COMMAND_PARAM["ADD_TIMER"] = "addtimer";
EDZ_COMMAND_PARAM["ADD_USER_VARIABLE"] = "adduservariable";
EDZ_COMMAND_PARAM["ADD_NOTIFICATION"] = "addnotification";
EDZ_COMMAND_PARAM["ALLOW_NEW_HARDWARE"] = "allownewhardware";
EDZ_COMMAND_PARAM["APPLY_ZWAVE_NODE_CONFIG"] = "applyzwavenodeconfig";
EDZ_COMMAND_PARAM["CLEAR_LIGHT_LOG"] = "clearlightlog";
EDZ_COMMAND_PARAM["CLEAR_TIMER"] = "cleartimers";
EDZ_COMMAND_PARAM["CLEAR_NOTIFICATIONS"] = "clearnotifications";
EDZ_COMMAND_PARAM["DEVICE_LIST"] = "device_list";
EDZ_COMMAND_PARAM["DELETE_SCENE_DEVICE"] = "deletescenedevice";
EDZ_COMMAND_PARAM["DELETE_HARDWARE"] = "deletehardware";
EDZ_COMMAND_PARAM["DELETE_DATA_POINT"] = "deletedatapoint";
EDZ_COMMAND_PARAM["DELETE_DATE_RANGE"] = "deletedaterange";
EDZ_COMMAND_PARAM["DELETE_TIMER"] = "deletetimer";
EDZ_COMMAND_PARAM["DELETE_SETPOINT_TIMER"] = "deletesetpointtimer";
EDZ_COMMAND_PARAM["DELETE_SCENE_TIMER"] = "deletescenetimer";
EDZ_COMMAND_PARAM["DELETE_NOTIFICATION"] = "deletenotification";
EDZ_COMMAND_PARAM["DUPLICATE_TIMER_PLAN"] = "duplicatetimerplan";
EDZ_COMMAND_PARAM["DISABLE_TIMER"] = "disabletimer";
EDZ_COMMAND_PARAM["DISABLE_SETPOINT_TIMER"] = "disablesetpointtimer";
EDZ_COMMAND_PARAM["DISABLE_SCENE_TIMER"] = "disablescenetimer";
EDZ_COMMAND_PARAM["ENABLE_TIMER"] = "enabletimer";
EDZ_COMMAND_PARAM["ENABLE_SETPOINT_TIMER"] = "enablesetpointtimer";
EDZ_COMMAND_PARAM["ENABLE_SCENE_TIMER"] = "enablescenetimer";
EDZ_COMMAND_PARAM["EMAIL_CAMERA_SNAPSHOP"] = "emailcamerasnapshot";
EDZ_COMMAND_PARAM["GET_LOG"] = "getlog";
EDZ_COMMAND_PARAM["GET_LIGHT_SWITCHES"] = "getlightswitches";
EDZ_COMMAND_PARAM["GET_PLAN_DEVICES"] = "getplandevices";
EDZ_COMMAND_PARAM["GET_SCENE_ACTIVATIONS"] = "getsceneactivations";
EDZ_COMMAND_PARAM["GET_SCENE_DEVICES"] = "getscenedevices";
EDZ_COMMAND_PARAM["GET_SECURITY_STATUS"] = "getsecstatus";
EDZ_COMMAND_PARAM["GET_SERVER_TIME"] = "getServerTime";
EDZ_COMMAND_PARAM["GET_SUNRISE_SUNSET"] = "getSunRiseSet";
EDZ_COMMAND_PARAM["GET_TIMER_PLANS"] = "gettimerplans";
EDZ_COMMAND_PARAM["GET_USER_VARIABLES"] = "getuservariables";
EDZ_COMMAND_PARAM["GET_VERSION"] = "getversion";
EDZ_COMMAND_PARAM["GET_NOTIFICATION_TYPES"] = "getnotificationtypes";
EDZ_COMMAND_PARAM["LMS_MEDIA_COMMAND"] = "lmsmediacommand";
EDZ_COMMAND_PARAM["KODI_MEDIA_COMMAND"] = "kodimediacommand";
EDZ_COMMAND_PARAM["RENAME_DEVICE"] = "renamedevice";
EDZ_COMMAND_PARAM["SET_ACTIVE_TIMER_PLAN"] = "setactivetimerplan";
EDZ_COMMAND_PARAM["SET_COLOR_BRIGHTNESS_VALUE"] = "setcolbrightnessvalue";
EDZ_COMMAND_PARAM["SET_DEVICE_USED"] = "setdevused";
EDZ_COMMAND_PARAM["SET_KELVIN_LEVEL"] = "setkelvinlevel";
EDZ_COMMAND_PARAM["SET_SETPOINT"] = "setsetpoint";
EDZ_COMMAND_PARAM["SEND_NOTIFICATION"] = "sendnotification";
EDZ_COMMAND_PARAM["SUN_WIND_ENABLE"] = "EnableSunWind";
EDZ_COMMAND_PARAM["SUN_WIND_DISABLE"] = "DisableSunWind";
EDZ_COMMAND_PARAM["SWITCH"] = "switch";
EDZ_COMMAND_PARAM["SWITCH_SCENE"] = "switchscene";
EDZ_COMMAND_PARAM["SWITCH_LIGHT"] = "switchlight";
EDZ_COMMAND_PARAM["SWITCH_MODAL"] = "switchmodal";
EDZ_COMMAND_PARAM["SYSTEM_REBOOT"] = "system_reboot";
EDZ_COMMAND_PARAM["SYSTEM_SHUTDOWN"] = "system_shutdown";
EDZ_COMMAND_PARAM["TRIGGER_CUSTOM_EVENT"] = "customevent";
EDZ_COMMAND_PARAM["UPDATE_CAMERA"] = "updatecamera";
EDZ_COMMAND_PARAM["UPDATE_DEVICE"] = "udevice";
EDZ_COMMAND_PARAM["UPDATE_SCENE"] = "updatescene";
EDZ_COMMAND_PARAM["UPDATE_HARDWARE"] = "updatehardware";
EDZ_COMMAND_PARAM["UPDATE_USER_VARIABLE"] = "updateuservariable";
EDZ_COMMAND_PARAM["UPDATE_TIMER_PLAN"] = "updatetimerplan";
EDZ_COMMAND_PARAM["UPDATE_TIMER"] = "updatetimer";
EDZ_COMMAND_PARAM["UPDATE_NOTIFICATION"] = "updatenotification";
EDZ_COMMAND_PARAM["VACCUM_DATABASE"] = "vaccumdatabase";
EDZ_COMMAND_PARAM["ZWAVE_BATTERY_LEVELS"] = "zwavegetbatterylevels";
EDZ_COMMAND_PARAM["GET_DEVICE_VALUE_OPTIONS"] = "getdevicevalueoptions";
EDZ_COMMAND_PARAM["LOGOUT"] = "dologout";
EDZ_COMMAND_PARAM["GET_UPTIME"] = "GetUptime";
EDZ_COMMAND_PARAM["MAKE_FAVORITE"] = "makefavorite";
EDZ_COMMAND_PARAM["GET_DEVICES"] = "devices";
EDZ_COMMAND_PARAM["LOGIN_CHECK"] = "logincheck";
})(EDZ_COMMAND_PARAM || (EDZ_COMMAND_PARAM = {}));
var EDZ_DAY;
(function (EDZ_DAY) {
EDZ_DAY[EDZ_DAY["EVERYDAY"] = 128] = "EVERYDAY";
EDZ_DAY[EDZ_DAY["WEEKDAYS"] = 256] = "WEEKDAYS";
EDZ_DAY[EDZ_DAY["WEEKENDS"] = 512] = "WEEKENDS";
EDZ_DAY[EDZ_DAY["MONDAY"] = 1] = "MONDAY";
EDZ_DAY[EDZ_DAY["TUESDAY"] = 2] = "TUESDAY";
EDZ_DAY[EDZ_DAY["WEDNESDAY"] = 4] = "WEDNESDAY";
EDZ_DAY[EDZ_DAY["THURSDAY"] = 8] = "THURSDAY";
EDZ_DAY[EDZ_DAY["FRIDAY"] = 16] = "FRIDAY";
EDZ_DAY[EDZ_DAY["SATURDAY"] = 32] = "SATURDAY";
EDZ_DAY[EDZ_DAY["SUNDAY"] = 64] = "SUNDAY";
})(EDZ_DAY || (EDZ_DAY = {}));
var EDZ_DEVICE;
(function (EDZ_DEVICE) {
EDZ_DEVICE["LIGHT"] = "light";
EDZ_DEVICE["WEATHER"] = "weather";
EDZ_DEVICE["TEMP"] = "temp";
EDZ_DEVICE["UTILITY"] = "utility";
EDZ_DEVICE["WIND"] = "wind";
EDZ_DEVICE["RAIN"] = "rain";
EDZ_DEVICE["UV"] = "uv";
EDZ_DEVICE["BARO"] = "baro";
EDZ_DEVICE["ZWAVEALARM"] = "zwavealarm";
EDZ_DEVICE["ALL"] = "all";
})(EDZ_DEVICE || (EDZ_DEVICE = {}));
var EDZ_DEVICE_HUMIDITY;
(function (EDZ_DEVICE_HUMIDITY) {
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["HEAVY_SNOW"] = 0] = "HEAVY_SNOW";
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["SNOW"] = 1] = "SNOW";
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["HEAVY_RAIN"] = 2] = "HEAVY_RAIN";
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["RAIN"] = 3] = "RAIN";
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["CLOUDY"] = 4] = "CLOUDY";
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["SOME_CLOUDS"] = 5] = "SOME_CLOUDS";
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["SUNNY"] = 6] = "SUNNY";
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["UNKNOWN"] = 7] = "UNKNOWN";
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["UNSTABLE"] = 8] = "UNSTABLE";
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["STABLE"] = 9] = "STABLE";
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["GENERAL_STABLE"] = 0] = "GENERAL_STABLE";
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["GENERAL_SUNNY"] = 1] = "GENERAL_SUNNY";
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["GENERAL_CLOUDY"] = 2] = "GENERAL_CLOUDY";
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["GENERAL_UNSABLE"] = 3] = "GENERAL_UNSABLE";
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["GENERAL_THUNDERSTORM"] = 4] = "GENERAL_THUNDERSTORM";
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["GENERAL_UNKNOWN"] = 5] = "GENERAL_UNKNOWN";
EDZ_DEVICE_HUMIDITY[EDZ_DEVICE_HUMIDITY["GENERAL_CLOUDY_RAIN"] = 6] = "GENERAL_CLOUDY_RAIN";
})(EDZ_DEVICE_HUMIDITY || (EDZ_DEVICE_HUMIDITY = {}));
var EDZ_EVOHOME_ACTIONS;
(function (EDZ_EVOHOME_ACTIONS) {
EDZ_EVOHOME_ACTIONS[EDZ_EVOHOME_ACTIONS["RUN_ON_SCRIPT"] = 1] = "RUN_ON_SCRIPT";
EDZ_EVOHOME_ACTIONS[EDZ_EVOHOME_ACTIONS["DISABLE"] = 0] = "DISABLE";
})(EDZ_EVOHOME_ACTIONS || (EDZ_EVOHOME_ACTIONS = {}));
var EDZ_EVOHOME_OOC;
(function (EDZ_EVOHOME_OOC) {
EDZ_EVOHOME_OOC[EDZ_EVOHOME_OOC["ON_CHANGE"] = 1] = "ON_CHANGE";
EDZ_EVOHOME_OOC[EDZ_EVOHOME_OOC["ALWAYS"] = 0] = "ALWAYS";
})(EDZ_EVOHOME_OOC || (EDZ_EVOHOME_OOC = {}));
var EDZ_EVOHOME_STATUS;
(function (EDZ_EVOHOME_STATUS) {
EDZ_EVOHOME_STATUS["AUTO"] = "Auto";
EDZ_EVOHOME_STATUS["AUTO_WITH_RESET"] = "AutoWithReset";
EDZ_EVOHOME_STATUS["AUTO_WITH_ECO"] = "AutoWithEco";
EDZ_EVOHOME_STATUS["AWAY"] = "Away";
EDZ_EVOHOME_STATUS["DAY_OFF"] = "DayOff";
EDZ_EVOHOME_STATUS["CUSTOM"] = "Custom";
EDZ_EVOHOME_STATUS["HEATING_OFF"] = "HeatingOff";
})(EDZ_EVOHOME_STATUS || (EDZ_EVOHOME_STATUS = {}));
var EDZ_HUMIDITY;
(function (EDZ_HUMIDITY) {
EDZ_HUMIDITY[EDZ_HUMIDITY["NORMAL"] = 1] = "NORMAL";
EDZ_HUMIDITY[EDZ_HUMIDITY["CONFORTABLE"] = 2] = "CONFORTABLE";
EDZ_HUMIDITY[EDZ_HUMIDITY["DRY"] = 3] = "DRY";
EDZ_HUMIDITY[EDZ_HUMIDITY["WET"] = 4] = "WET";
})(EDZ_HUMIDITY || (EDZ_HUMIDITY = {}));
var EDZ_LOG_LEVEL;
(function (EDZ_LOG_LEVEL) {
EDZ_LOG_LEVEL[EDZ_LOG_LEVEL["NORMAL"] = 1] = "NORMAL";
EDZ_LOG_LEVEL[EDZ_LOG_LEVEL["STATUS"] = 2] = "STATUS";
EDZ_LOG_LEVEL[EDZ_LOG_LEVEL["ERROR"] = 4] = "ERROR";
EDZ_LOG_LEVEL[EDZ_LOG_LEVEL["ALL"] = 268435455] = "ALL";
})(EDZ_LOG_LEVEL || (EDZ_LOG_LEVEL = {}));
var EDZ_NOTIFICATOR;
(function (EDZ_NOTIFICATOR) {
EDZ_NOTIFICATOR["FCM"] = "fcm";
EDZ_NOTIFICATOR["HTTP"] = "http";
EDZ_NOTIFICATOR["KODI"] = "kodi";
EDZ_NOTIFICATOR["LMS"] = "lms";
EDZ_NOTIFICATOR["NMA"] = "nma";
EDZ_NOTIFICATOR["PROWL"] = "prowl";
EDZ_NOTIFICATOR["PUSHALOT"] = "pushalot";
EDZ_NOTIFICATOR["PUSHBULLET"] = "pushbullet";
EDZ_NOTIFICATOR["PUSHOVER"] = "pushover";
EDZ_NOTIFICATOR["PUSHSAFER"] = "pushsafer";
})(EDZ_NOTIFICATOR || (EDZ_NOTIFICATOR = {}));
var EDZ_SECURITY_STATUS;
(function (EDZ_SECURITY_STATUS) {
EDZ_SECURITY_STATUS[EDZ_SECURITY_STATUS["DISARMED"] = 0] = "DISARMED";
EDZ_SECURITY_STATUS[EDZ_SECURITY_STATUS["ARM_HOME"] = 1] = "ARM_HOME";
EDZ_SECURITY_STATUS[EDZ_SECURITY_STATUS["ARM_AWAY"] = 2] = "ARM_AWAY";
EDZ_SECURITY_STATUS[EDZ_SECURITY_STATUS["UNKNOWN"] = 3] = "UNKNOWN";
})(EDZ_SECURITY_STATUS || (EDZ_SECURITY_STATUS = {}));
var EDZ_SUB_TYPE;
(function (EDZ_SUB_TYPE) {
EDZ_SUB_TYPE[EDZ_SUB_TYPE["ONOFF"] = 0] = "ONOFF";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["DOORBELL"] = 1] = "DOORBELL";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["CONTACT"] = 2] = "CONTACT";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["BLINDS"] = 3] = "BLINDS";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["X10_SIREN"] = 4] = "X10_SIREN";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["SMOKE_DETECTOR"] = 5] = "SMOKE_DETECTOR";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["BLINDS_INVERTED"] = 6] = "BLINDS_INVERTED";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["DIMMER"] = 7] = "DIMMER";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["MOTION_SENSOR"] = 8] = "MOTION_SENSOR";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["PUSH_ON_BUTTON"] = 9] = "PUSH_ON_BUTTON";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["PUSH_OFF_BUTTON"] = 10] = "PUSH_OFF_BUTTON";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["DOOR_CONTACT"] = 11] = "DOOR_CONTACT";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["DUSK_SENSOR"] = 12] = "DUSK_SENSOR";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["BLINDS_PERCENTAGE"] = 13] = "BLINDS_PERCENTAGE";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["VENETIAN_BLINDS_US"] = 14] = "VENETIAN_BLINDS_US";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["VENETIAN_BLINDS_EU"] = 15] = "VENETIAN_BLINDS_EU";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["BLINDS_PERCENTAGE_INVERTED"] = 16] = "BLINDS_PERCENTAGE_INVERTED";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["MEDIA_PLAYER"] = 17] = "MEDIA_PLAYER";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["SELECTOR"] = 18] = "SELECTOR";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["DOOR_LOCK"] = 19] = "DOOR_LOCK";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["DOOR_LOCK_INVERTED"] = 20] = "DOOR_LOCK_INVERTED";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["BLINDS_PERCENTAGE_WITH_STOP"] = 21] = "BLINDS_PERCENTAGE_WITH_STOP";
EDZ_SUB_TYPE[EDZ_SUB_TYPE["BLINDS_PERCENTAGE_WITH_STOP_INVERTED"] = 22] = "BLINDS_PERCENTAGE_WITH_STOP_INVERTED";
})(EDZ_SUB_TYPE || (EDZ_SUB_TYPE = {}));
var EDZ_SWITCH_COMMAND;
(function (EDZ_SWITCH_COMMAND) {
EDZ_SWITCH_COMMAND["ON"] = "On";
EDZ_SWITCH_COMMAND["OFF"] = "Off";
EDZ_SWITCH_COMMAND["TOGGLE"] = "Toggle";
EDZ_SWITCH_COMMAND["NORMAL"] = "Normal";
EDZ_SWITCH_COMMAND["STOP"] = "Stop";
EDZ_SWITCH_COMMAND["OPEN"] = "Open";
EDZ_SWITCH_COMMAND["CLOSE"] = "Close";
EDZ_SWITCH_COMMAND["SET_LEVEL"] = "Set Level";
})(EDZ_SWITCH_COMMAND || (EDZ_SWITCH_COMMAND = {}));
var EDZ_TIMER_TYPE;
(function (EDZ_TIMER_TYPE) {
EDZ_TIMER_TYPE[EDZ_TIMER_TYPE["BEFORE_SUNRISE"] = 0] = "BEFORE_SUNRISE";
EDZ_TIMER_TYPE[EDZ_TIMER_TYPE["AFTER_SUNRISE"] = 1] = "AFTER_SUNRISE";
EDZ_TIMER_TYPE[EDZ_TIMER_TYPE["ON_TIME"] = 2] = "ON_TIME";
EDZ_TIMER_TYPE[EDZ_TIMER_TYPE["BEFORE_SUNSET"] = 3] = "BEFORE_SUNSET";
EDZ_TIMER_TYPE[EDZ_TIMER_TYPE["AFTER_SUNSET"] = 4] = "AFTER_SUNSET";
EDZ_TIMER_TYPE[EDZ_TIMER_TYPE["FIXED_DATETIME"] = 5] = "FIXED_DATETIME";
})(EDZ_TIMER_TYPE || (EDZ_TIMER_TYPE = {}));
var EDZ_USER_VARIABLE;
(function (EDZ_USER_VARIABLE) {
EDZ_USER_VARIABLE[EDZ_USER_VARIABLE["INTEGER"] = 0] = "INTEGER";
EDZ_USER_VARIABLE[EDZ_USER_VARIABLE["FLOAT"] = 1] = "FLOAT";
EDZ_USER_VARIABLE[EDZ_USER_VARIABLE["STRING"] = 2] = "STRING";
EDZ_USER_VARIABLE[EDZ_USER_VARIABLE["DATE"] = 3] = "DATE";
EDZ_USER_VARIABLE[EDZ_USER_VARIABLE["TIME"] = 4] = "TIME";
})(EDZ_USER_VARIABLE || (EDZ_USER_VARIABLE = {}));
var DeviceManager = /*#__PURE__*/function () {
function DeviceManager(domoticzApi) {
_classCallCheck(this, DeviceManager);
_defineProperty(this, "domoticzApi", void 0);
this.domoticzApi = domoticzApi;
}
/**
* Get all devices, including the hidden ones
*/
_createClass(DeviceManager, [{
key: "items",
value: function () {
var _items = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
var devices;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return this.domoticzApi.devices({
used: true,
displayhidden: 1
});
case 2:
devices = _context.sent;
if (!((devices === null || devices === void 0 ? void 0 : devices.result) != null && devices.result !== undefined)) {
_context.next = 5;
break;
}
return _context.abrupt("return", devices.result);
case 5:
return _context.abrupt("return", []);
case 6:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
function items() {
return _items.apply(this, arguments);
}
return items;
}()
/**
* Get all devices idx, names, and statuses without details
* @returns
*/
}, {
key: "itemsList",
value: function () {
var _itemsList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
var devices;
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return this.domoticzApi.command({
param: EDZ_COMMAND_PARAM.GET_DEVICES
});
case 2:
devices = _context2.sent;
if (!((devices === null || devices === void 0 ? void 0 : devices.result) != null && devices.result !== undefined)) {
_context2.next = 5;
break;
}
return _context2.abrupt("return", devices.result);
case 5:
return _context2.abrupt("return", []);
case 6:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}));
function itemsList() {
return _itemsList.apply(this, arguments);
}
return itemsList;
}()
/**
* Get a specific device using the device identifier Idx
* @param {number} idx
*/
}, {
key: "getByIdx",
value: function () {
var _getByIdx = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(idx) {
var _device$result;
var device;
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return this.domoticzApi.devices({
rid: idx
});
case 2:
device = _context3.sent;
if (!((device === null || device === void 0 ? void 0 : device.result) != null && device.result !== undefined && ((_device$result = device.result) === null || _device$result === void 0 ? void 0 : _device$result.length) > 0)) {
_context3.next = 5;
break;
}
return _context3.abrupt("return", device.result[0]);
case 5:
return _context3.abrupt("return", null);
case 6:
case "end":
return _context3.stop();
}
}
}, _callee3, this);
}));
function getByIdx(_x) {
return _getByIdx.apply(this, arguments);
}
return getByIdx;
}()
/**
* Retrieve all devices of a specified type
* @param {EDZ_DEVICE} filter
* @param {string} orderBy
*/
}, {
key: "getByType",
value: function () {
var _getByType = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(filter) {
var orderBy,
devices,
_args4 = arguments;
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
orderBy = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : 'Name';
_context4.next = 3;
return this.domoticzApi.devices({
filter: filter,
used: true,
order: orderBy
});
case 3:
devices = _context4.sent;
if (!((devices === null || devices === void 0 ? void 0 : devices.result) != null && devices.result !== undefined)) {
_context4.next = 6;
break;
}
return _context4.abrupt("return", devices.result);
case 6:
return _context4.abrupt("return", []);
case 7:
case "end":
return _context4.stop();
}
}
}, _callee4, this);
}));
function getByType(_x2) {
return _getByType.apply(this, arguments);
}
return getByType;
}()
/**
* Return devices marked as *favorites*
*/
}, {
key: "getFavorites",
value: function () {
var _getFavorites = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
var devices;
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_context5.next = 2;
return this.domoticzApi.devices({
used: true,
filter: EDZ_DEVICE.ALL,
favorite: 1
});
case 2:
devices = _context5.sent;
if (!((devices === null || devices === void 0 ? void 0 : devices.result) != null && devices.result !== undefined)) {
_context5.next = 5;
break;
}
return _context5.abrupt("return", devices.result);
case 5:
return _context5.abrupt("return", []);
case 6:
case "end":
return _context5.stop();
}
}
}, _callee5, this);
}));
function getFavorites() {
return _getFavorites.apply(this, arguments);
}
return getFavorites;
}()
/**
* Action a Light/Switch
* @param {number} idx
* @param {EDZ_SWITCH_COMMAND} command "On|Off"
*/
}, {
key: "switch",
value: function () {
var _switch2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(idx) {
var command,
_args6 = arguments;
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
command = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : EDZ_SWITCH_COMMAND.ON;
_context6.next = 3;
return this.domoticzApi.command({
param: EDZ_COMMAND_PARAM.SWITCH_LIGHT,
idx: idx,
switchcmd: command
});
case 3:
return _context6.abrupt("return", _context6.sent);
case 4:
case "end":
return _context6.stop();
}
}
}, _callee6, this);
}));
function _switch(_x3) {
return _switch2.apply(this, arguments);
}
return _switch;
}()
/**
* Ask Domoticz to toggle a Light/Switch
* @param {number} idx
*/
}, {
key: "toggle",
value: function () {
var _toggle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(idx) {
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
_context7.next = 2;
return this.domoticzApi.command({
param: EDZ_COMMAND_PARAM.SWITCH_LIGHT,
idx: idx,
switchcmd: EDZ_SWITCH_COMMAND.TOGGLE
});
case 2:
return _context7.abrupt("return", _context7.sent);
case 3:
case "end":
return _context7.stop();
}
}
}, _callee7, this);
}));
function toggle(_x4) {
return _toggle.apply(this, arguments);
}
return toggle;
}()
/**
* Rename the device identified by idx
* @param {number} idx
* @param {string} name
*/
}, {
key: "rename",
value: function () {
var _rename = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(idx, name) {
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
_context8.next = 2;
return this.domoticzApi.command({
param: EDZ_COMMAND_PARAM.RENAME_DEVICE,
idx: idx,
name: name
});
case 2:
return _context8.abrupt("return", _context8.sent);
case 3:
case "end":
return _context8.stop();
}
}
}, _callee8, this);
}));
function rename(_x5, _x6) {
return _rename.apply(this, arguments);
}
return rename;
}()
/**
* Set/Remove the protection on a device identified by idx
* @param {number} idx
* @param {boolean} enable
*/
}, {
key: "protect",
value: function () {
var _protect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(idx) {
var enable,
_args9 = arguments;
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
enable = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : true;
_context9.next = 3;
return this.domoticzApi.setUsed({
used: true,
idx: idx,
"protected": enable
});
case 3:
return _context9.abrupt("return", _context9.sent);
case 4:
case "end":
return _context9.stop();
}
}
}, _callee9, this);
}));
function protect(_x7) {
return _protect.apply(this, arguments);
}
return protect;
}()
/**
* Set the new temperature
*
* @param {number} idx
* @param {number} temperature
* @returns
*/
}, {
key: "updateTemperature",
value: function () {
var _updateTemperature = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(idx, temperature) {
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
while (1) {
switch (_context10.prev = _context10.next) {
case 0:
_context10.next = 2;
return this.updateDevice(idx, temperature.toString());
case 2:
return _context10.abrupt("return", _context10.sent);
case 3:
case "end":
return _context10.stop();
}
}
}, _callee10, this);
}));
function updateTemperature(_x8, _x9) {
return _updateTemperature.apply(this, arguments);
}
return updateTemperature;
}()
/**
* Set the humidity datas of a device
*
* @param {number} idx Domoticz Device ID
* @param {number} humidityPercent Ex: 45
* @param {EDZ_HUMIDITY} humidityState [0: Normal, 1: Confortable, 2: Dry, 3: Wet]
* @returns
*/
}, {
key: "updateHumidity",
value: function () {
var _updateHumidity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(idx, humidityPercent, humidityState) {
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
while (1) {
switch (_context11.prev = _context11.next) {
case 0:
if (!(humidityPercent < 0 || humidityPercent > 100)) {
_context11.next = 2;
break;
}
return _context11.abrupt("return", null);
case 2:
if (!(humidityState < 0 || humidityState > 5)) {
_context11.next = 4;
break;
}
return _context11.abrupt("return", null);
case 4:
_context11.next = 6;
return this.updateDevice(idx, humidityState.toString(), humidityPercent.toString());
case 6:
return _context11.abrupt("return", _context11.sent);
case 7:
case "end":
return _context11.stop();
}
}
}, _callee11, this);
}));
function updateHumidity(_x10, _x11, _x12) {
return _updateHumidity.apply(this, arguments);
}
return updateHumidity;
}()
/**
* Set the barometer pressure and define the barometer forecast.
*
* @param {number} idx
* @param {int} barometer Atmospheric Pressure
* @param {deviceHumidityType} deviceHumidityType use a deviceHumidityGeneralType (if device.Type is 'General'), or deviceHumidityType otherwise.
*
* @returns
*/
}, {
key: "updateBarometer",
value: function () {
var _updateBarometer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(idx, barometer, deviceHumidityType) {
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
while (1) {
switch (_context12.prev = _context12.next) {
case 0:
_context12.next = 2;
return this.updateDevice(idx, "".concat(barometer.toString(), ";").concat(deviceHumidityType));
case 2:
return _context12.abrupt("return", _context12.sent);
case 3:
case "end":
return _context12.stop();
}
}
}, _callee12, this);
}));
function updateBarometer(_x13, _x14, _x15) {
return _updateBarometer.apply(this, arguments);
}
return updateBarometer;
}()
/**
* Generic update of a devices
*
* @param {number} idx
* @param {string} sValue
* @param {string} nValue
* @returns
*/
}, {
key: "updateDevice",
value: function () {
var _updateDevice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(idx, svalue) {
var nvalue,
_args13 = arguments;
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
while (1) {
switch (_context13.prev = _context13.next) {
case 0:
nvalue = _args13.length > 2 && _args13[2] !== undefined ? _args13[2] : '0';
_context13.next = 3;
return this.domoticzApi.command({
param: EDZ_COMMAND_PARAM.UPDATE_DEVICE,
idx: idx,
svalue: svalue,
nvalue: nvalue
});
case 3:
return _context13.abrupt("return", _context13.sent);
case 4:
case "end":
return _context13.stop();
}
}
}, _callee13, this);
}));
function updateDevice(_x16, _x17) {
return _updateDevice.apply(this, arguments);
}
return updateDevice;
}()
}]);
return DeviceManager;
}();
var CameraManager = /*#__PURE__*/function () {
function CameraManager(domoticzApi) {
_classCallCheck(this, CameraManager);
_defineProperty(this, "domoticzApi", void 0);
this.domoticzApi = domoticzApi;
}
/**
* Get all cameras informations
*/
_createClass(CameraManager, [{
key: "items",
value: function () {
var _items = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
var data;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return this.domoticzApi.cameras();
case 2:
data = _context.sent;
return _context.abrupt("return", data.result);
case 4:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
function items() {
return _items.apply(this, arguments);
}
return items;
}()
}]);
return CameraManager;
}();
var EventManager = /*#__PURE__*/function () {
function EventManager(domoticzApi) {
_classCallCheck(this, EventManager);
_defineProperty(this, "domoticzApi", void 0);
this.domoticzApi = domoticzApi;
}
/**
* Retrieve all Domoticz Events
*/
_createClass(EventManager, [{
key: "items",
value: function () {
var _items = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
var events;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return this.domoticzApi.events({
param: 'list'
});
case 2:
events = _context.sent;
if (!((events === null || events === void 0 ? void 0 : events.result) != null && events.result !== undefined)) {
_context.next = 5;
break;
}
return _context.abrupt("return", events.result);
case 5:
return _context.abrupt("return", []);
case 6:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
function items() {
return _items.apply(this, arguments);
}
return items;
}()
}]);
return EventManager;
}();
var SceneManager = /*#__PURE__*/function () {
function SceneManager(domoticzApi) {
_classCallCheck(this, SceneManager);
_defineProperty(this, "domoticzApi", void 0);
this.domoticzApi = domoticzApi;
}
/**
* Get all the Domoticz"s scenes
*/
_createClass(SceneManager, [{
key: "items",
value: function () {
var _items = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
var scenes;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return this.domoticzApi.scenes();
case 2:
scenes = _context.sent;
if (!((scenes === null || scenes === void 0 ? void 0 : scenes.result) != null && scenes.result !== undefined)) {
_context.next = 5;
break;
}
return _context.abrupt("return", scenes.result);
case 5:
return _context.abrupt("return", []);
case 6:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
function items() {
return _items.apply(this, arguments);
}
return items;
}()
/**
* Switch a state into a specific state
*
* @param {number} idx : Domoticz index of the device
* @param {EDZ_SWITCH_COMMAND} command : string of the state, ex: 'Off'
*/
}, {
key: "switch",
value: function () {
var _switch2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(idx, command) {
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return this.domoticzApi.command({
param: EDZ_COMMAND_PARAM.SWITCH,
idx: idx,
switchcmd: command
});
case 2:
return _context2.abrupt("return", _context2.sent);
case 3:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}));
function _switch(_x, _x2) {
return _switch2.apply(this, arguments);
}
return _switch;
}()
/**
* Toggle a device (ex: On/Off
*
* @param {number} idx : Domoticz index of the device
*/
}, {
key: "toggle",
value: function () {
var _toggle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(idx) {
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return this["switch"](idx, EDZ_SWITCH_COMMAND.TOGGLE);
case 2:
return _context3.abrupt("return", _context3.sent);
case 3:
case "end":
return _context3.stop();
}
}
}, _callee3, this);
}));
function toggle(_x3) {
return _toggle.apply(this, arguments);
}
return toggle;
}()
}]);
return SceneManager;
}();
var NotificationManager = /*#__PURE__*/function () {
function NotificationManager(domoticzApi) {
_classCallCheck(this, NotificationManager);
_defineProperty(this, "domoticzApi", void 0);
this.domoticzApi = domoticzApi;
}
/**
* Send a notification through Domoticz Notification API
* @param {string} subject
* @param {string} message
* @param {notificationType[]} subSystems
*/
_createClass(NotificationManager, [{
key: "send",
value: function () {
var _send = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(subject, message, subSystems) {
var options;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
options = {
param: EDZ_COMMAND_PARAM.SEND_NOTIFICATION,
subject: subject,
body: message
};
if (subSystems != null && subSystems.length > 0) {
options.subsystem = subSystems.reduce(function (str, item) {
return str + (str !== '' ? ';' : '') + item.toString();
}, '');
}
_context.next = 4;
return this.domoticzApi.command(options);
case 4:
return _context.abrupt("return", _context.sent);
case 5:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
function send(_x, _x2, _x3) {
return _send.apply(this, arguments);
}
return send;
}()
}]);
return NotificationManager;
}();
var SystemManager = /*#__PURE__*/function () {
function SystemManager(domoticzApi) {
_classCallCheck(this, SystemManager);
_defineProperty(this, "domoticzApi", void 0);
this.domoticzApi = domoticzApi;
}
/**
* Write a message into Domoticz Logs
* @param {String} message
*/
_createClass(SystemManager, [{
key: "log",
value: function () {
var _log = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(message) {
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return this.domoticzApi.command({
param: EDZ_COMMAND_PARAM.ADD_LOG_MESSAGE,
message: "DOMOTICZ API : ".concat(message)
});
case 2:
return _context.abrupt("return", _context.sent);
case 3:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
function log(_x) {
return _log.apply(this, arguments);
}
return log;
}()
/**
* Check Credentials
*/
}, {
key: "login",
value: function () {
var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(username, password, rememberMe) {
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return this.domoticzApi.login(username, password, rememberMe);
case 2:
return _context2.abrupt("return", _context2.sent);
case 3:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}));
function login(_x2, _x3, _x4) {
return _login.apply(this, arguments);
}
return login;
}()
/**
* Check Credentials
*/
}, {
key: "checkCredentials",
value: function () {
var _checkCredentials = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.prev = 0;
_context3.next = 3;
return this.domoticzApi.checkCredentials();
case 3:
return _context3.abrupt("return", true);
case 6:
_context3.prev = 6;
_context3.t0 = _context3["catch"](0);
return _context3.abrupt("return", false);
case 9:
case "end":
return _context3.stop();
}
}
}, _callee3, this, [[0, 6]]);
}));
function checkCredentials() {
return _checkCredentials.apply(this, arguments);
}
return checkCredentials;
}()
/**
* Check Security Status
*/
}, {
key: "securityStatus",
value: function () {
var _securityStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.next = 2;
return this.domoticzApi.command({
param: EDZ_COMMAND_PARAM.GET_SECURITY_STATUS
});
case 2:
return _context4.abrupt("return", _context4.sent);
case 3:
case "end":
return _context4.stop();
}
}
}, _callee4, this);
}));
function securityStatus() {
return _securityStatus.apply(this, arguments);
}
return securityStatus;
}()
/**
* Get various informations about the Domoticz Server
*/
}, {
key: "version",
value: function () {
var _version = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_context5.next = 2;
return this.domoticzApi.command({
param: EDZ_COMMAND_PARAM.GET_VERSION
});
case 2:
return _context5.abrupt("return", _context5.sent);
case 3:
case "end":
return _context5.stop();
}
}
}, _callee5, this);
}));
function version() {
return _version.apply(this, arguments);
}
return version;
}()
/**
* Get times (Local time, Sunset, Sunrise, etc.) from Domoticz Server
*/
}, {
key: "datetimes",
value: function () {
var _datetimes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
_context6.next = 2;
return this.domoticzApi.command({
param: EDZ_COMMAND_PARAM.GET_SUNRISE_SUNSET
});
case 2:
return _context6.abrupt("return", _context6.sent);
case 3:
case "end":
return _context6.stop();
}
}
}, _callee6, this);
}));
function datetimes() {
return _datetimes.apply(this, arguments);
}
return datetimes;
}()
/**
* Reboot Domoticz Server
*/
}, {
key: "reboot",
value: function () {
var _reboot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
_context7.next = 2;
return this.domoticzApi.command({
param: EDZ_COMMAND_PARAM.SYSTEM_REBOOT
});
case 2:
return _context7.abrupt("return", _context7.sent);
case 3:
case "end":
return _context7.stop();
}
}
}, _callee7, this);
}));
function reboot() {
return _reboot.apply(this, arguments);
}
return reboot;
}()
/**
* Shutdown the Domoticz Server
*/
}, {
key: "shutdown",
value: function () {
var _shutdown = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
_context8.next = 2;
return this.domoticzApi.command({
param: EDZ_COMMAND_PARAM.SYSTEM_SHUTDOWN
});
case 2:
return _context8.abrupt("return", _context8.sent);
case 3:
case "end":
return _context8.stop();
}
}
}, _callee8, this);
}));
function shutdown() {
return _shutdown.apply(this, arguments);
}
return shutdown;
}()
/**
* Start Database backup
*/
}, {
key: "db_backup",
value: function () {
var _db_backup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
_context9.next = 2;
return this.domoticzApi.get('backupdatabase.php');
case 2:
return _context9.abrupt("return", _context9.sent);
case 3:
case "end":
return _context9.stop();
}
}
}, _callee9, this);
}));
function db_backup() {
return _db_backup.apply(this, arguments);
}
return db_backup;
}()
/**
* Execute database cleanup
*/
}, {
key: "db_vaccum",
value: function () {
var _db_vaccum = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
while (1) {
switch (_context10.prev = _context10.next) {
case 0:
_context10.next = 2;
return this.domoticzApi.command({
param: EDZ_COMMAND_PARAM.VACCUM_DATABASE
});
case 2:
return _context10.abrupt("return", _context10.sent);
case 3:
case "end":
return _context10.stop();
}
}
}, _callee10, this);
}));
function db_vaccum() {
return _db_vaccum.apply(this, arguments);
}
return db_vaccum;
}()
}]);
return SystemManager;
}();
function useDomoticzApi(options) {
var domoticzApi = options.DomoticzApi === undefined ? new DomoticzApiFetch(options) : new options.DomoticzApi(options);
return {
cameraManager: new CameraManager(domoticzApi),
deviceManager: new DeviceManager(domoticzApi),
eventManager: new EventManager(domoticzApi),
notificationManager: new NotificationManager(domoticzApi),
sceneManager: new SceneManager(domoticzApi),
systemManager: new SystemManager(domoticzApi)
};
}
exports.CameraManager = CameraManager;
exports.DeviceManager = DeviceManager;
exports.DomoticzApiConnector = DomoticzApiConnector;
exports.EventManager = EventManager;
exports.NotificationManager = NotificationManager;
exports.SceneManager = SceneManager;
exports.SystemManager = SystemManager;
exports.useDomoticzApi = useDomoticzApi;