Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creates tenthousands objects and states with withings.sleep #9

Open
Grizzelbee opened this issue Jun 7, 2022 · 25 comments
Open

creates tenthousands objects and states with withings.sleep #9

Grizzelbee opened this issue Jun 7, 2022 · 25 comments

Comments

@Grizzelbee
Copy link

Grizzelbee commented Jun 7, 2022

Had the adapter V0.0.6/V0.0.7 running for four month now with a single Nokia sleep (aka Withings Sleep Analyzer).
In that time the adapter created about 1.200 new objects and states per night.
This resulted in approx 150.000 objects and states as of today.

After deletion of the adapter and cleanup I had only: 19.172 objects and 17.005 states left.

I think the adapter needs a housekeeping routine or a general concept overhaul to avoid that. Especially since not all of these objects are accessable in the object tree.

@TA2k
Copy link
Owner

TA2k commented Jun 7, 2022

Can you provide a screenshot of the folder

@Grizzelbee
Copy link
Author

Grizzelbee commented Jun 7, 2022

Hmmm. Difficult!
Since I deleted everything to find this issue. And trying to restore the backup in my development environment destroyed the dev environment.
So I'll keep trying but can't promise.

Edit: Maybe I can extract the objects and states from the backup files directly. Would this be sufficient too?

Edit II:
Just took a look into the data by iob list objects and realized that most states are written by:

  • withings.0.28881994.sleep.series12.rr.xxx
  • withings.0.28881994.sleep.series12.hr.xxx
  • withings.0.28881994.sleep.series12.snoring.xxx
    often many hundrets per night and channel.

So in the end: running the adapter for approx. 120 nights with approx 1.400 states per night it would sum up to 168.000 states. Thats pretty close to what I'm facing.

Since I configured to retrieve the last 30 days I expected older values to be deleted. But in fact it dosen't seem to be the case.
I think it's not a good idea to use the objects and states file as a database for historization. It would be much better to clean up every day and retrieve only the last night and drop historic values to the database as it's ment to be. Or (even better) only provide the values that are delivered every day (like average values, durations (Minutes of snoring), ...). Since the datapoints change every day it's anyway not possible to use them in senseful way.
Another solution may be to create states like:

  • withings.0.28881994.sleep.lastNight.rr
  • withings.0.28881994.sleep.lastNight.hr
  • withings.0.28881994.sleep.lastNight.snoring
    and update them with every single value you reveived by the API. In that case the values can be stored in the database easily and used by any analysing tool.

@TA2k
Copy link
Owner

TA2k commented Jun 21, 2022

can you try the github version. Should now be sorted and series01 should have the most recent object

@Damrak2022
Copy link

Damrak2022 commented Jun 22, 2022

Das ist bei mir genauso, dass unfassbar viele Objekte angelegt werden. Ich habe jetzt die neue Github-Version geladen und meinen ganzen Verzeichnisbaum von Withings gelöscht, um neu zu werden.
Im Allgemeinen möchte ich meine Schlafdaten (mindestens 1 Jahr) ja über einen langen Zeitraum über Influx und Grafana darstellen. Wie sollte ich dann den Abruf bei dem Withings Adapter optimal einstellen? Damm müsste ja der Abruf 1 Tag und 24 Stunden im Schlaf reichen, da die Daten dann in der Influx sind, oder?
ch werde beobachten wie schnell sich ab heute wieder Objekte ansammeln.

@Grizzelbee
Copy link
Author

Grizzelbee commented Jun 22, 2022

@TA2k : What is your preferred language mon github? German or english?

I tested the github version over night and Objects increased by ~540 and states by ~1500.
If this still happens every night (and I expect that) it will soon be unusable.
Btw:
grafik

