purpleair 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/purpleair_mqtt_bridge +112 -19
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 060b300e03f93347681d274759857922d8455b0656163c7d41cea67451558323
|
4
|
+
data.tar.gz: 79f6d753281474e92b9089b0998a0244e07032d31073bfc6ecc58731715a2bf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91296a0d880f6493ec018ae1d13d067be69a599a70079b11074a21a14e4530233f501d053ce30e7315e8c78a97651cb3664bf32d4b50deb227caff5987e77e08
|
7
|
+
data.tar.gz: 19ba9b97408f248fe315d5f7ae96b2820f4ec4d286f92c0c3f9bfe20babce4ccff258c99ffbd194fcf0639b450d015a46b398de7c973971b0c3808d8a594b6e2
|
data/exe/purpleair_mqtt_bridge
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require "faraday_middleware"
|
5
|
-
require "
|
5
|
+
require "mqtt-homeassistant"
|
6
6
|
require "optparse"
|
7
7
|
|
8
8
|
refresh = 30.0
|
@@ -36,13 +36,53 @@ end
|
|
36
36
|
data = purple.get.body
|
37
37
|
|
38
38
|
homie = MQTT::Homie::Device.new(MQTT::Homie.escape_id(data["Geo"]), "PurpleAir Sensor", mqtt: ARGV[1])
|
39
|
+
homie.home_assistant_device = {
|
40
|
+
manufacturer: "PurpleAir, Inc.",
|
41
|
+
sw_version: data["version"],
|
42
|
+
model: data["hardwarediscovered"]
|
43
|
+
}
|
44
|
+
|
39
45
|
device = homie.node("device", "Device", "Device")
|
40
|
-
device.property("temperature",
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
+
device.property("temperature",
|
47
|
+
"Current Temperature",
|
48
|
+
:integer,
|
49
|
+
data["current_temp_f"],
|
50
|
+
unit: "°F",
|
51
|
+
hass: { sensor: { device_class: :temperature,
|
52
|
+
state_class: :measurement } })
|
53
|
+
device.property("relative-humidity",
|
54
|
+
"Current Relative Humidity",
|
55
|
+
:integer,
|
56
|
+
data["current_humidity"],
|
57
|
+
format: 0..100,
|
58
|
+
unit: "%",
|
59
|
+
hass: { sensor: { device_class: :humidity,
|
60
|
+
state_class: :measurement } })
|
61
|
+
device.property("dewpoint",
|
62
|
+
"Current Dew Point",
|
63
|
+
:integer,
|
64
|
+
data["current_dewpoint_f"],
|
65
|
+
unit: "°F",
|
66
|
+
hass: { sensor: { device_class: :temperature,
|
67
|
+
icon: "mdi:water-opacity",
|
68
|
+
state_class: :measurement } })
|
69
|
+
device.property("pressure",
|
70
|
+
"Barometric Pressure",
|
71
|
+
:integer,
|
72
|
+
data["pressure"],
|
73
|
+
unit: "hPA",
|
74
|
+
hass: { sensor: { device_class: :pressure,
|
75
|
+
state_class: :measurement } })
|
76
|
+
device.property("rssi",
|
77
|
+
"WiFi RSSI",
|
78
|
+
:integer,
|
79
|
+
data["rssi"],
|
80
|
+
unit: "dB",
|
81
|
+
hass: { sensor: { device_class: :signal_strength,
|
82
|
+
state_class: :measurement,
|
83
|
+
entity_category: :diagnostic } })
|
84
|
+
|
85
|
+
CHANNELS = %w[a b].freeze
|
46
86
|
|
47
87
|
FIELDS = %w[
|
48
88
|
pm2.5_aqi
|
@@ -66,19 +106,72 @@ def get_fields(data, channel_id)
|
|
66
106
|
result
|
67
107
|
end
|
68
108
|
|
69
|
-
|
109
|
+
CHANNELS.each do |channel_id|
|
70
110
|
fields = get_fields(data, channel_id)
|
71
111
|
channel = homie.node(channel_id, "Sensor Channel #{channel_id.upcase}", "Air Sensor")
|
72
|
-
channel.property("pm2-5-aqi",
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
channel.property("
|
79
|
-
|
80
|
-
|
81
|
-
|
112
|
+
channel.property("pm2-5-aqi",
|
113
|
+
"PM2.5 AQI",
|
114
|
+
:integer,
|
115
|
+
fields["pm2.5_aqi"],
|
116
|
+
hass: { sensor: { device_class: :aqi,
|
117
|
+
state_class: :measurement } })
|
118
|
+
channel.property("pm1-0-atm",
|
119
|
+
"PM1.0",
|
120
|
+
:float,
|
121
|
+
fields["pm1_0_atm"],
|
122
|
+
unit: "µg/m3",
|
123
|
+
hass: { sensor: { device_class: :pm1,
|
124
|
+
state_class: :measurement } })
|
125
|
+
channel.property("pm2-5-atm",
|
126
|
+
"PM2.5",
|
127
|
+
:float,
|
128
|
+
fields["pm2_5_atm"],
|
129
|
+
unit: "µg/m3",
|
130
|
+
hass: { sensor: { device_class: :pm25,
|
131
|
+
state_class: :measurement } })
|
132
|
+
channel.property("pm10-0-atm",
|
133
|
+
"PM10",
|
134
|
+
:float,
|
135
|
+
fields["pm10_0_atm"],
|
136
|
+
unit: "µg/m3",
|
137
|
+
hass: { sensor: { device_class: :pm10,
|
138
|
+
state_class: :measurement } })
|
139
|
+
channel.property("p-0-3-um",
|
140
|
+
"# particles >= 0.3µm per decileter",
|
141
|
+
:float,
|
142
|
+
fields["p_0_3_um"],
|
143
|
+
hass: { sensor: { state_class: :measurement,
|
144
|
+
entity_category: :diagnostic } })
|
145
|
+
channel.property("p-0-5-um",
|
146
|
+
"# particles >= 0.5µm per decileter",
|
147
|
+
:float,
|
148
|
+
fields["p_0_5_um"],
|
149
|
+
hass: { sensor: { state_class: :measurement,
|
150
|
+
entity_category: :diagnostic } })
|
151
|
+
channel.property("p-1-0-um",
|
152
|
+
"# particles >= 1.0µm per decileter",
|
153
|
+
:float,
|
154
|
+
fields["p_1_0_um"],
|
155
|
+
hass: { sensor: { state_class: :measurement,
|
156
|
+
entity_category: :diagnostic } })
|
157
|
+
channel.property("p-2-5-um",
|
158
|
+
"# particles >= 2.5µm per decileter",
|
159
|
+
:float,
|
160
|
+
fields["p_2_5_um"],
|
161
|
+
hass: { sensor: { state_class: :measurement,
|
162
|
+
entity_category: :diagnostic } })
|
163
|
+
channel.property("p-5-0-um",
|
164
|
+
"# particles >= 5.0µm per decileter",
|
165
|
+
:float,
|
166
|
+
fields["p_5_0_um"],
|
167
|
+
hass: { sensor: { state_class: :measurement,
|
168
|
+
entity_category: :diagnostic } })
|
169
|
+
channel.property("p-10-0-um",
|
170
|
+
"# particles >= 10µm per decileter",
|
171
|
+
:float,
|
172
|
+
fields["p_10_0_um"],
|
173
|
+
hass: { sensor: { state_class: :measurement,
|
174
|
+
entity_category: :diagnostic } })
|
82
175
|
end
|
83
176
|
|
84
177
|
homie.publish
|
@@ -91,7 +184,7 @@ loop do
|
|
91
184
|
device["pressure"].value = data["pressure"]
|
92
185
|
device["rssi"].value = data["rssi"]
|
93
186
|
|
94
|
-
|
187
|
+
CHANNELS.each do |channel_id|
|
95
188
|
fields = get_fields(data, channel_id)
|
96
189
|
channel = homie[channel_id]
|
97
190
|
FIELDS.each do |field|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: purpleair
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday_middleware
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: mqtt-homeassistant
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1
|
33
|
+
version: '0.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1
|
40
|
+
version: '0.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: net-http-persistent
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.19'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-performance
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.12'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.12'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rubocop-rake
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,7 +133,8 @@ files:
|
|
119
133
|
homepage: https://github.com/ccutrer/ruby-purpleair
|
120
134
|
licenses:
|
121
135
|
- MIT
|
122
|
-
metadata:
|
136
|
+
metadata:
|
137
|
+
rubygems_mfa_required: 'true'
|
123
138
|
post_install_message:
|
124
139
|
rdoc_options: []
|
125
140
|
require_paths:
|