-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-rooms.sh
executable file
·49 lines (45 loc) · 1.07 KB
/
update-rooms.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# © Copyright 2015 Robin Kearney
# Licensed under the MIT license with an additional non-advertising clause
# See https://github.com/rk295/maplin-webremote
# Quick hack in bash to turn a vaguely user friendly lump of JSON
# into a single line, retained message on a given MQTT topic for
# the Web UI to parse into a list of buttons
host="trin"
topic="rooms/switches"
cat <<EOF | tr '\n' ' ' | sed 's/ //g' | mosquitto_pub -h $host -t $topic -r -s
{
"rooms": [
{
"name": "Lounge",
"channel": 4,
"button": 1
},
{
"name": "Tank",
"channel": 4,
"button": 2
},
{
"name": "Sofa",
"channel": 4,
"button": 3
},
{
"name": "Outside",
"channel": 4,
"button": 4
},
{
"name": "Spareroom",
"channel": 3,
"button": 1
},
{
"name": "OurRoom",
"channel": 3,
"button": 2
}
]
}
EOF