[+] Sync sleep function
This commit is contained in:
@@ -11,6 +11,8 @@ import com.topjohnwu.superuser.Shell
|
||||
import org.hydev.wearsync.Database.seq
|
||||
import org.hydev.wearsync.Database.str
|
||||
import org.hydev.wearsync.GsonExtensions.parseJson
|
||||
import org.hydev.wearsync.Influx
|
||||
import org.hydev.wearsync.offset
|
||||
import org.hydev.wearsync.reflectToString
|
||||
import java.time.Instant
|
||||
import java.util.*
|
||||
@@ -128,4 +130,20 @@ fun Context.readMiFitness(): MiFitness
|
||||
}
|
||||
|
||||
return MiFitness(days, states)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun Context.syncSleep(influx: Influx)
|
||||
{
|
||||
val (days, states) = readMiFitness()
|
||||
|
||||
println(days.joinToString("\n"))
|
||||
|
||||
listOf("mi-sleep-day", "mi-sleep-state").forEach {
|
||||
influx.java.deleteApi.delete(Date(0).offset, Date(5999999999999).offset,
|
||||
"_measurement=\"$it\"",
|
||||
influx.prefs.infBucket!!, influx.prefs.infOrg!!)
|
||||
}
|
||||
|
||||
influx += days
|
||||
influx += states
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
This package is for decoding Xiaomi's smart watch app Mi Fitness (com.mi.health) databases.
|
||||
I have a Mi Band 6 that works with it, probably other devices would work too.
|
||||
|
||||
This is used instead of GadgetBridge's export database because GadgetBridge does not decode
|
||||
device data correctly.
|
||||
Reference in New Issue
Block a user