Skip to content

[Bug]: Falsche Warnung: Default value has to be stringified but received type "object" #2307

Closed

Description

@paul53

I'm sure that

  • This issue is still present in the current beta version of this adapter
  • There is no other (open) issue with the same topic (use the search!)
  • This issue is not described in the adapter documentation / FAQ (read the docs!)

Script type

Javascript

The problem

const idObj = '0_userdata.0.Test.neues_Objekt';

// erzeugt Warnung "Default value has to be stringified but received type "object" This will throw an error up from js-controller version 7.0.0!"
createState(idObj, {name: 'neues Objekt', type: 'object', read: true, write: true, def: {}});

// erzeugt keine Warnung:
createState(idObj, {name: 'neues Objekt', type: 'object', read: true, write: true}, function() {
    setState(idObj, {}, true);
});

iobroker.current.log (in debug mode!)

No response

Version of nodejs

22.23.1

Version of ioBroker js-controller

7.2.2

Version of adapter

9.0.18

Activity

  1. klein0r commented on Jul 21, 2026

    @klein0r
    Collaborator

    See

    It is possible short type of createState:
    - `createState('myDatapoint')` - simply create datapoint if it does not exist
    - `createState('myDatapoint', 1)` - create datapoint if it does not exist and initialize it with value 1
    - `createState('myDatapoint', { type: 'string', role: 'json', read: true, write: false }, () => { log('created'); });` - with common definitions like type, read, write and role
    - `createState('myDatapoint', { name: 'My own datapoint', unit: '°C' }, () => { log('created'); });`
    - `createState('myDatapoint', 1, { name: 'My own datapoint', unit: '°C' })` - create datapoint if it does not exist with specific name and units

    The second parameter is the initValue. The correct code would be

    createState(idObj, {}, {name: 'neues Objekt', type: 'object', read: true, write: true});

    But: Since the type is object, the second parameter will be interpreted as the object definition.

  2. paul53 commented on Jul 21, 2026

    @paul53
    ContributorAuthor

    Da der zweite Parameter im Falle eines Objekts als common interpretiert wird, muss man die Initialisierung per common.def vornehmen, was allerdings zu der gezeigten Warnung führt. Siehe Forum

  3. klein0r commented on Jul 21, 2026

    @klein0r
    Collaborator

    Ah, okay. Falsch verstanden. Ich hatte mich darauf fokussiert, dass diese Signatur in der Dokumentation aktuell gar nicht vorgesehen bzw. dokumentiert ist (ohne Callback).

  4. GermanBluefox commented on Aug 15, 2026

    @GermanBluefox
    Contributor

    I'm sure that

    • This issue is still present in the current beta version of this adapter[x] There is no other (open) issue with the same topic (use the search!)[x] This issue is not described in the adapter documentation / FAQ (read the docs!)

    Script type

    Javascript

    The problem

    const idObj = '0_userdata.0.Test.neues_Objekt';

    // erzeugt Warnung "Default value has to be stringified but received type "object" This will throw an error up from js-controller version 7.0.0!"
    createState(idObj, {name: 'neues Objekt', type: 'object', read: true, write: true, def: {}});

    // erzeugt keine Warnung:
    createState(idObj, {name: 'neues Objekt', type: 'object', read: true, write: true}, function() {
    setState(idObj, {}, true);
    });

    iobroker.current.log (in debug mode!)

    No response

    Version of nodejs

    22.23.1

    Version of ioBroker js-controller

    7.2.2

    Version of adapter

    9.0.18

    createState(idObj, {name: 'neues Objekt', type: 'object', read: true, write: true, def: '{}'});
    

    Die Objekte werden als string gespeichert. Deswegen def muss auch string sien

  5. added a commit that references this issue on Aug 15, 2026
  6. added a commit that references this issue on Aug 16, 2026
  7. added a commit that references this issue on Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions