diff --git a/lib/db.ts b/lib/db.ts index bcf0c85..3511bf5 100644 --- a/lib/db.ts +++ b/lib/db.ts @@ -148,7 +148,7 @@ export async function fetchDevice( if (obj["_value"] != null) { attrs.value = [obj["_timestamp"] || 1, [obj["_value"], obj["_type"]]]; - if (obj["_type"] === "xsd:dateTime") + if (obj["_type"] === "xsd:dateTime" && obj["_value"] instanceof Date) attrs.value[1][0] = +attrs.value[1][0]; obj["_object"] = false; diff --git a/lib/ui/api.ts b/lib/ui/api.ts index 7c2efaa..4e43a73 100644 --- a/lib/ui/api.ts +++ b/lib/ui/api.ts @@ -125,7 +125,7 @@ router.get(`/devices/:id.csv`, async (ctx) => { new Date(p.objectTimestamp).toJSON(), p.writable, new Date(p.writableTimestamp).toJSON(), - `"${value.toString().replace(/"/g, '""')}"`, + `"${String(value).replace(/"/g, '""')}"`, type, new Date(p.valueTimestamp).toJSON(), p.notification,