From 5fb1e1a109c05fc845d912b6fdeeb09f85b3b8ab Mon Sep 17 00:00:00 2001 From: Peter Hajas Date: Sat, 7 May 2022 21:06:26 -0600 Subject: [PATCH] load HA data --- script.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/script.js b/script.js index 106c090..7dc539b 100644 --- a/script.js +++ b/script.js @@ -1,3 +1,5 @@ +let haStateURL = "http://beacon:1880/ha_state" + const scene = new THREE.Scene(); const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); let homeContainer = new THREE.Group() @@ -84,7 +86,7 @@ function configureScene(data) { home.position.y = +1 * (yExtent / 2) } -async function doLoad() { +async function loadHomeData() { let request = new Request('data.json'); fetch(request) .then(response => { @@ -95,5 +97,18 @@ async function doLoad() { }) } -doLoad(); +loadHomeData(); + +async function loadHAData() { + let request = new Request(haStateURL); + fetch(request) + .then(response => { + return response.json() + }) + .then(json => { + console.log(json) + }) +} + +loadHAData()