Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. [gelöst] DP mit CRON anlegen

    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

    [gelöst] DP mit CRON anlegen

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

      Moin

      Bitte nicht Steinigen, das ist mein erste Versuch mit JavaScript.
      Hatte auch was im Forum gefunden und versucht Anzupassen, aber leider ohne Erfolg.

      Denn ich möchte gern das am 31.12.xxxx um 23:00 Uhr ein Datenpunkt mit dem noch aktuellen Jahr angelegt wird.

      Der CRONJOB ist nicht das Problem.
      Die Einstellungen sind nur zur Probe.
      jahr.png

      Was mir nicht gelingt ist das JavaScript.
      Das ist der letzte Versuch.😊

      //
      const obj = {
         type: 'state',
         native: {},
         common: {
             type: Typ,
             name: formatDate(state.ts, "JJJJ") ,
             role: State
         }
      };
      
      //if(Default != undefined) obj.common.def = Default;
      const path = '0_userdata.0.';
      if(!existsObject(path + name)) setObject(path + name, obj);
      

      Im Log habe ich folgende Meldungen :

      host.IoB
      2024-01-28 17:40:01.121	error	Caught by controller[3]: at processImmediate (node:internal/timers:478:21)
      host.IoB
      2024-01-28 17:40:01.121	error	Caught by controller[3]: at Immediate.<anonymous> (/opt/iobroker/node_modules/iobroker.javascript/lib/scheduler.js:96:109)
      host.IoB
      2024-01-28 17:40:01.121	error	Caught by controller[3]: at Object.cb (script.js.14_Wäsche.AnzahlArchiv:24:9)
      host.IoB
      2024-01-28 17:40:01.121	error	Caught by controller[3]: at Alte_Jahr_wegschreiben (script.js.14_Wäsche.AnzahlArchiv:11:19)
      host.IoB
      2024-01-28 17:40:01.121	error	Caught by controller[3]: ReferenceError: Typ is not defined
      host.IoB
      2024-01-28 17:40:01.121	error	Caught by controller[3]: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
      host.IoB
      2024-01-28 17:40:01.121	error	Caught by controller[2]: at processImmediate (node:internal/timers:478:21)
      host.IoB
      2024-01-28 17:40:01.121	error	Caught by controller[2]: at Immediate.<anonymous> (/opt/iobroker/node_modules/iobroker.javascript/lib/scheduler.js:96:109)
      host.IoB
      2024-01-28 17:40:01.121	error	Caught by controller[2]: at Object.cb (script.js.14_Wäsche.AnzahlArchiv:24:9)
      host.IoB
      2024-01-28 17:40:01.121	error	Caught by controller[2]: at Alte_Jahr_wegschreiben (script.js.14_Wäsche.AnzahlArchiv:11:19)
      host.IoB
      2024-01-28 17:40:01.121	error	Caught by controller[2]: ReferenceError: Typ is not defined
      host.IoB
      2024-01-28 17:40:01.120	error	Caught by controller[1]: Typ is not defined
      host.IoB
      2024-01-28 17:40:01.120	error	Caught by controller[0]: at processImmediate (node:internal/timers:478:21)
      host.IoB
      2024-01-28 17:40:01.120	error	Caught by controller[0]: at Immediate.<anonymous> (/opt/iobroker/node_modules/iobroker.javascript/lib/scheduler.js:96:109)
      host.IoB
      2024-01-28 17:40:01.120	error	Caught by controller[0]: at Object.cb (script.js.14_Wäsche.AnzahlArchiv:24:9)
      host.IoB
      2024-01-28 17:40:01.120	error	Caught by controller[0]: at Alte_Jahr_wegschreiben (script.js.14_Wäsche.AnzahlArchiv:11:19)
      host.IoB
      2024-01-28 17:40:01.119	error	Caught by controller[0]: Uncaught Rejection: ReferenceError: Typ is not defined
      host.IoB.compactgroup1
      2024-01-28 17:40:00.615	warn	instance system.adapter.javascript.0 terminated due to 11
      
      javascript.0
      2024-01-28 17:40:00.030	error	(COMPACT) at processImmediate (node:internal/timers:478:21)
      
      javascript.0
      2024-01-28 17:40:00.030	error	(COMPACT) at Immediate.<anonymous> (/opt/iobroker/node_modules/iobroker.javascript/lib/scheduler.js:96:109)
      
      javascript.0
      2024-01-28 17:40:00.030	error	(COMPACT) at Object.cb (script.js.14_Wäsche.AnzahlArchiv:23:9)
      
      javascript.0
      2024-01-28 17:40:00.030	error	(COMPACT) at Alte_Jahr_wegschreiben (script.js.14_Wäsche.AnzahlArchiv:10:19)
      
      javascript.0
      2024-01-28 17:40:00.028	error	(COMPACT) script.js.14_Wäsche.AnzahlArchiv: ReferenceError: Typ is not defined
      

      Ist das Überhaut möglich was ich mir Denke. 😡

      paul53 1 Reply Last reply Reply Quote 0
      • paul53
        paul53 @ioBrokerMike last edited by

        @iobrokermike
        Du verwendest in common Variablenbezeichner (Typ, state.ts, State), die nirgends deklariert sind. Außerdem erstellt man Datenpunkte mit createState().

        createState('0_userdata.0.' + year, 0, {type: 'number', name: year, role: 'value'});
        

        Blockly_temp.JPG

        I 1 Reply Last reply Reply Quote 0
        • I
          ioBrokerMike @paul53 last edited by

          @paul53

          Vielen Dank 👍

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

          Support us

          ioBroker
          Community Adapters
          Donate

          982
          Online

          31.8k
          Users

          80.0k
          Topics

          1.3m
          Posts

          2
          3
          121
          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