From 2eb1cb7e4bd5a8a4c6e7363b1e5ef79cad975208 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Wed, 22 Jun 2022 01:03:16 +0000 Subject: [PATCH] Add Air quality and proper units --- client/src/App.js | 262 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 247 insertions(+), 15 deletions(-) diff --git a/client/src/App.js b/client/src/App.js index 1e43ca7..ed6bce8 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -19,6 +19,20 @@ const durations = [ {id: 7, len: 'Year', win: '30d', full: '30 day', delta: [1, 'years'], format: 'M'}, ]; +const units = { + 'PM10': ' ug/m³', + 'PM2.5': ' ug/m³', + 'VOC': ' / 500', + 'CO2': ' ppm', + 'Energy': ' kWh', + 'Power': ' W', + 'Temperature': ' °C', + 'Humidity': '%', + 'Setpoint': ' °C', + 'State': '', + 'Lux': ' lx', +}; + function useSensor(measurement, name, end, duration) { const [data, setData] = useState(false); const [loading, setLoading] = useState(false); @@ -134,24 +148,43 @@ function SolarPower({end, duration}) { minTickGap={10} tickFormatter={tickFormatter} /> + + + v + ' W'} + formatter={(v, name) => v.toFixed(1) + units[name]} labelFormatter={timeStr => moment(timeStr).tz('America/Edmonton').format('ddd MMM DD h:mm A')} separator=': ' /> - + + + - + @@ -220,23 +253,33 @@ function NookTemperature({end, duration}) { minTickGap={10} tickFormatter={tickFormatter} /> + + + v.toFixed(1) + ' °C'} + formatter={(v, name) => v.toFixed(1) + units[name]} labelFormatter={timeStr => moment(timeStr).tz('America/Edmonton').format('ddd MMM DD h:mm A')} separator=': ' /> - + - + + + ); } @@ -264,23 +318,33 @@ function BedroomTemperature({end, duration}) { minTickGap={10} tickFormatter={tickFormatter} /> + + + v.toFixed(1) + ' °C'} + formatter={(v, name) => v.toFixed(1) + units[name]} labelFormatter={timeStr => moment(timeStr).tz('America/Edmonton').format('ddd MMM DD h:mm A')} separator=': ' /> - + - + + + ); } @@ -322,7 +397,7 @@ function SeedsTemperature({end, duration}) { v.toFixed(1) + ' °C'} + formatter={(v, name) => v.toFixed(1) + units[name]} labelFormatter={timeStr => moment(timeStr).tz('America/Edmonton').format('ddd MMM DD h:mm A')} separator=': ' /> @@ -369,19 +444,40 @@ function Thermostat({end, duration}) { minTickGap={10} tickFormatter={tickFormatter} /> + + + v.toFixed(1) + ' °C'} + formatter={(v, name) => v.toFixed(1) + units[name]} labelFormatter={timeStr => moment(timeStr).tz('America/Edmonton').format('ddd MMM DD h:mm A')} separator=': ' /> - + + + x.max_p10?.toFixed(1) + ' ug/m³'} + loading={loading} + > + + + + + + + + v + units[name]} + labelFormatter={timeStr => moment(timeStr).tz('America/Edmonton').format('ddd MMM DD h:mm A')} + separator=': ' + /> + + + + + + + + + + + + ); +} + function BedroomSleep({end, duration}) { const [data, loading, tickFormatter] = useSensor('sleep', 'Bedroom', end, duration); @@ -600,11 +786,57 @@ function BedroomSleep({end, duration}) { ); } +function LivingRoomLux({end, duration}) { + const [data, loading, tickFormatter] = useSensor('lux', 'Living Room', end, duration); + + return ( + x.lux?.toFixed(1) + ' lx'} + loading={loading} + > + + + + + + v.toFixed(1) + units[name]} + labelFormatter={timeStr => moment(timeStr).tz('America/Edmonton').format('ddd MMM DD h:mm A')} + separator=': ' + /> + + + + + + ); +} + function Graphs({end, duration}) { return (
+ + @@ -612,8 +844,8 @@ function Graphs({end, duration}) { - +
); }