You create states for HR, RR, ... with a current value (I'm assuming). Are the state names (-> red rectangle) timestamps? If so - it's pretty impossible to write these values to a database to analyze/visulize them using grafana, float, VIS, ... , since it's impossible to react to constantly changing state names. In the end: You can't do anything with these data.

I think - what we really need here is a structure like:

sleep
+- hr
    +-- Heartrate              50 bpm
    +-- hr-timestamp       1555855520 (but as a readable timestamp please)
+- rr
    +-- r-rate                  12 
    +-- rr-timestamp       1555855520
+- snoring
...

And this structure needs to be updated with every value the API delivers (also if someone chooses to poll last xx nights from the API). And only the newest value stays in the object tree. Every older value needs to be stored in the database. That's the only way it makes sense. All the "seriesXX" stuff doesn't make any sense to me - it's not loggable.

@TA2k
Copy link
Owner

TA2k commented Jun 22, 2022

Danke für den Screenshot ich habs jetzt glaube verstanden
bitte alles unter sleep löschen und nochmal via github installieren

Wieviele timestamps kommen denn pro serie eintrag? Ich gehe zur zeit von einem aus

@Grizzelbee
Copy link
Author

Jetzt steht unter sleep praktisch nichts mehr (hatte den kompletten Baum gelöscht und nur das wurde neu angelegt).
grafik

In dem Zusammenhang ist mir auch aufgefallen, das das oben gesagte quasi genauso für die sleepSummary gilt. Für meinen Geschmack könnte man das zusammen legen.

Einheiten wären auch noch ein super Gewinn. Bei vielen Zahlen weiß man einfach nicht, wie man die interpretieren soll.
deepSleepDuration zum Beispiel. Sind das Sekunden, Minuten, ...?

Wie wird bei dem Adapter eigentlich die morgentliche Aktualisierung getriggert?

@TA2k
Copy link
Owner

TA2k commented Jun 22, 2022

Gibt es im log errors?

in der api finde ich dazu nichts zur aktualisierung
https://developer.withings.com/api-reference#operation/heartv2-get

@Grizzelbee
Copy link
Author

Grizzelbee commented Jun 22, 2022

Gibt es im log errors?

Nein. Keine Fehler - Zumindest nicht gerade. Das ist das gesammte current-log:

root@ganymed:~# cat /opt/iobroker/log/iobroker.2022-06-22.log | grep withings
2022-06-22 00:31:20.325  - error: withings.0 (2368559) https://wbsapi.withings.net/v2/sleep
2022-06-22 00:31:20.338  - error: withings.0 (2368559) TypeError: Cannot read property 'sort' of undefined
2022-06-22 00:31:20.456  - error: withings.0 (2368559) https://wbsapi.withings.net/v2/sleep
2022-06-22 00:31:20.457  - error: withings.0 (2368559) TypeError: Cannot read property 'sort' of undefined
2022-06-22 03:31:20.311  - error: withings.0 (2368559) https://wbsapi.withings.net/v2/sleep
2022-06-22 03:31:20.313  - error: withings.0 (2368559) TypeError: Cannot read property 'sort' of undefined
2022-06-22 03:31:20.420  - error: withings.0 (2368559) https://wbsapi.withings.net/v2/sleep
2022-06-22 03:31:20.420  - error: withings.0 (2368559) TypeError: Cannot read property 'sort' of undefined
2022-06-22 06:31:20.293  - error: withings.0 (2368559) https://wbsapi.withings.net/v2/sleep
2022-06-22 06:31:20.297  - error: withings.0 (2368559) TypeError: Cannot read property 'sort' of undefined
2022-06-22 06:31:20.408  - error: withings.0 (2368559) https://wbsapi.withings.net/v2/sleep
2022-06-22 06:31:20.409  - error: withings.0 (2368559) TypeError: Cannot read property 'sort' of undefined
2022-06-22 09:31:20.305  - error: withings.0 (2368559) https://wbsapi.withings.net/v2/sleep
2022-06-22 09:31:20.308  - error: withings.0 (2368559) TypeError: Cannot read property 'sort' of undefined
2022-06-22 09:31:20.431  - error: withings.0 (2368559) https://wbsapi.withings.net/v2/sleep
2022-06-22 09:31:20.431  - error: withings.0 (2368559) TypeError: Cannot read property 'sort' of undefined
2022-06-22 11:58:40.054  - info: host.ganymed "system.adapter.withings.0" disabled
2022-06-22 11:58:40.060  - info: host.ganymed stopInstance system.adapter.withings.0 (force=false, process=true)
2022-06-22 11:58:40.126  - info: withings.0 (2368559) Got terminate signal TERMINATE_YOURSELF
2022-06-22 11:58:40.133  - info: withings.0 (2368559) terminating
2022-06-22 11:58:40.134  - info: withings.0 (2368559) Terminated (ADAPTER_REQUESTED_TERMINATION): Without reason
2022-06-22 11:58:40.153  - info: host.ganymed stopInstance system.adapter.withings.0 send kill signal
2022-06-22 11:58:40.706  - info: host.ganymed instance system.adapter.withings.0 terminated with code 11 (ADAPTER_REQUESTED_TERMINATION)
2022-06-22 11:59:43.829  - info: host.ganymed iobroker url TA2k/ioBroker.withings --host ganymed
2022-06-22 11:59:44.568  - info: host.ganymed iobroker install TA2k/ioBroker.withings
2022-06-22 11:59:44.749  - info: host.ganymed iobroker Installing TA2k/ioBroker.withings... (System call)
2022-06-22 12:04:14.966  - info: host.ganymed iobroker + [email protected] 1 package in 269.797s
2022-06-22 12:04:15.575  - info: host.ganymed iobroker upload [3] withings.admin /opt/iobroker/node_modules/iobroker.withings/admin/index_m.html index_m.html text/html
2022-06-22 12:04:15.617  - info: host.ganymed iobroker upload [2] withings.admin /opt/iobroker/node_modules/iobroker.withings/admin/style.css style.css text/css
2022-06-22 12:04:15.622  - info: host.ganymed iobroker upload [1] withings.admin /opt/iobroker/node_modules/iobroker.withings/admin/withings.png withings.png image/png
2022-06-22 12:04:15.626  - info: host.ganymed iobroker upload [0] withings.admin /opt/iobroker/node_modules/iobroker.withings/admin/words.js words.js application/javascript
2022-06-22 12:04:15.661  - info: host.ganymed iobroker Update "system.adapter.withings.0"
2022-06-22 12:16:18.282  - info: host.ganymed "system.adapter.withings.0" enabled
2022-06-22 12:16:18.406  - info: host.ganymed instance system.adapter.withings.0 started with pid 196616
2022-06-22 12:16:19.541  - info: withings.0 (196616) starting. Version 0.0.7 (non-npm: TA2k/ioBroker.withings) in /opt/iobroker/node_modules/iobroker.withings, node: v14.19.3, js-controller: 4.0.23
2022-06-22 12:30:09.822  - info: host.ganymed "system.adapter.withings.0" disabled
2022-06-22 12:30:09.824  - info: host.ganymed stopInstance system.adapter.withings.0 (force=false, process=true)
2022-06-22 12:30:09.829  - info: withings.0 (196616) Got terminate signal TERMINATE_YOURSELF
2022-06-22 12:30:09.830  - info: withings.0 (196616) terminating
2022-06-22 12:30:09.832  - info: withings.0 (196616) Terminated (ADAPTER_REQUESTED_TERMINATION): Without reason
2022-06-22 12:30:09.839  - info: host.ganymed stopInstance system.adapter.withings.0 send kill signal
2022-06-22 12:30:10.436  - info: host.ganymed instance system.adapter.withings.0 terminated with code 11 (ADAPTER_REQUESTED_TERMINATION)
2022-06-22 12:30:11.421  - info: host.ganymed "system.adapter.withings.0" enabled
2022-06-22 12:30:11.624  - info: host.ganymed instance system.adapter.withings.0 started with pid 228319
2022-06-22 12:30:12.803  - info: withings.0 (228319) starting. Version 0.0.7 (non-npm: TA2k/ioBroker.withings) in /opt/iobroker/node_modules/iobroker.withings, node: v14.19.3, js-controller: 4.0.23

in der api finde ich dazu nichts zur aktualisierung

Das meinte ich auch nicht. Holt der Adapter sebständig Zeitgesteuert neue Daten, oder schickt die API die von sich aus?
Wenn ich so ins Log schaue sieht das wie ein 3 Stunden Poll-Intervall aus.

@TA2k
Copy link
Owner

TA2k commented Jun 22, 2022

nochmal installieren
es wird wie in den optionen im minuten interval abgefragt

@Grizzelbee
Copy link
Author

Es wird immer spannender: ;)
grafik

@Damrak2022
Copy link

Damrak2022 commented Jun 22, 2022 via email

@Grizzelbee
Copy link
Author

@Damrak2022
Naja. Beide sind interessant und ergeben nur zusammen das ganze Bild.
Die Summary bietet die Zusammenfassung der Nacht. Das ist schon einmal super. Da fehlen mir im Grunde nur ein paar Einheiten zum besseren Verständnis.

grafik

Nimm mal den Puls (rotes Rechteck). In der Summary siehst du Min, Max und Durchschnitt. Wenn Du aber zum Beispiel den Verlauf über die ganze Nacht analysieren musst, brauchst Du die Daten aus Sleep, weil Du dort das Tupel TimeStamp/Puls hast. Und nur damit kannst Du die Pulskurve über die ganze Nacht zeichnen.

Deshalb sage ich ja das wir die Daten aus SleepSummary brauchen und zusatzlich:

  • RR+Timestamp,
  • HR+Timestamp
  • Snoring+Timestamp,
  • StartDate
  • EndDate

Das ganze SeriesXX-Gedöns ist nach meinem Dafürhalten unnötig und bringt keinen Mehrwert. Zumal ich irgendwie das System noch nicht durchschaut habe. Series01 scheint immer die letzte Nacht zu sein - was über die Zeit betrachtet, dazu führt, dass sich unter sleep-series01-data-hr (und den anderen: rr, snoring) unendlich viele States ansammeln, weil sich die IDs nie wiederholen (können, da timestamps). Dadurch können sie aber auch nicht in einer DB erfasst werden.

