File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -16,14 +16,16 @@ async def main():
1616 data = Luftdaten (155 , loop , session )
1717 await data .get_data ()
1818
19+ if not data .valid_sensor :
20+ print ("Station is not available:" , data .sensor_id )
21+ return
22+
1923 if data .values and data .meta :
2024 # Print the sensor values
2125 print ("Sensor values:" , data .values )
2226
2327 # Print the coordinates fo the sensor
2428 print ("Location:" , data .meta ['latitude' ], data .meta ['longitude' ])
25- else :
26- print ("Station is not available:" , data .sensor_id )
2729
2830
2931loop = asyncio .get_event_loop ()
Original file line number Diff line number Diff line change @@ -68,3 +68,8 @@ async def get_data(self):
6868 self .meta ['latitude' ] = float (sensor_data ['location' ]['latitude' ])
6969 except (TypeError , IndexError ):
7070 raise exceptions .LuftdatenError ()
71+
72+ @property
73+ def valid_sensor (self ):
74+ """Return True if the sensor ID is valid."""
75+ return True if self .values else False
You can’t perform that action at this time.
0 commit comments