Skip to content

Commit cbcea39

Browse files
authored
Update lockscreen-hass-temp.js
1 parent da2fb29 commit cbcea39

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

source/lockscreen-hass-temp.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Home Assistant Lockscreen Widget
2+
// Details
3+
// - Used on lockscreen to show 2 temperature sensors
24

35
// Confguration
46
// EDIT HERE
@@ -8,7 +10,8 @@ const hassToken = "<your long lived Bearer token>"
810

911
let widget = await createWidget();
1012
if (!config.runsInWidget) {
11-
await widget.presentSmall();
13+
// await widget.presentSmall();
14+
await widget.presentMedium();
1215
}
1316

1417
Script.setWidget(widget);
@@ -25,7 +28,11 @@ async function createWidget(items) {
2528
/* Parse data received from API */
2629
let data = {livingroom: {}}
2730

28-
data.livingroom = addData(json, data.livingroom, ['sensor.living_room_temperature', 'sensor.living_room_humidity']);
31+
data.livingroom = addData(json, data.livingroom, [
32+
'sensor.boiler_temp'
33+
,'sensor.storage_temp'
34+
,'binary_sensor.blower'
35+
]);
2936

3037
/* Create the widget */
3138
const widget = new ListWidget();
@@ -40,7 +47,7 @@ async function createWidget(items) {
4047
labelStack.setPadding(0, 0, 0, 0);
4148
labelStack.borderWidth = 0;
4249
labelStack.size = new Size(50,50);
43-
addLabel(labelStack, "🛋️")
50+
addLabel(labelStack, "🔥")
4451

4552
/* Second, the temperature column */
4653
const tempStack = bodyStack.addStack();
@@ -54,15 +61,15 @@ async function createWidget(items) {
5461
addTemp(tempStack, data.livingroom)
5562

5663
/* Third, the humidity column */
57-
const humidStack = bodyStack.addStack();
58-
humidStack.centerAlignContent();
59-
humidStack.setPadding(0, 5, 0, 0);
60-
humidStack.borderWidth = 0;
61-
humidStack.size = new Size(0,50);
62-
humidStack.layoutVertically();
64+
const storageStack = bodyStack.addStack();
65+
storageStack.centerAlignContent();
66+
storageStack.setPadding(0, 5, 0, 0);
67+
storageStack.borderWidth = 0;
68+
storageStack.size = new Size(0,50);
69+
storageStack.layoutVertically();
6370

64-
humidStack.addText("💧")
65-
addHumid(humidStack, data.livingroom)
71+
storageStack.addText("💧")
72+
addStorage(storageStack, data.livingroom)
6673

6774
/* Done: Widget is now ready to be displayed */
6875
return widget;
@@ -77,14 +84,14 @@ async function addLabel(labelStack, label) {
7784

7885
/* Adds the entries to the temperature column */
7986
async function addTemp(tempStack, data) {
80-
const mytext = tempStack.addText(data.temp + C");
87+
const mytext = tempStack.addText(data.temp + F");
8188
mytext.font = Font.heavyMonospacedSystemFont(13);
8289
mytext.textColor = Color.white();
8390
}
8491

8592
/* Adds the entries to the humidity column */
86-
async function addHumid(humidStack, data) {
87-
const mytext = humidStack.addText(data.humid + "%");
93+
async function addStorage(storageStack, data) {
94+
const mytext = storageStack.addText(data.humid + "°F");
8895
mytext.font = Font.mediumMonospacedSystemFont(13);
8996
mytext.textColor = Color.white();
9097
mytext.textOpacity = 0.8;

0 commit comments

Comments
 (0)