NEWS
Adapterentwicklung/Funktion wird nicht ausgeführt
-
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 30801Eigentlich 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(); } -
Danke für die schnelle Hilfe. Klappt. Gut zu wissen das die Funktionen außerhalb der "class" definiert werden müssen. Ich hatte mich an den onUnload / onReady Methoden orientiert...
-
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 30801Eigentlich 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(); }
Hey! Du scheinst an dieser Unterhaltung interessiert zu sein, hast aber noch kein Konto.
Hast du es satt, bei jedem Besuch durch die gleichen Beiträge zu scrollen? Wenn du dich für ein Konto anmeldest, kommst du immer genau dorthin zurück, wo du zuvor warst, und kannst dich über neue Antworten benachrichtigen lassen (entweder per E-Mail oder Push-Benachrichtigung). Du kannst auch Lesezeichen speichern und Beiträge positiv bewerten, um anderen Community-Mitgliedern deine Wertschätzung zu zeigen.
Mit deinem Input könnte dieser Beitrag noch besser werden 💗
Registrieren Anmelden