Moin zusammen,
ich bin gerade dabei mich in die Adapter-Entwicklung einzuarbeiten. Ich starte mit einem ganz einfachen "scheduled" Test-Adapter. Soweit so gut. Leider wird meine Funktion queryHomeServer() nicht ausgeführt. Habe ich da ein Denk-Fehler??
home.0 2019-06-19 23:40:00.310 info config password: test1234
home.0 2019-06-19 23:40:00.310 info config email: 123@test.com
home.0 2019-06-19 23:40:00.302 info starting. Version 0.0.1 in /opt/iobroker/node_modules/iobroker.home, node: v8.16.0
home.0 2019-06-19 23:40:00.206 debug statesDB connected
home.0 2019-06-19 23:40:00.193 debug objectDB connected
host.iobrokerdev 2019-06-19 23:40:00.011 info instance system.adapter.home.0 started with pid 30801
Eigentlich sollte doch dann noch "entering queryHomeServer" ausgegeben werden und der Adapter beendet werden. Passiert aber nicht. Der Adapter bleibt im Speicher. Auch
this.log.debug("should never should reach this point. Exiting!")
this.stop(); // stop adapter right here (on schedule mode)
wird nicht erreicht
"use strict";
/*
* Created with @iobroker/create-adapter v1.15.1
*/
// The adapter-core module gives you access to the core ioBroker functions
// you need to create an adapter
const utils = require("@iobroker/adapter-core");
class Home extends utils.Adapter {
/**
* @param {Partial<ioBroker.AdapterOptions>} [options={}]
*/
constructor(options) {
super({
...options,
name: "home",
});
this.on("ready", this.onReady.bind(this));
this.on("unload", this.onUnload.bind(this));
}
/**
* Is called when databases are connected and adapter received configuration.
*/
async onReady() {
// Initialize your adapter here
// The adapters config (in the instance object everything under the attribute "native") is accessible via
// this.config:
this.log.info("config email: " + this.config.email);
this.log.info("config password: " + this.config.password);
if (!this.config.email) {
this.log.warn("email is empty. Exiting!");
this.stop();
} else if (!this.config.password) {
this.log.warn("password empty. Exiting!");
this.stop();
}
queryHomeServer();
this.log.debug("should never should reach this point. Exiting!")
this.stop(); // stop adapter right here (on schedule mode)
}
/**
* Is called when adapter shuts down - callback has to be called under any circumstances!
* @param {() => void} callback
*/
onUnload(callback) {
try {
this.log.info("cleaned everything up...");
callback();
} catch (e) {
callback();
}
}
/**
* queryHomeServer
*/
queryHomeServer() {
this.log.debug("entering queryHomeServer");
this.stop(); // stop adapter right here (on shedule mode)
}
}
// @ts-ignore parent is a valid property on module
if (module.parent) {
// Export the constructor in compact mode
/**
* @param {Partial<ioBroker.AdapterOptions>} [options={}]
*/
module.exports = (options) => new Home(options);
} else {
// otherwise start the instance directly
new Home();
}