awair 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/exe/awair_mqtt_bridge +58 -11
  3. metadata +23 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 788ff24e23ac2945b69b285a3a1b449f87927072d4f4e80367146304d85ff1cd
4
- data.tar.gz: 69b050275c5b63911f9cf32e35cdd692ab09d52452f726ce0e965a16ba22688d
3
+ metadata.gz: ce8d30d13d9d8b60c466ebc147fb669ede41ffd027cacb6e33d90eaf46824a4f
4
+ data.tar.gz: debd26604af53badc92938a14a1e6d8e3e98973ee7ba25802ae914e6125f5f7a
5
5
  SHA512:
6
- metadata.gz: f78ab06856013674cbfd8702a4e15926860124dd04aafa8161b0374f1940bb00b746eb674143f9e6d328b4891d9f9e5dc0ab4b448aee785267380268c4ce506a
7
- data.tar.gz: 9d25f750205b8a66e3a037c86c437bf5e9c961c7e8bb6de11d6e48aa409fd5e2549b1711c41b64c93f9db165fe6262b8191a3b1acb87d33d98996bdc1df07965
6
+ metadata.gz: 5cd9d755e83fefca0c5c789c95147f12d292751de7ddaa4baacf125b7fed74b53d946ea83cd217f4762feb7f305bf82223d34ace92005180a2c20f5261928bcc
7
+ data.tar.gz: '048f27b5cedaf24b27cf82797d48d1e0e59eb3c89335513e714e9b98dbd71d7a1fe310177449d6811a68d82be6752365ac91822b2f4deb255bab1e015aa51394'
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "faraday_middleware"
5
- require "homie-mqtt"
5
+ require "mqtt-homeassistant"
6
6
  require "optparse"
7
7
 
8
8
  refresh = 30.0
@@ -40,18 +40,65 @@ unit = fahrenheit ? "°F" : "°C"
40
40
  def convert_unit(number, use_fahrenheit)
41
41
  return number unless use_fahrenheit
42
42
 
43
- number * 9 / 5 + 32
43
+ (number * 9 / 5).round(2) + 32
44
44
  end
45
45
 
46
- homie = MQTT::Homie::Device.new(MQTT::Homie.escape_id(config["device_uuid"]), "Awair Sensor", mqtt: ARGV[1])
47
- device = homie.node("device", "Device", "Device")
48
- device.property("score", "Air Quality Score", :integer, data["score"], format: 0..100, unit: "%")
49
- device.property("dewpoint", "Dew Point", :float, convert_unit(data["dew_point"], fahrenheit), unit: unit)
50
- device.property("temperature", "Current Temperature", :float, convert_unit(data["temp"], fahrenheit), unit: unit)
51
- device.property("relative-humidity", "Current Relative Humidity", :float, data["humid"], format: 0..100, unit: "%")
52
- device.property("co2", "CO₂ Concentration", :integer, data["co2"], unit: "ppm")
53
- device.property("tvocs", "TVOCs Concentration", :integer, data["voc"], unit: "ppb")
54
- device.property("pm2-5", "Fine particle concentration", :integer, data["pm25"], unit: "µg/m³")
46
+ homie = MQTT::Homie::Device.new(MQTT::Homie.escape_id(config["device_uuid"]), "Awair Air Quality Sensor", mqtt: ARGV[1])
47
+ homie.home_assistant_device = {
48
+ manufacturer: "Awair Inc.",
49
+ sw_version: config["fw_version"]
50
+ }
51
+ device = homie.node("device", "Awair Air Quality Sensor", "Device")
52
+ device.property("score",
53
+ "Air Quality Score",
54
+ :integer,
55
+ data["score"],
56
+ format: 0..100,
57
+ unit: "%",
58
+ hass: { sensor: { icon: "mdi:counter",
59
+ state_class: :measurement } })
60
+ device.property("dewpoint",
61
+ "Dew Point",
62
+ :float,
63
+ convert_unit(data["dew_point"], fahrenheit),
64
+ unit: unit,
65
+ hass: { sensor: { device_class: :temperature,
66
+ icon: "mdi:water-opacity",
67
+ state_class: :measurement } })
68
+ device.property("temperature",
69
+ "Current Temperature",
70
+ :float,
71
+ convert_unit(data["temp"], fahrenheit),
72
+ unit: unit,
73
+ hass: { sensor: { device_class: :temperature,
74
+ state_class: :measurement } })
75
+ device.property("relative-humidity",
76
+ "Current Relative Humidity",
77
+ :float, data["humid"],
78
+ format: 0..100,
79
+ unit: "%",
80
+ hass: { sensor: { device_class: :humidity,
81
+ state_class: :measurement } })
82
+ device.property("co2",
83
+ "CO₂ Concentration",
84
+ :integer, data["co2"],
85
+ unit: "ppm",
86
+ hass: { sensor: { device_class: :carbon_dioxide,
87
+ state_class: :measurement } })
88
+ device.property("tvocs",
89
+ "TVOCs Concentration",
90
+ :integer,
91
+ data["voc"],
92
+ unit: "ppb",
93
+ hass: { sensor: { device_class: :volatile_organic_compounds,
94
+ state_class: :measurement } })
95
+ device.property("pm2-5",
96
+ "Fine particle concentration",
97
+ :integer,
98
+ data["pm25"],
99
+ unit: "µg/m³",
100
+ hass: { sensor: { device_class: :pm25,
101
+ state_class: :measurement } })
55
102
 
56
103
  homie.publish
57
104
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awair
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-10-20 00:00:00.000000000 Z
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: homie-mqtt
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.4'
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.4'
40
+ version: '0.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: net-http-persistent
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,28 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.19'
89
+ version: '1.23'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.19'
96
+ version: '1.23'
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-awair
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: