Fixes float being cast as int
This commit is contained in:
parent
acfd967aee
commit
2cd551f7c5
4 changed files with 5 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
.idea/
|
.idea/
|
||||||
node_modules/
|
node_modules/
|
||||||
dist/
|
dist/
|
||||||
|
.env
|
||||||
|
|
@ -89,7 +89,7 @@
|
||||||
const data = await result.json();
|
const data = await result.json();
|
||||||
|
|
||||||
TIMESTAMP_DISPLAY.textContent = new Date().toLocaleString();
|
TIMESTAMP_DISPLAY.textContent = new Date().toLocaleString();
|
||||||
TEMP_DISPLAY.textContent = `${data.temperature.toLocaleString(undefined, { minimumFractionDigits: 2 })}°C`;
|
TEMP_DISPLAY.textContent = `${data.temperature.toLocaleString(undefined, { minimumFractionDigits: 1 })}°C`;
|
||||||
MOISTURE.textContent = `${data.moisture}%`;
|
MOISTURE.textContent = `${data.moisture}%`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ import dotenv from 'dotenv';
|
||||||
import * as fs from "node:fs";
|
import * as fs from "node:fs";
|
||||||
import {Agent} from "undici";
|
import {Agent} from "undici";
|
||||||
|
|
||||||
if (fs.existsSync(".env.dist")) {
|
if (fs.existsSync(".env")) {
|
||||||
dotenv.config({ path: '.env.dist'});
|
dotenv.config({ path: '.env'});
|
||||||
}
|
}
|
||||||
|
|
||||||
const URI = `${process.env.DOMAIN}/api/states`;
|
const URI = `${process.env.DOMAIN}/api/states`;
|
||||||
|
|
@ -25,7 +25,7 @@ async function getSensorValue(sensor: string): Promise<number> {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
const data: unknown = await result.json();
|
const data: unknown = await result.json();
|
||||||
return parseInt(data.state);
|
return parseFloat(data.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
const server = express()
|
const server = express()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue