ioBroker / ioBroker.simple-api

HTTP-API Interface to read and write objets and states
MIT License
40 stars 19 forks source link

get: "ts" is not state.ts #100

Closed paul53 closed 2 years ago

paul53 commented 2 years ago

Siehe Forum.

get liefert in "ts" anstelle von state.ts den Zeitpunkt vom Erstellen des Datenpunktes. "from" stimmt ebenfalls nicht.

Web-Adapter 3.4.16 Simple-API-Adapter 2.6.2

neo4a commented 2 years ago

Wrong value for object property .ts for objects located in 0_userdata.0

For objects in adapter nodes values for .ls and .lc are correct.

Simple-API-Adapter 2.6.1

Apollon77 commented 2 years ago

Sorry, but I do not get it ...

neo4a commented 2 years ago

In my first attempt I was only calling setState(dpAndreas, ! getState(dpAndreas).val) without ack-parameter. Then .lc-value in simple api request was never refreshed.

I updated my script by involving ack parameter and now it is working. (Background: I use a smart button and Alexa command to set status flags for updating several pc and tablet displays accordingly.) Thanks.

`const cSWAndreas = ["mihome.0.devices.switch_158d00018b46ff.click"];

const cDP = "0_userdata.0.Fitness.";

const dpAndreas = cDP + "Andreas.Click"; DoCreateObj(dpAndreas, {read: true, write: true, name: 'Andreas hat Taster gedrückt', desc: '', type: "boolean"});

on({id: cSWAndreas, val: true}, function (obj) { setState(dpAndreas, ! getState(dpAndreas).val, true); console.log('Andreas Click'); });`

http://192.168.178.26:8087/get/0_userdata.0.Fitness.Andreas.Click

{"val":true,"ack":true,"ts":1643206250223,"q":0,"c":"script.js.Andreas.Fitness.FitnessClock","from":"system.adapter.javascript.0","user":"system.user.admin","lc":1643206912616,"type":"state","common":{"read":true,"write":true,"name":"Andreas hat Taster gedrückt","desc":"","type":"boolean"},"_id":"0_userdata.0.Fitness.Andreas.Click","acl":{"object":1636,"state":1636,"owner":"system.user.admin","ownerGroup":"system.group.administrator"}}

Apollon77 commented 2 years ago

In fact "lc" is only checked if the value is changed, so assumption is that you do not really changed the value.

neo4a commented 2 years ago

In fact "lc" is only checked if the value is changed

That behavior differs from admin object tree where lc values is always updated even state value is not changed but touched.

Simple Api is following its own logic at this point :)

Apollon77 commented 2 years ago

No this is simply not true :-) The logic that checks this exactly reacts on a changed value and is in a very central place and has nothing to do with "reading" the value ... the "lc" is adjusted or reteined on "setState" ...

paul53 commented 2 years ago

@Apollon77 Schau mal in die simpleapi.js Zeilen 899 bis 904: Dort werden ts und from mit den Werten aus dem statischen Objekt überschrieben.

Apollon77 commented 2 years ago

@paul53 Ja deswegen ist der noch offen ... die "lc" diskussion ist ja eigentlich Themenfremd in dem issue :-) aber danke fürs pinpointen

Apollon77 commented 2 years ago

Please try GitHub version