Skip to content

Commit 1d8d1dd

Browse files
authored
Update lockscreen-homeassistant-temp.js
1 parent 1910eb1 commit 1d8d1dd

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

source/lockscreen-homeassistant-temp.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
hass.js
1+
// Home Assistant Lockscreen Widget
2+
3+
// Confguration
4+
// EDIT HERE
5+
6+
const hassUrl = "<hass base url>"
7+
const hassToken = "<your long lived Bearer token>"
8+
29
let widget = await createWidget();
310
if (!config.runsInWidget) {
411
await widget.presentSmall();
@@ -8,14 +15,11 @@ Script.setWidget(widget);
815
Script.complete();
916

1017
async function createWidget(items) {
11-
12-
/* Get data from API */
13-
const tempImg = await getImage('temperature.png');
14-
const humidImg = await getImage('humidity.png');
15-
const logoImg = await getImage('hass-favicon.png');
16-
17-
let req = new Request("https://<HASS IP>/api/states")
18-
req.headers = { "Authorization": "Bearer YOUR KEY", "content-type": "application/json" }
18+
let req = new Request(`${hassUrl}/api/states`)
19+
req.headers = {
20+
"Authorization": `Bearer ${hassToken}`,
21+
"content-type": "application/json"
22+
}
1923
let json = await req.loadJSON();
2024

2125
/* Parse data received from API */

0 commit comments

Comments
 (0)