You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following script from user drefree is returning "not found" in console, while documentation seems to allow an initial value as second parameter, and the common object as third parameter.
When providing initial value as "def" in common, callback and async/await is working fine without errors:
conststate123='0_userdata.0.test123';createState(state123,{name:'test variable',def:'test init',type:'string',read:true,write:true,role:'state'},(obj)=>{log(`Value of ${state123}: '${getState(state123).val}'`);})// Und noch Test per async/awaittest();asyncfunctiontest(){try{conststate456='0_userdata.0.test456';awaitcreateStateAsync(state456,{name:'test variable',type:'string',read:true,write:true,role:'state',def:'test init'});constr=awaitgetStateAsync(state456);log(`Value of ${state456}: '${r.val}'`);}catch(error){log(error.stack,'warn');}}
The text was updated successfully, but these errors were encountered:
Acgua
changed the title
getState()/getStateAsync() issue, if 2nd param = initial value, and 3rd param = common obj
createState()/createStateAsync() issue, if 2nd param = initial value, and 3rd param = common obj
Dec 15, 2021
Yes rthis can happen and if is a timing issue ... the create will trigger a "setState" internally but the "internal state array" is only filled when the state value is published which happens slightly async. So there is a chance that in the callback the state value publish is not yet received.
In fact we would need to set the value directly in the internal array directly and do not rely on publish
Describe the bug
Following script from user drefree is returning "not found" in console, while documentation seems to allow an initial value as second parameter, and the common object as third parameter.
When providing initial value as "def" in common, callback and async/await is working fine without errors:
See ioBroker Forum Thread for details.
To Reproduce
See code above.
Expected behavior
Callback / await is working, i.e. state is created once callback function called or await createStateAsync() is processed.
Screenshots & Logfiles
See above and ioBroker Forum Thread
Versions:
Additional context
See ioBroker Forum Thread
The text was updated successfully, but these errors were encountered: