diff --git a/client/src/App.css b/client/src/App.css index 40d4027..88099b9 100644 --- a/client/src/App.css +++ b/client/src/App.css @@ -47,3 +47,8 @@ p { margin: 0.25em; } +.recharts-wrapper p { + color: initial; + font-size: initial; +} + diff --git a/client/src/App.js b/client/src/App.js index 04cc8b3..4d6b580 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -6,11 +6,12 @@ import './App.css'; function App() { const [data, setData] = useState(false); + const [history, setHistory] = useState(false); useEffect(() => { const get = async() => { try { - const res = await axios.get('https://reg.t0.vc/solar.json'); + const res = await axios.get('https://solar-api.dns.t0.vc/data'); setData(res.data); } catch (error) { setData(false); @@ -18,97 +19,94 @@ function App() { }; get(); - const interval = setInterval(get, 1000); + const interval = setInterval(get, 30000); return () => clearInterval(interval); }, []); - const listen = () => { - var audioCtx = new (window.AudioContext || window.webkitAudioContext)(); - var myArrayBuffer = audioCtx.createBuffer(2, audioCtx.sampleRate * 5, audioCtx.sampleRate); - for (var channel = 0; channel < myArrayBuffer.numberOfChannels; channel++) { - var nowBuffering = myArrayBuffer.getChannelData(channel); - for (var i = 0; i < myArrayBuffer.length; i++) { - nowBuffering[i] = data.history[i % data.history.length].total / 24000.0; + useEffect(() => { + const get = async() => { + try { + const date = moment().format('YYYY-MM-DD'); + const res = await axios.get('https://solar-api.dns.t0.vc/history/'+date); + setHistory(res.data); + } catch (error) { + setHistory(false); } - } - var source = audioCtx.createBufferSource(); - source.buffer = myArrayBuffer; - source.connect(audioCtx.destination); - source.start(); - } + }; + + get(); + const interval = setInterval(get, 30000); + return () => clearInterval(interval); + }, []); return (
Loading...
+ } - + {data ? +Total: {data.actual_total} W — {parseInt(data.actual_total / 5985 * 100)}%
- {data.night ? -The sun has set 😴
-Total: {data.actual_total} W — {parseInt(data.actual_total / 5985 * 100)}%
+Today: {data.today_energy} kWh
-Today: {data.today_energy} kWh
+Updated: {data.timestamp.split(' ')[1]}
-Updated: {data.timestamp.split(' ')[1]}
+Individual panels:
-Individual panels:
+Loading...