Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Entwicklung
    4. Adapterentwicklung/Funktion wird nicht ausgeführt

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    Adapterentwicklung/Funktion wird nicht ausgeführt

    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      NemoN last edited by

      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();
      }
      
      
      AlCalzone 1 Reply Last reply Reply Quote 0
      • arteck
        arteck Developer Most Active last edited by

        setzte die klammer aus Zeile 72 auf Zeile 63..

        1 Reply Last reply Reply Quote 0
        • N
          NemoN last edited by

          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...

          Jey Cee 1 Reply Last reply Reply Quote 0
          • Jey Cee
            Jey Cee Developer @NemoN last edited by

            @NemoN sagte in Adapterentwicklung/Funktion wird nicht ausgeführt:

            Gut zu wissen das die Funktionen außerhalb der "class" definiert werden müssen.

            Nein müssen sie nicht, es geht auch innerhalb der Class.

            this.queryHomeServer()
            
            1 Reply Last reply Reply Quote 1
            • AlCalzone
              AlCalzone Developer @NemoN last edited by

              @NemoN queryHomeServer ist eine Instanz-Methode und muss daher wie log und stop mit this. aufgerufen werden.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post

              Support us

              ioBroker
              Community Adapters
              Donate

              786
              Online

              31.9k
              Users

              80.3k
              Topics

              1.3m
              Posts

              4
              5
              320
              Loading More Posts
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes
              Reply
              • Reply as topic
              Log in to reply
              Community
              Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
              The ioBroker Community 2014-2023
              logo