This repository was archived by the owner on Jan 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision.rb
executable file
·82 lines (67 loc) · 2.33 KB
/
provision.rb
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env ruby
require 'homebus'
require 'json'
require 'pp'
CONFIG_FILE='.meteo.json'
homebus_config = []
if File.exists? CONFIG_FILE
f = File.open CONFIG_FILE, 'r'
homebus_config = JSON.parse f.read, symbolize_names: true
f.close
end
provision_request = {
friendly_name: 'PDX Hackerspace Meteobridge Weather Station',
friendly_location: 'Portland, OR',
manufacturer: 'Homebus',
model: 'Meteobridge',
pin: 0,
serial_number: 'indoor',
devices: [ {
friendly_name: 'Indoor Conditions',
friendly_location: 'Portland, OR',
update_frequency: 0,
index: 0,
accuracy: 0,
precision: 0,
wo_topics: [ 'org.homebus.experimental.weather', 'org.homebus.experimental.air' ],
ro_topics: [],
rw_topics: []
}
]
}
result = HomeBus.provision provision_request
auth_info = {}
auth_info[:indoor_auth] = { uuid: result[:uuid],
mqtt_server: result[:host],
mqtt_port: result[:port],
mqtt_username: result[:username],
mqtt_password: result[:password]
}
provision_request = {
friendly_name: 'PDX Hackerspace Meteobridge Weather Station',
friendly_location: 'Portland, OR',
manufacturer: 'Homebus',
model: 'Meteobridge',
pin: 0,
serial_number: 'outdoor',
devices: [ {
friendly_name: 'Outdoor Conditions',
friendly_location: 'Portland, OR',
update_frequency: 0,
index: 0,
accuracy: 0,
precision: 0,
wo_topics: [ 'temperature', 'pressure', 'hunmidity', 'rain_total', 'rain_average', 'wind_average', 'wind_direciton' ],
ro_topics: [],
rw_topics: []
}
]
}
result = HomeBus.provision provision_request
auth_info[:outdoor_auth] = { uuid: result[:uuid],
mqtt_server: result[:host],
mqtt_port: result[:port],
mqtt_username: result[:username],
mqtt_password: result[:password]
}
File.open(CONFIG_FILE, 'w') do |f| f.write(JSON.pretty_generate(auth_info)) end