Skip to content

Commit c88acc8

Browse files
authored
Use floating point values (#372)
1 parent 44040bf commit c88acc8

File tree

4 files changed

+74
-12
lines changed

4 files changed

+74
-12
lines changed

src/airgradient/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ class Measures(DataClassORJSONMixin):
2020
model: str = field(metadata=field_options(alias="model"))
2121
rco2: int | None = None
2222
pm01: int | None = None
23-
pm02: int | None = None
23+
pm02: float | None = None
2424
raw_pm02: int | None = field(default=None, metadata=field_options(alias="pm02"))
25-
compensated_pm02: int | None = field(
25+
compensated_pm02: float | None = field(
2626
default=None, metadata=field_options(alias="pm02Compensated")
2727
)
2828
pm10: int | None = None
2929
total_volatile_organic_component_index: int | None = field(
3030
default=None, metadata=field_options(alias="tvocIndex")
3131
)
32-
raw_total_volatile_organic_component: int | None = field(
32+
raw_total_volatile_organic_component: float | None = field(
3333
default=None, metadata=field_options(alias="tvocRaw")
3434
)
3535
pm003_count: int | None = field(
@@ -38,7 +38,7 @@ class Measures(DataClassORJSONMixin):
3838
nitrogen_index: int | None = field(
3939
default=None, metadata=field_options(alias="noxIndex")
4040
)
41-
raw_nitrogen: int | None = field(
41+
raw_nitrogen: float | None = field(
4242
default=None, metadata=field_options(alias="noxRaw")
4343
)
4444
ambient_temperature: float | None = field(

tests/__snapshots__/test_airgradient.ambr

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,65 @@
2626
'nitrogen_index': 1,
2727
'pm003_count': 270,
2828
'pm01': 22,
29-
'pm02': 34,
29+
'pm02': 34.0,
3030
'pm10': 41,
3131
'raw_ambient_temperature': 23.1,
32-
'raw_nitrogen': 16931,
32+
'raw_nitrogen': 16931.0,
3333
'raw_pm02': 34,
3434
'raw_relative_humidity': 32.0,
35-
'raw_total_volatile_organic_component': 31792,
35+
'raw_total_volatile_organic_component': 31792.0,
3636
'rco2': 778,
3737
'relative_humidity': 47.0,
3838
'serial_number': '84fce612f5b8',
3939
'signal_strength': -52,
4040
'total_volatile_organic_component_index': 99,
4141
})
4242
# ---
43+
# name: test_current_fixtures[current_measures_2.json]
44+
dict({
45+
'ambient_temperature': 20.35,
46+
'boot_time': 309,
47+
'compensated_ambient_temperature': 20.35,
48+
'compensated_pm02': 6.83,
49+
'compensated_relative_humidity': 32.51,
50+
'firmware_version': '3.1.21',
51+
'model': 'I-9PSL',
52+
'nitrogen_index': 1,
53+
'pm003_count': 256,
54+
'pm01': 0,
55+
'pm02': 6.83,
56+
'pm10': 2,
57+
'raw_ambient_temperature': 20.35,
58+
'raw_nitrogen': 15568.08,
59+
'raw_pm02': 2,
60+
'raw_relative_humidity': 32.51,
61+
'raw_total_volatile_organic_component': 33774.83,
62+
'rco2': 566,
63+
'relative_humidity': 32.51,
64+
'serial_number': 'aaaaaaaaaa',
65+
'signal_strength': -40,
66+
'total_volatile_organic_component_index': 138,
67+
})
68+
# ---
4369
# name: test_current_fixtures[current_measures_zero.json]
4470
dict({
4571
'ambient_temperature': 0.0,
4672
'boot_time': 4,
4773
'compensated_ambient_temperature': 0.0,
48-
'compensated_pm02': 0,
74+
'compensated_pm02': 0.0,
4975
'compensated_relative_humidity': 0.0,
5076
'firmware_version': '3.1.1',
5177
'model': 'I-9PSL',
5278
'nitrogen_index': 1,
5379
'pm003_count': 270,
5480
'pm01': 22,
55-
'pm02': 0,
81+
'pm02': 0.0,
5682
'pm10': 41,
5783
'raw_ambient_temperature': 23.1,
58-
'raw_nitrogen': 16931,
84+
'raw_nitrogen': 16931.0,
5985
'raw_pm02': 34,
6086
'raw_relative_humidity': 32.0,
61-
'raw_total_volatile_organic_component': 31792,
87+
'raw_total_volatile_organic_component': 31792.0,
6288
'rco2': 778,
6389
'relative_humidity': 0.0,
6490
'serial_number': '84fce612f5b8',
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"pm01": 0,
3+
"pm02": 2,
4+
"pm10": 2,
5+
"pm01Standard": 0,
6+
"pm02Standard": 2,
7+
"pm10Standard": 2,
8+
"pm003Count": 256,
9+
"pm005Count": 216.17,
10+
"pm01Count": 0,
11+
"pm02Count": 0,
12+
"pm50Count": 0,
13+
"pm10Count": 0,
14+
"atmp": 20.35,
15+
"atmpCompensated": 20.35,
16+
"rhum": 32.51,
17+
"rhumCompensated": 32.51,
18+
"pm02Compensated": 6.83,
19+
"rco2": 566,
20+
"tvocIndex": 138,
21+
"tvocRaw": 33774.83,
22+
"noxIndex": 1,
23+
"noxRaw": 15568.08,
24+
"boot": 309,
25+
"bootCount": 309,
26+
"wifi": -40,
27+
"ledMode": "co2",
28+
"serialno": "aaaaaaaaaa",
29+
"firmware": "3.1.21",
30+
"model": "I-9PSL"
31+
}

tests/test_airgradient.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ async def response_handler(_: str, **_kwargs: Any) -> CallbackResult:
145145

146146
@pytest.mark.parametrize(
147147
"fixture",
148-
["current_measures.json", "measures_after_boot.json", "current_measures_zero.json"],
148+
[
149+
"current_measures.json",
150+
"current_measures_2.json",
151+
"measures_after_boot.json",
152+
"current_measures_zero.json",
153+
],
149154
)
150155
async def test_current_fixtures(
151156
responses: aioresponses,

0 commit comments

Comments
 (0)