1212_INSTANCE = "https://api.opensensemap.org/boxes/{id}"
1313
1414_TITLES = {
15- "Air pressure" : (
15+ "Air Pressure" : (
16+ "Pressure" ,
1617 "Luftdruck" ,
1718 "Ilmanpaine" ,
18- ), # fi
19+ ),
1920 "Humidity" : (
2021 "rel. Luftfeuchte" ,
22+ "rel. Humidity" ,
2123 "Ilmankosteus" ,
2224 "Kosteus" ,
23- ), # fi
25+ ),
2426 "Illuminance" : (
2527 "Beleuchtungsstärke" ,
2628 "Valoisuus" ,
27- "Valaistuksen voimakkuus" , # fi
29+ "Valaistuksen voimakkuus" ,
30+ "Ambient Light" ,
2831 ),
2932 "Temperature" : (
3033 "Temperatur" ,
3134 "Lämpötila" ,
32- ), # fi
35+ ),
3336 "UV" : (
37+ "UV Index" ,
3438 "UV-Intensität" ,
3539 "UV-säteily" ,
36- ), # fi
40+ ),
41+ "Precipitation" : (
42+ "Rain" ,
43+ "Regen" ,
44+ "Niederschlag" ,
45+ ),
46+ "Wind Speed" : ("Windgeschwindigkeit" ,),
47+ "Wind Direction" : ("Windrichtung" ,),
3748}
3849
3950
@@ -78,6 +89,22 @@ def coordinates(self):
7889 """Return the coordinates of the station."""
7990 return self .data ["currentLocation" ]["coordinates" ]
8091
92+ @property
93+ def exposure (self ):
94+ """Return the exposure of the station."""
95+ try :
96+ return self .data ["exposure" ]
97+ except KeyError :
98+ return None
99+
100+ @property
101+ def model (self ):
102+ """Return the model of the station."""
103+ try :
104+ return self .data ["model" ]
105+ except KeyError :
106+ return None
107+
81108 @property
82109 def pm10 (self ):
83110 """Return the particulate matter 10 value."""
@@ -88,6 +115,11 @@ def pm2_5(self):
88115 """Return the particulate matter 2.5 value."""
89116 return self .get_value ("PM2.5" )
90117
118+ @property
119+ def pm1_0 (self ):
120+ """Return the particulate matter 1.0 value."""
121+ return self .get_value ("PM1.0" )
122+
91123 @property
92124 def temperature (self ):
93125 """Return the temperature of a station."""
@@ -106,7 +138,7 @@ def vcc(self):
106138 @property
107139 def air_pressure (self ):
108140 """Return the current air pressure of a station."""
109- return self .get_value ("Air pressure " )
141+ return self .get_value ("Air Pressure " )
110142
111143 @property
112144 def illuminance (self ):
@@ -123,14 +155,31 @@ def radioactivity(self):
123155 """Return the current radioactivity value of a station."""
124156 return self .get_value ("Radioactivity" )
125157
158+ @property
159+ def wind_speed (self ):
160+ """Return the current wind speed value of a station."""
161+ return self .get_value ("Wind Speed" )
162+
163+ @property
164+ def wind_direction (self ):
165+ """Return the current wind direction value of a station."""
166+ return self .get_value ("Wind Direction" )
167+
168+ @property
169+ def precipitation (self ):
170+ """Return the current precipitation value of a station."""
171+ return self .get_value ("Precipitation" )
172+
126173 def get_value (self , key ):
127174 """Extract a value for a given key."""
128175 for title in _TITLES .get (key , ()) + (key ,):
129176 try :
130177 value = [
131178 entry ["lastMeasurement" ]["value" ]
132179 for entry in self .data ["sensors" ]
133- if entry ["title" ] == title
180+ if entry ["title" ].casefold () == title .casefold ()
181+ and "lastMeasurement" in entry
182+ and "value" in entry ["lastMeasurement" ]
134183 ][0 ]
135184 return value
136185 except (IndexError , TypeError ):
0 commit comments