1
1
// Home Assistant Lockscreen Widget
2
+ // Details
3
+ // - Used on lockscreen to show 2 temperature sensors
2
4
3
5
// Confguration
4
6
// EDIT HERE
@@ -8,7 +10,8 @@ const hassToken = "<your long lived Bearer token>"
8
10
9
11
let widget = await createWidget ( ) ;
10
12
if ( ! config . runsInWidget ) {
11
- await widget . presentSmall ( ) ;
13
+ // await widget.presentSmall();
14
+ await widget . presentMedium ( ) ;
12
15
}
13
16
14
17
Script . setWidget ( widget ) ;
@@ -25,7 +28,11 @@ async function createWidget(items) {
25
28
/* Parse data received from API */
26
29
let data = { livingroom : { } }
27
30
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
+ ] ) ;
29
36
30
37
/* Create the widget */
31
38
const widget = new ListWidget ( ) ;
@@ -40,7 +47,7 @@ async function createWidget(items) {
40
47
labelStack . setPadding ( 0 , 0 , 0 , 0 ) ;
41
48
labelStack . borderWidth = 0 ;
42
49
labelStack . size = new Size ( 50 , 50 ) ;
43
- addLabel ( labelStack , "🛋️ " )
50
+ addLabel ( labelStack , "🔥 " )
44
51
45
52
/* Second, the temperature column */
46
53
const tempStack = bodyStack . addStack ( ) ;
@@ -54,15 +61,15 @@ async function createWidget(items) {
54
61
addTemp ( tempStack , data . livingroom )
55
62
56
63
/* 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 ( ) ;
63
70
64
- humidStack . addText ( "💧" )
65
- addHumid ( humidStack , data . livingroom )
71
+ storageStack . addText ( "💧" )
72
+ addStorage ( storageStack , data . livingroom )
66
73
67
74
/* Done: Widget is now ready to be displayed */
68
75
return widget ;
@@ -77,14 +84,14 @@ async function addLabel(labelStack, label) {
77
84
78
85
/* Adds the entries to the temperature column */
79
86
async function addTemp ( tempStack , data ) {
80
- const mytext = tempStack . addText ( data . temp + "°C " ) ;
87
+ const mytext = tempStack . addText ( data . temp + "°F " ) ;
81
88
mytext . font = Font . heavyMonospacedSystemFont ( 13 ) ;
82
89
mytext . textColor = Color . white ( ) ;
83
90
}
84
91
85
92
/* 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 " ) ;
88
95
mytext . font = Font . mediumMonospacedSystemFont ( 13 ) ;
89
96
mytext . textColor = Color . white ( ) ;
90
97
mytext . textOpacity = 0.8 ;
0 commit comments