@TA2k
Copy link
Owner

TA2k commented Jun 22, 2022

nochmal probieren

@Damrak2022
Copy link

Damrak2022 commented Jun 22, 2022 via email

@Grizzelbee
Copy link
Author

@TA2k
Wir bewegen uns in die richtige Richtung:
grafik

Aber jetzt fehlt noch der TimeStamp zu hr, rr und snoring. Die Daten ergeben nur zusammen Sinn. Deshalb ja meine Idee SLEEP und die SeriesXX komplett in Rente zu schicken und SleepSummary um die oben genannten Felder zu erweitern. Dann ergibt sich ein komplettes Bild einer Nacht - und baut sich über die Zeit vernünftig in der DB auf. Das einzige Problem sind dann nur noch die historischen Daten. Die würde ich über einen Button im Config holen und scheiben lassen. Sodass man nach der Installation des Adapters die DB-Konfig für die Historisierung machen kann und dann einmalig auf Button-Klick die historischen Daten reinladen. Eine Automatik halte ich für zu kompliziert.

@TA2k
Copy link
Owner

TA2k commented Jun 22, 2022

Ich habe noch was angepasst

@Damrak2022
Copy link

Damrak2022 commented Jun 23, 2022 via email

@Damrak2022
Copy link

Damrak2022 commented Jun 25, 2022

Mir ist gerade aufgefallen das bei Activities 01 und Activities 02 die absolut identischen Daten drinstehen.
Kann Du das korrigieren, oder soll ich hier bei Abruf der Daten den Wert von 1 auf 0 ändern?
Weiterhin würde ich mich auf eine Antwort von meinem vorigen Post freuen, da die Daten nicht synchron mit der App sind und ich auch gerne wüsste wie ich die Werte korrekt umrechne.
Bildschirmfoto 2022-06-25 um 03 54 10
Bildschirmfoto 2022-06-25 um 03 54 33
Bildschirmfoto 2022-06-25 um 03 56 55

Gruß Andy

@TA2k
Copy link
Owner

TA2k commented Jun 25, 2022

Ich habe keine Ahnung es werden nur die Daten aus der API weitergeleitet.
Außerdem fehlt mir die Zeit für tiefgreifende Änderung der Daten aber der Adapter ist offen jeder kann alles verändern

@ev3info
Copy link

ev3info commented Sep 6, 2022

Hallo zusammen, erstmal danke für den Adapter.

Ich habe das Problem, das nach ca. einer Woche meine DB zu viele Datapoints hat und extrem langsam wird. Im Prinzip fängt das ganze System an in die Knie zu gehen.

Der Grund ist der sleep-Ordner im Adapter. Die Anzahl der Datenpunkt steigt hier täglich an.
Ich habe die aktuelle Version 0.0.9 wo das Problem eigentlich gelöst sein sollte.

Meine Frage wäre, kannst du in den Adapter eine delete-Funktion einbauen? Es würde reichen, wenn ich einstellen kann, jeden Tag 12 Uhr den sleep-Ordner löschen. Aktuell mache ich das per Hand.

Grüße Tobi

@TA2k
Copy link
Owner

TA2k commented Sep 6, 2022

Kannst du bitte via GitHub installieren und schauen ob damit dein Problem gelöst ist

@ev3info
Copy link

ev3info commented Sep 6, 2022

Kannst du bitte via GitHub installieren und schauen ob damit dein Problem gelöst ist

Ja mach ich. Ich melde mich dann nochmal.

@ev3info
Copy link

ev3info commented Sep 9, 2022

Kannst du bitte via GitHub installieren und schauen ob damit dein Problem gelöst ist

Ja mach ich. Ich melde mich dann nochmal.

Ich hab alles mit der Github-Version laufen lassen. Versionsnummer ist 0.0.10.

Ich hatte Initial 2876 Objekte (4 Instanzen) nach einem Tag sind es jetzt 3435. Ich melde mich später nochmal.
Vielleicht steigt es ja nicht weiter.

@ev3info
Copy link

ev3info commented Sep 11, 2022

Kannst du bitte via GitHub installieren und schauen ob damit dein Problem gelöst ist

Ja mach ich. Ich melde mich dann nochmal.

Ich hab alles mit der Github-Version laufen lassen. Versionsnummer ist 0.0.10.

Ich hatte Initial 2876 Objekte (4 Instanzen) nach einem Tag sind es jetzt 3435. Ich melde mich später nochmal. Vielleicht steigt es ja nicht weiter.

Super ist stabil. Danke dir für den Tipp mit dem Github-Update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants