frugal-iot-server 0.3.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/INSTALLATION.md +219 -61
- package/config.d/email.yaml +23 -0
- package/config.d/schema/devices.yaml +0 -2
- package/config.d/schema/modules.yaml +344 -2
- package/config.d/schema/topics.yaml +140 -46
- package/extras/aclfile +38 -0
- package/extras/mosquitto.conf +29 -0
- package/frugal-iot-createdb.sql +82 -1
- package/frugal-iot-server.js +692 -80
- package/lib/api-routes.js +7 -7
- package/lib/config-for-user.js +115 -0
- package/lib/dynsec-plan.js +246 -0
- package/lib/dynsec-server.js +204 -0
- package/lib/dynsec-sync.js +209 -0
- package/lib/dynsec.js +166 -0
- package/lib/enrol.js +288 -0
- package/lib/mailer.js +43 -0
- package/lib/replica.js +246 -0
- package/lib/resetcode.js +103 -0
- package/lib/retained.js +110 -0
- package/lib/secrets.js +148 -0
- package/package.json +12 -5
- package/public/index.html +8 -8
- package/public/service-worker.js +76 -27
- package/scripts/addbridge-pi.zsh +91 -7
- package/scripts/addbridge-prod.zsh +57 -3
- package/scripts/addorganization.zsh +5 -0
- package/scripts/clearretained.js +185 -0
- package/scripts/diagnostic.zsh +121 -2
- package/scripts/dynsec-init.js +142 -0
- package/scripts/init.zsh +64 -1
- package/scripts/install-pi.sh +83 -4
- package/scripts/migrate-permissions-project.sql +21 -0
- package/scripts/not-published.txt +5 -0
- package/scripts/rebuild-dynsec.js +190 -0
- package/scripts/resetnode.js +69 -0
- package/scripts/clearretained.zsh +0 -153
|
@@ -20,11 +20,89 @@ aht21:
|
|
|
20
20
|
topics:
|
|
21
21
|
- leaf: temperature
|
|
22
22
|
- leaf: humidity
|
|
23
|
+
# The DS18B20 probes on an FF-OpenMPPT board - see frugal-iot-irrigation. Separate modules rather
|
|
24
|
+
# than one, because the three measure quite different things and want different ranges; the class
|
|
25
|
+
# is the same Sensor_DS18B20 as the `ds18b20` module below.
|
|
26
|
+
airtemp:
|
|
27
|
+
name: Air Temperature
|
|
28
|
+
topics:
|
|
29
|
+
- leaf: airtemp
|
|
30
|
+
leaf_from: temperature
|
|
31
|
+
name: Air Temperature
|
|
32
|
+
min: -20
|
|
33
|
+
max: 60
|
|
34
|
+
analog:
|
|
35
|
+
name: "Analog Out"
|
|
36
|
+
topics:
|
|
37
|
+
- leaf: volts
|
|
23
38
|
battery:
|
|
24
39
|
name: "Battery"
|
|
25
40
|
insidefrugaliot: true
|
|
26
41
|
topics:
|
|
27
42
|
- leaf: battery
|
|
43
|
+
# How much of its rated capacity the battery still has, inferred from an overnight discharge.
|
|
44
|
+
# A trend over weeks, not a reading; see control_health.h. Named batteryhealth because `health` is
|
|
45
|
+
# already taken by the device's own reporting.
|
|
46
|
+
batteryhealth:
|
|
47
|
+
name: Battery Health
|
|
48
|
+
topics:
|
|
49
|
+
- leaf: health
|
|
50
|
+
leaf_from: percent
|
|
51
|
+
name: Health
|
|
52
|
+
duplicates:
|
|
53
|
+
significantdate: 86400000
|
|
54
|
+
significantvalue: 1
|
|
55
|
+
- leaf: state
|
|
56
|
+
leaf_from: controltext
|
|
57
|
+
name: State
|
|
58
|
+
rw: r
|
|
59
|
+
- leaf: soc
|
|
60
|
+
leaf_from: controlfloat
|
|
61
|
+
name: Charge
|
|
62
|
+
min: 0
|
|
63
|
+
max: 100
|
|
64
|
+
- leaf: capacity
|
|
65
|
+
leaf_from: controlfloat
|
|
66
|
+
name: Capacity Ah
|
|
67
|
+
min: 0
|
|
68
|
+
max: 500
|
|
69
|
+
wireable: false
|
|
70
|
+
- leaf: load
|
|
71
|
+
leaf_from: controlfloat
|
|
72
|
+
name: Average load A
|
|
73
|
+
min: 0
|
|
74
|
+
max: 50
|
|
75
|
+
wireable: false
|
|
76
|
+
- leaf: active
|
|
77
|
+
leaf_from: controlint
|
|
78
|
+
name: Irrigation active
|
|
79
|
+
min: 0
|
|
80
|
+
max: 16
|
|
81
|
+
- leaf: panelwatts
|
|
82
|
+
leaf_from: controlfloat
|
|
83
|
+
name: Panel watts
|
|
84
|
+
min: 0
|
|
85
|
+
max: 2000
|
|
86
|
+
wireable: false
|
|
87
|
+
- leaf: storageratio
|
|
88
|
+
leaf_from: controlfloat
|
|
89
|
+
name: Storage ratio
|
|
90
|
+
min: 0
|
|
91
|
+
max: 50
|
|
92
|
+
rw: r
|
|
93
|
+
wireable: false
|
|
94
|
+
- leaf: advice
|
|
95
|
+
leaf_from: controltext
|
|
96
|
+
name: Advice
|
|
97
|
+
rw: r
|
|
98
|
+
batttemp:
|
|
99
|
+
name: Battery Temperature
|
|
100
|
+
topics:
|
|
101
|
+
- leaf: batttemp
|
|
102
|
+
leaf_from: temperature
|
|
103
|
+
name: Battery Temperature
|
|
104
|
+
min: -20
|
|
105
|
+
max: 60
|
|
28
106
|
bme280:
|
|
29
107
|
name: "BME280"
|
|
30
108
|
topics:
|
|
@@ -131,11 +209,11 @@ ens160:
|
|
|
131
209
|
leaf_from: controlfloat
|
|
132
210
|
name: Temperature
|
|
133
211
|
max: 50
|
|
134
|
-
color:
|
|
212
|
+
color: "#ff0000"
|
|
135
213
|
- leaf: humidity
|
|
136
214
|
leaf_from: controlfloat
|
|
137
215
|
name: Humidity
|
|
138
|
-
color:
|
|
216
|
+
color: "#0000ff"
|
|
139
217
|
- leaf: aqi
|
|
140
218
|
- leaf: tvoc
|
|
141
219
|
- leaf: eco2
|
|
@@ -177,6 +255,16 @@ health:
|
|
|
177
255
|
topics:
|
|
178
256
|
- leaf: wifibars
|
|
179
257
|
- leaf: wifissid
|
|
258
|
+
# The charge controller's own heatsink. Either a DS18B20 or a pair of diodes read on an ADC pin,
|
|
259
|
+
# depending on the board - the reading means the same either way.
|
|
260
|
+
heatsink:
|
|
261
|
+
name: Heatsink Temperature
|
|
262
|
+
topics:
|
|
263
|
+
- leaf: heatsink
|
|
264
|
+
leaf_from: temperature
|
|
265
|
+
name: Heatsink Temperature
|
|
266
|
+
min: 0
|
|
267
|
+
max: 120
|
|
180
268
|
ht:
|
|
181
269
|
name: HT
|
|
182
270
|
topics:
|
|
@@ -190,11 +278,64 @@ ina219:
|
|
|
190
278
|
- leaf: current
|
|
191
279
|
- leaf: power
|
|
192
280
|
- leaf: load
|
|
281
|
+
irrigation:
|
|
282
|
+
name: Irrigation
|
|
283
|
+
topics:
|
|
284
|
+
- leaf: hour
|
|
285
|
+
leaf_from: controlint
|
|
286
|
+
name: Start hour
|
|
287
|
+
min: 0
|
|
288
|
+
max: 23
|
|
289
|
+
- leaf: minute
|
|
290
|
+
leaf_from: controlint
|
|
291
|
+
name: Start minute
|
|
292
|
+
min: 0
|
|
293
|
+
max: 59
|
|
294
|
+
- leaf: maxminutes
|
|
295
|
+
leaf_from: controlfloat
|
|
296
|
+
name: Max minutes per sector
|
|
297
|
+
min: 0
|
|
298
|
+
max: 120
|
|
299
|
+
- leaf: enabled
|
|
300
|
+
leaf_from: controlintoggle
|
|
301
|
+
name: Enabled
|
|
302
|
+
- leaf: tank
|
|
303
|
+
leaf_from: controlfloat
|
|
304
|
+
name: Tank level
|
|
305
|
+
color: "#0000ff"
|
|
306
|
+
- leaf: tankstart
|
|
307
|
+
leaf_from: controlfloat
|
|
308
|
+
name: Tank level to start
|
|
309
|
+
- leaf: tankempty
|
|
310
|
+
leaf_from: controlfloat
|
|
311
|
+
name: Tank level to stop
|
|
312
|
+
- leaf: power
|
|
313
|
+
leaf_from: controlintoggle
|
|
314
|
+
name: Power ok
|
|
315
|
+
wireable: true
|
|
316
|
+
- leaf: solar
|
|
317
|
+
leaf_from: controlintoggle
|
|
318
|
+
name: Input power
|
|
319
|
+
wireable: true
|
|
320
|
+
- leaf: pump
|
|
321
|
+
leaf_from: controlouttoggle
|
|
322
|
+
name: Pump
|
|
323
|
+
- leaf: active
|
|
324
|
+
leaf_from: controlint
|
|
325
|
+
name: Active sector
|
|
326
|
+
min: 0
|
|
327
|
+
max: 16
|
|
193
328
|
lcd:
|
|
194
329
|
summary: false # a message is not a reading
|
|
195
330
|
name: LCD
|
|
196
331
|
topics:
|
|
197
332
|
- leaf: message
|
|
333
|
+
# The switched load output - OSPIT's pin 14 in its "load" role, opened by the low-voltage
|
|
334
|
+
# disconnect. An Actuator_Digital, so the same shape as `relay`.
|
|
335
|
+
load:
|
|
336
|
+
name: Load
|
|
337
|
+
topics:
|
|
338
|
+
- leaf: on
|
|
198
339
|
ledbuiltin:
|
|
199
340
|
name: LED
|
|
200
341
|
slot: ledbuiltin
|
|
@@ -211,6 +352,96 @@ lux:
|
|
|
211
352
|
name: Light meter
|
|
212
353
|
topics:
|
|
213
354
|
- leaf: lux
|
|
355
|
+
# Solar charge control - see frugal-iot-irrigation. `step` is the raw DAC value because that is
|
|
356
|
+
# unambiguous; `vmpp` is what the node PREDICTS that step asks the hardware for, which is a guess
|
|
357
|
+
# until it has been checked against a meter.
|
|
358
|
+
mppt:
|
|
359
|
+
name: Charge Control
|
|
360
|
+
topics:
|
|
361
|
+
- leaf: automatic
|
|
362
|
+
leaf_from: controlintoggle
|
|
363
|
+
name: Automatic
|
|
364
|
+
- leaf: state
|
|
365
|
+
leaf_from: controltext
|
|
366
|
+
name: State
|
|
367
|
+
rw: r
|
|
368
|
+
- leaf: profile
|
|
369
|
+
leaf_from: controlint
|
|
370
|
+
name: Battery type
|
|
371
|
+
min: 0
|
|
372
|
+
max: 3
|
|
373
|
+
wireable: false
|
|
374
|
+
- leaf: chargeend
|
|
375
|
+
leaf_from: controlfloat
|
|
376
|
+
name: Charge end
|
|
377
|
+
min: 10000
|
|
378
|
+
max: 16000
|
|
379
|
+
wireable: false
|
|
380
|
+
- leaf: tempcoeff
|
|
381
|
+
leaf_from: controlfloat
|
|
382
|
+
name: Temp coefficient
|
|
383
|
+
min: 0
|
|
384
|
+
max: 60
|
|
385
|
+
wireable: false
|
|
386
|
+
- leaf: hotcharge
|
|
387
|
+
leaf_from: controlfloat
|
|
388
|
+
name: Hot battery
|
|
389
|
+
min: 10000
|
|
390
|
+
max: 16000
|
|
391
|
+
wireable: false
|
|
392
|
+
- leaf: batttemp
|
|
393
|
+
leaf_from: controlfloat
|
|
394
|
+
name: Battery temp
|
|
395
|
+
min: -20
|
|
396
|
+
max: 60
|
|
397
|
+
- leaf: heatsink
|
|
398
|
+
leaf_from: controlfloat
|
|
399
|
+
name: Heatsink temp
|
|
400
|
+
min: 0
|
|
401
|
+
max: 120
|
|
402
|
+
- leaf: target
|
|
403
|
+
leaf_from: controlfloat
|
|
404
|
+
name: Target
|
|
405
|
+
min: 10000
|
|
406
|
+
max: 16000
|
|
407
|
+
rw: r
|
|
408
|
+
wireable: false
|
|
409
|
+
- leaf: step
|
|
410
|
+
leaf_from: controlint
|
|
411
|
+
name: DAC step
|
|
412
|
+
min: 0
|
|
413
|
+
max: 255
|
|
414
|
+
wireable: false
|
|
415
|
+
- leaf: panel
|
|
416
|
+
leaf_from: controlfloat
|
|
417
|
+
name: Panel
|
|
418
|
+
min: 0
|
|
419
|
+
max: 30000
|
|
420
|
+
- leaf: battery
|
|
421
|
+
leaf_from: controlfloat
|
|
422
|
+
name: Battery
|
|
423
|
+
min: 0
|
|
424
|
+
max: 16000
|
|
425
|
+
- leaf: voc
|
|
426
|
+
leaf_from: controlfloat
|
|
427
|
+
name: Open circuit
|
|
428
|
+
min: 0
|
|
429
|
+
max: 30000
|
|
430
|
+
rw: r
|
|
431
|
+
wireable: false
|
|
432
|
+
- leaf: vmpp
|
|
433
|
+
leaf_from: controlfloat
|
|
434
|
+
name: Panel target
|
|
435
|
+
min: 0
|
|
436
|
+
max: 30
|
|
437
|
+
rw: r
|
|
438
|
+
wireable: false
|
|
439
|
+
- leaf: dacvolts
|
|
440
|
+
leaf_from: controlfloat
|
|
441
|
+
name: DAC volts
|
|
442
|
+
min: 0
|
|
443
|
+
max: 3.3
|
|
444
|
+
rw: r
|
|
214
445
|
ms5803:
|
|
215
446
|
name: MS5803
|
|
216
447
|
topics:
|
|
@@ -221,6 +452,25 @@ ota:
|
|
|
221
452
|
insidefrugaliot: true
|
|
222
453
|
topics:
|
|
223
454
|
- leaf: key
|
|
455
|
+
panel:
|
|
456
|
+
name: Solar Panel
|
|
457
|
+
topics:
|
|
458
|
+
- leaf: panel
|
|
459
|
+
leaf_from: voltage
|
|
460
|
+
name: Panel Voltage
|
|
461
|
+
max: 30000
|
|
462
|
+
pcbtemp:
|
|
463
|
+
name: Board Temperature
|
|
464
|
+
topics:
|
|
465
|
+
- leaf: pcbtemp
|
|
466
|
+
leaf_from: temperature
|
|
467
|
+
name: Board Temperature
|
|
468
|
+
min: -20
|
|
469
|
+
max: 100
|
|
470
|
+
pump:
|
|
471
|
+
name: Pump
|
|
472
|
+
topics:
|
|
473
|
+
- leaf: on
|
|
224
474
|
rain:
|
|
225
475
|
name: Rain
|
|
226
476
|
topics:
|
|
@@ -230,16 +480,108 @@ relay:
|
|
|
230
480
|
name: Relay
|
|
231
481
|
topics:
|
|
232
482
|
- leaf: on
|
|
483
|
+
# One sector of an irrigation run - see modules "irrigation". A node with several sectors publishes
|
|
484
|
+
# sector1, sector2... and the client resolves those numbered instances back to this entry, so only
|
|
485
|
+
# the one definition is needed here however many sectors a node has.
|
|
486
|
+
sector:
|
|
487
|
+
name: Irrigation sector
|
|
488
|
+
topics:
|
|
489
|
+
- leaf: moisture
|
|
490
|
+
leaf_from: controlfloat
|
|
491
|
+
name: Moisture
|
|
492
|
+
color: "#a52a2a"
|
|
493
|
+
- leaf: target
|
|
494
|
+
leaf_from: controlfloat
|
|
495
|
+
name: Target
|
|
496
|
+
- leaf: enable
|
|
497
|
+
leaf_from: controlintoggle
|
|
498
|
+
name: Enable
|
|
499
|
+
- leaf: valve
|
|
500
|
+
leaf_from: controlouttoggle
|
|
501
|
+
name: Valve
|
|
233
502
|
sht:
|
|
234
503
|
name: SHT
|
|
235
504
|
topics:
|
|
236
505
|
- leaf: temperature
|
|
237
506
|
- leaf: humidity
|
|
507
|
+
# State of charge, estimated from battery voltage - reporting only, never controlled from. See
|
|
508
|
+
# control_soc.h in frugal-iot-irrigation for what the estimate is and is not worth.
|
|
509
|
+
soc:
|
|
510
|
+
name: State of Charge
|
|
511
|
+
topics:
|
|
512
|
+
- leaf: soc
|
|
513
|
+
leaf_from: percent
|
|
514
|
+
name: Charge
|
|
515
|
+
duplicates:
|
|
516
|
+
significantdate: 900000
|
|
517
|
+
significantvalue: 1
|
|
518
|
+
- leaf: charging
|
|
519
|
+
leaf_from: controlouttoggle
|
|
520
|
+
name: Charging
|
|
521
|
+
- leaf: battery
|
|
522
|
+
leaf_from: controlfloat
|
|
523
|
+
name: Battery
|
|
524
|
+
min: 0
|
|
525
|
+
max: 16000
|
|
526
|
+
# controlfloat is "log: false" because most control inputs are wired from a topic that is
|
|
527
|
+
# already logged in its own right. Battery and panel are not - the node measures and
|
|
528
|
+
# publishes them here and nowhere else, so without this they were never archived.
|
|
529
|
+
log: true
|
|
530
|
+
- leaf: panel
|
|
531
|
+
leaf_from: controlfloat
|
|
532
|
+
name: Panel
|
|
533
|
+
min: 0
|
|
534
|
+
max: 30000
|
|
535
|
+
log: true
|
|
536
|
+
- leaf: profile
|
|
537
|
+
leaf_from: controlint
|
|
538
|
+
name: Battery type
|
|
539
|
+
min: 0
|
|
540
|
+
max: 3
|
|
541
|
+
wireable: false
|
|
238
542
|
soil:
|
|
239
543
|
name: Soil
|
|
240
544
|
topics:
|
|
241
545
|
- leaf: soil
|
|
546
|
+
tank:
|
|
547
|
+
name: Water Tank
|
|
548
|
+
topics:
|
|
549
|
+
- leaf: tank
|
|
550
|
+
soilmodbus:
|
|
551
|
+
name: "Soil Probe"
|
|
552
|
+
topics:
|
|
553
|
+
# Reuses the shared humidity and temperature definitions - same ranges, logging and
|
|
554
|
+
# duplicate rules - overriding only what soil makes different from air.
|
|
555
|
+
- leaf: humidity
|
|
556
|
+
name: "Soil Moisture"
|
|
557
|
+
color: brown
|
|
558
|
+
units: "%" # Volumetric water content, not the relative humidity the shared leaf means
|
|
559
|
+
- leaf: temperature
|
|
560
|
+
name: "Soil Temperature"
|
|
561
|
+
color: brown
|
|
562
|
+
# The node's clock - what time it thinks it is and how far from UTC it displays. Infrastructure
|
|
563
|
+
# rather than a sensor, so it belongs in the Frugal_IoT drop-down alongside ota, and neither leaf is
|
|
564
|
+
# logged. Without this entry both leaves resolved to no schema at all, so every message from them
|
|
565
|
+
# reached valueFromText with no type and was reported as "Unrecognized message type: undefined".
|
|
566
|
+
time:
|
|
567
|
+
name: Time
|
|
568
|
+
insidefrugaliot: true
|
|
569
|
+
topics:
|
|
570
|
+
- leaf: epoch
|
|
571
|
+
- leaf: offset
|
|
242
572
|
ultrasonic:
|
|
243
573
|
name: "Ultrasonic Distance"
|
|
244
574
|
topics:
|
|
245
575
|
- leaf: ultrasonic
|
|
576
|
+
# The irrigation valves - Actuator_Digital instances, so the same shape as `relay`. A node with
|
|
577
|
+
# several publishes valve1, valve2... which the client resolves back to this entry.
|
|
578
|
+
# A switched USB supply - an Actuator_Digital, so the same shape as `relay`. On the FF board this
|
|
579
|
+
# shares a pin with the third irrigation valve; a node has one or the other.
|
|
580
|
+
usb:
|
|
581
|
+
name: USB Supply
|
|
582
|
+
topics:
|
|
583
|
+
- leaf: on
|
|
584
|
+
valve:
|
|
585
|
+
name: Valve
|
|
586
|
+
topics:
|
|
587
|
+
- leaf: on
|