frugal-iot-server 2.0.8 → 2.0.10
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/README.md +3 -3
- package/config.d/email.yaml +1 -1
- package/config.d/opensearch.yaml +19 -15
- package/config.d/schema/modules.yaml +13 -0
- package/config.d/schema/topics.yaml +50 -0
- package/{GRAFANA.md → docs/GRAFANA.md} +37 -6
- package/{INSTALL-OPENSEARCH.md → docs/INSTALL-OPENSEARCH.md} +183 -97
- package/docs/OPENWRT.md +208 -0
- package/extras/frugaliot.service +1 -1
- package/extras/mosquitto.conf +1 -1
- package/frugal-iot-createdb.sql +10 -1
- package/frugal-iot-server.js +28 -7
- package/lib/forwarders.js +49 -10
- package/lib/grafana.js +2 -2
- package/lib/language-requests.js +50 -0
- package/lib/opensearch-access.js +9 -2
- package/package.json +7 -6
- package/public/service-worker.js +10 -2
- package/scripts/addbridge-pi.zsh +1 -1
- package/scripts/addbridge-prod.zsh +2 -2
- package/scripts/addorganization.zsh +11 -2
- package/scripts/diagnostic.zsh +4 -4
- package/scripts/grafana-token.js +1 -1
- package/scripts/init.zsh +5 -1
- package/scripts/install-openwrt.sh +709 -0
- package/scripts/install-pi.sh +46 -12
- package/scripts/openwrt-preflight.sh +363 -0
- /package/{INSTALLATION.md → docs/INSTALLATION.md} +0 -0
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
## Installation
|
|
4
4
|
|
|
5
5
|
For a self-contained server on a Raspberry Pi - including the MQTT broker, and starting from a
|
|
6
|
-
blank SD card - see [INSTALLATION.md](INSTALLATION.md), which also has a script that does the whole
|
|
6
|
+
blank SD card - see [docs/INSTALLATION.md](docs/INSTALLATION.md), which also has a script that does the whole
|
|
7
7
|
thing in one go once you can ssh in.
|
|
8
8
|
|
|
9
9
|
On a unix box that is already running ...
|
|
@@ -91,7 +91,7 @@ verbose: true
|
|
|
91
91
|
and each message reappears as `Received dev/lotus/esp8266-85ea2b/humidity 71.8`. `morgan: true`
|
|
92
92
|
in `config.d/server.yaml` does the same for web requests. Turn both off again afterwards.
|
|
93
93
|
There is more on what gets written, and how to see how much, under
|
|
94
|
-
[Wear and tear on the SD card](INSTALLATION.md#wear-and-tear-on-the-sd-card).
|
|
94
|
+
[Wear and tear on the SD card](docs/INSTALLATION.md#wear-and-tear-on-the-sd-card).
|
|
95
95
|
|
|
96
96
|
Open a browser pointing at for example `localhost:8080` and you should see the UI.
|
|
97
97
|
|
|
@@ -161,7 +161,7 @@ expensive on an SD card.
|
|
|
161
161
|
To set it up as a service that runs at startup (and instructions vary between flavors of Linux)
|
|
162
162
|
|
|
163
163
|
copy and edit `extras/frugaliot.service` to `/etc/systemd/system/frugaliot.service`. As shipped it
|
|
164
|
-
matches the Raspberry Pi install in [INSTALLATION.md](INSTALLATION.md) - user `pi`, installed in
|
|
164
|
+
matches the Raspberry Pi install in [docs/INSTALLATION.md](docs/INSTALLATION.md) - user `pi`, installed in
|
|
165
165
|
`/home/pi/frugal-iot` - so on any other machine change `User`, `WorkingDirectory` and `ExecStart`
|
|
166
166
|
to the account and directory you installed into.
|
|
167
167
|
```
|
package/config.d/email.yaml
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Leave it commented out on a server that should not send mail.
|
|
5
5
|
#
|
|
6
|
-
# For Gmail - the common case, written out step by step in INSTALLATION.md section 9a:
|
|
6
|
+
# For Gmail - the common case, written out step by step in docs/INSTALLATION.md section 9a:
|
|
7
7
|
# 1. Turn on 2-Step Verification: https://myaccount.google.com/signinoptions/twosv
|
|
8
8
|
# App passwords do not exist until you do, which is where most people get stuck.
|
|
9
9
|
# 2. Create an app password: https://myaccount.google.com/apppasswords
|
package/config.d/opensearch.yaml
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
# This server's own OpenSearch - the one INSTALL-OPENSEARCH.md sets up on the server itself.
|
|
1
|
+
# This server's own OpenSearch - the one docs/INSTALL-OPENSEARCH.md sets up on the server itself.
|
|
2
2
|
#
|
|
3
3
|
# Leave it all commented out on a server without one. With it filled in, an organization's
|
|
4
4
|
# administrator can choose "OpenSearch on this server" on the dashboard's Forwarders card, and make a
|
|
5
5
|
# login for OpenSearch Dashboards on the Dashboards access card. Neither shows an address or a password:
|
|
6
6
|
# they come from here, and never leave this machine.
|
|
7
7
|
#
|
|
8
|
-
# opensearch
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
8
|
+
# Write the lines at the top level, as below: the file's name already says they are about opensearch.
|
|
9
|
+
#
|
|
10
|
+
# node: https://localhost:9200 # where this server reaches OpenSearch - on this machine.
|
|
11
|
+
# # https on a Linux install (it has a login); http://localhost:9200
|
|
12
|
+
# # only for Homebrew's OpenSearch on a Mac, which has neither
|
|
13
|
+
# username: admin # what the forwarder writes readings as
|
|
14
|
+
# password: change-me
|
|
15
|
+
# insecure: true # OpenSearch's own certificate is self-signed, which can't be checked.
|
|
16
|
+
# # Needed with https://localhost; leave it out for http
|
|
13
17
|
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
18
|
+
# # The account that makes and removes the per-organization logins on the Dashboards access card.
|
|
19
|
+
# # It must be allowed to change security settings, which is much more than the logger needs - so it
|
|
20
|
+
# # is separate, and you can leave it out if you would rather make those logins by hand.
|
|
21
|
+
# admin:
|
|
22
|
+
# username: admin
|
|
23
|
+
# password: change-me
|
|
20
24
|
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
25
|
+
# # The address Dashboards on someone's own computer uses to reach OpenSearch: https, through
|
|
26
|
+
# # Apache (docs/INSTALL-OPENSEARCH.md), never the port 9200 above.
|
|
27
|
+
# public: https://search.example.org
|
|
@@ -383,6 +383,13 @@ heatsink:
|
|
|
383
383
|
name: Heatsink Temperature
|
|
384
384
|
min: 0
|
|
385
385
|
max: 120
|
|
386
|
+
# Seeed HM3301 particulate sensor ("Grove - Laser PM2.5 Sensor") - Sensor_HM3301.
|
|
387
|
+
hm3301:
|
|
388
|
+
name: "HM3301"
|
|
389
|
+
topics:
|
|
390
|
+
- leaf: pm1
|
|
391
|
+
- leaf: pm25
|
|
392
|
+
- leaf: pm10
|
|
386
393
|
ht:
|
|
387
394
|
name: HT
|
|
388
395
|
topics:
|
|
@@ -617,6 +624,12 @@ sector:
|
|
|
617
624
|
- leaf: valve
|
|
618
625
|
leaf_from: controlouttoggle
|
|
619
626
|
name: Valve
|
|
627
|
+
# Nova Fitness SDS011 particulate sensor, as in sensor.community's airRohr - Sensor_SDS011.
|
|
628
|
+
sds011:
|
|
629
|
+
name: "SDS011"
|
|
630
|
+
topics:
|
|
631
|
+
- leaf: pm25
|
|
632
|
+
- leaf: pm10
|
|
620
633
|
sht:
|
|
621
634
|
name: SHT
|
|
622
635
|
topics:
|
|
@@ -549,6 +549,56 @@ percent:
|
|
|
549
549
|
significantvalue: 1
|
|
550
550
|
graphable: true
|
|
551
551
|
units: "%"
|
|
552
|
+
# Particulate matter, from the SDS011 or HM3301 - see sensor/pm.h in Frugal-IoT. Both are noisy,
|
|
553
|
+
# and unreliable above ~70% humidity (they count droplets as particles). Only the HM3301 has pm1.
|
|
554
|
+
pm1:
|
|
555
|
+
leaf: pm1
|
|
556
|
+
name: PM1.0
|
|
557
|
+
type: float
|
|
558
|
+
display: bar
|
|
559
|
+
min: 0
|
|
560
|
+
max: 100
|
|
561
|
+
width: 5
|
|
562
|
+
color: "#d2691e"
|
|
563
|
+
units: ug/m3
|
|
564
|
+
rw: r
|
|
565
|
+
graphable: true
|
|
566
|
+
log: true
|
|
567
|
+
duplicates:
|
|
568
|
+
significantdate: 900000
|
|
569
|
+
significantvalue: 1
|
|
570
|
+
pm10:
|
|
571
|
+
leaf: pm10
|
|
572
|
+
name: PM10
|
|
573
|
+
type: float
|
|
574
|
+
display: bar
|
|
575
|
+
min: 0
|
|
576
|
+
max: 200
|
|
577
|
+
width: 5
|
|
578
|
+
color: "#696969"
|
|
579
|
+
units: ug/m3
|
|
580
|
+
rw: r
|
|
581
|
+
graphable: true
|
|
582
|
+
log: true
|
|
583
|
+
duplicates:
|
|
584
|
+
significantdate: 900000
|
|
585
|
+
significantvalue: 1
|
|
586
|
+
pm25:
|
|
587
|
+
leaf: pm25
|
|
588
|
+
name: PM2.5
|
|
589
|
+
type: float
|
|
590
|
+
display: bar
|
|
591
|
+
min: 0
|
|
592
|
+
max: 100
|
|
593
|
+
width: 5
|
|
594
|
+
color: "#a0522d"
|
|
595
|
+
units: ug/m3
|
|
596
|
+
rw: r
|
|
597
|
+
graphable: true
|
|
598
|
+
log: true
|
|
599
|
+
duplicates:
|
|
600
|
+
significantdate: 900000
|
|
601
|
+
significantvalue: 1
|
|
552
602
|
position:
|
|
553
603
|
leaf: position
|
|
554
604
|
name: Position
|
|
@@ -17,7 +17,31 @@ Grafana reads the server with its free **Infinity** plugin, which can call any U
|
|
|
17
17
|
> Grafana's API), and the Grafana card on the dashboard clicked through by hand. Correct this page
|
|
18
18
|
> where they differ.
|
|
19
19
|
|
|
20
|
+
## Installing
|
|
21
|
+
|
|
22
|
+
#### On a Mac,
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
brew install grafana
|
|
26
|
+
brew services start grafana
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Open <http://localhost:3000>. Grafana's default login is `admin` / `admin`, and it asks you to change it.
|
|
30
|
+
Then add the Infinity plugin - in Grafana, Administration → Plugins → "Infinity" - or from the shell:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
/opt/homebrew/opt/grafana/bin/grafana cli --homepath /opt/homebrew/opt/grafana/share/grafana \
|
|
34
|
+
--pluginsDir /opt/homebrew/var/lib/grafana/plugins plugins install yesoreyeram-infinity-datasource
|
|
35
|
+
brew services restart grafana
|
|
36
|
+
```
|
|
37
|
+
To stop it: `brew services stop grafana` (Homebrew restarts it at login until you do).
|
|
38
|
+
|
|
39
|
+
#### On Windows, Linux and other systems
|
|
40
|
+
|
|
41
|
+
For other systems, Grafana's own download page has installers for [Windows, Linux and others](https://grafana.com/grafana/download).
|
|
42
|
+
|
|
20
43
|
## Setting it up
|
|
44
|
+
Access Grafana from your browser at [localhost:3000](http://localhost:3000)
|
|
21
45
|
|
|
22
46
|
Anyone who can **read** the organization can make a token for themselves - you do not need to be an
|
|
23
47
|
administrator. A token is yours: Grafana sees what *you* can see, so a token made by someone who can
|
|
@@ -26,22 +50,29 @@ read only one project shows that project only.
|
|
|
26
50
|
1. **Install the Infinity plugin in Grafana.** In Grafana: Administration → Plugins, search for
|
|
27
51
|
"Infinity", install it, and restart Grafana if it asks. (Installing Grafana itself is in
|
|
28
52
|
[INSTALL-OPENSEARCH.md](INSTALL-OPENSEARCH.md).)
|
|
29
|
-
2. **Make a token.** In the dashboard, open the project's back, then the **Grafana** card. Type a name
|
|
53
|
+
2. **Make a token.** In the Frugal IoT dashboard, open the project's back, then the **Grafana** card. Type a name
|
|
30
54
|
for this Grafana (so it can be revoked on its own later) and press *Make a token*. The token is shown
|
|
31
55
|
**once** - only a hash is kept, so it cannot be looked up again. If you lose it, make one with the
|
|
32
56
|
same name, which replaces it.
|
|
33
|
-
3. **Give Grafana the data source.** Either
|
|
34
|
-
|
|
57
|
+
3. **Give Grafana the data source.** Either:
|
|
58
|
+
a: press *Download the data source file* in the same place and
|
|
59
|
+
put it in Grafana's `provisioning/datasources` folder (On a Mac typically in /opt/homebrew/Cellar/grafana/13.3.0/share/grafana/conf/provisioning),
|
|
60
|
+
then restart Grafana:
|
|
61
|
+
- On Mac: `brew services restart grafana`;
|
|
62
|
+
|
|
63
|
+
or add it by hand in
|
|
35
64
|
Grafana under Connections → Data sources → Add → **Infinity**:
|
|
36
65
|
- Authentication: **Bearer Token**, with the token
|
|
37
66
|
- Allowed hosts: the address you reached this dashboard at, e.g. `https://frugaliot.naturalinnovation.org`
|
|
38
|
-
4. **Import the dashboard.**
|
|
39
|
-
|
|
67
|
+
4. **Import the dashboard.**
|
|
68
|
+
* On FrugalIoT: In the Grafana card press *Download the dashboard*.
|
|
69
|
+
* Then in Grafana choose
|
|
70
|
+
Dashboards → New → Import, upload the file, and pick the data source from step 3 when it asks.
|
|
40
71
|
|
|
41
72
|
The dashboard has a list of every topic at the top to choose from, and the time range at the top right.
|
|
42
73
|
The file already has this server and organization filled in.
|
|
43
74
|
|
|
44
|
-
A token lets one Grafana read **one organization**, read-only
|
|
75
|
+
A token lets one Grafana read **one organization**, read-only - and only the
|
|
45
76
|
projects of it that the person who made the token may read. For another
|
|
46
77
|
organization, make its own token, data source and import - the dashboard file is separate for each, so
|
|
47
78
|
importing a second does not replace the first. *Revoke* on the card cuts off a Grafana at once.
|