pulseeco package
Submodules
pulseeco.data_types module
- class pulseeco.data_types.DataValue(*args, **kwargs)[source]
Bases:
dict- position: str
- sensorId: str
- stamp: str
- type: str
- value: str
- year: Optional[int]
pulseeco.pulseeco module
- class pulseeco.pulseeco.PulseEco(auth: Tuple[str, str], base_url: str = 'https://{city_name}.pulse.eco/rest/{end_point}')[source]
Bases:
objectpulse.eco API wrapper
- avg_data(city_name: str, period: str, from_: Union[str, datetime.datetime], to: Union[str, datetime.datetime], type: str, sensor_id: Optional[str] = None) List[pulseeco.data_types.DataValue][source]
Get average data for a query in given time periods
- Parameters
city_name – the city name
period – the period of the data (day, week, month)
from – the start datetime of the data
to – the end datetime of the data
type – the type ID of the sensor
sensor_id – the unique ID of the sensor
- Returns
average data
- current(city_name: str) List[pulseeco.data_types.DataValue][source]
Get the last received valid data for each sensor
Will not return sensor data older than 2h.
- Parameters
city_name – the city name
- Returns
sensor data of the past 2h
- data24h(city_name: str) List[pulseeco.data_types.DataValue][source]
Get all of the data in the past 24h
The data values are sorted ascending by their timestamp.
- Parameters
city_name – the city name
- Returns
senssor data of the past 24h
- data_raw(city_name: str, from_: Union[str, datetime.datetime], to: Union[str, datetime.datetime], sensor_id: Optional[str] = None, type: Optional[str] = None) List[pulseeco.data_types.DataValue][source]
Get raw data for a given query
- Parameters
city_name – the city name
from – the start datetime of the data
to – the end datetime of the data
sensor_id – the unique ID of the sensor
type – the type ID of the sensor
- Returns
raw data
- overall(city_name: str) pulseeco.data_types.Overall[source]
Get the current average data for all sensors per value
Example:
{ 'cityName': 'skopje', 'values': { 'no2': '22', 'o3': '4', 'pm25': '53', 'pm10': '73', 'temperature': '7', 'humidity': '71', 'pressure': '992', 'noise_dba': '43' } }
- Parameters
city_name – the city name
- Returns
overall data for the city
- sensor(city_name: str, sensor_id: str) pulseeco.data_types.Sensor[source]
Get a sensor by it’s ID
- Parameters
city_name – the city name
sensor_id – the unique ID of the sensor
- Returns
sensor
- sensors(city_name: str) List[pulseeco.data_types.Sensor][source]
Get all sensors for a city
- Parameters
city_name – the city name
- Returns
list of sensors
pulseeco.utils module
- pulseeco.utils.convert_datetime_to_str(datetime: datetime.datetime) str[source]
Convert a datetime object to a string
- Parameters
datetime – a datetime object
- Returns
an isoformat string
- pulseeco.utils.split_datetime_span(fr: Union[str, datetime.datetime], to: Union[str, datetime.datetime], td: datetime.timedelta) List[Tuple[datetime.datetime, datetime.datetime]][source]
- Split a datetime span into a list of (fr, to) datetime pairs
with a given maximum timedelta
- Parameters
fr – the start datetime of the span
to – the end datetime of the span
td – the timedelta between the datetimes
- Returns
a list of datetimes