diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/404.html b/404.html new file mode 100644 index 0000000..22eee2d --- /dev/null +++ b/404.html @@ -0,0 +1,317 @@ + + + +
+ + + + + + + + + + + + + +PulseEcoAPI
+
+
+
+ Bases: PulseEcoAPIBase
Low level unsafe pulse.eco API wrapper.
+ +pulseeco/api/pulse_eco_api.py
69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 |
|
__init__(city_name, auth=None, base_url=PULSE_ECO_BASE_URL_FORMAT, session=None)
+
+Initialize the pulse.eco API wrapper.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
city_name |
+
+ str
+ |
+
+
+
+ the city name + |
+ + required + | +
auth |
+
+ tuple[str, str] | None
+ |
+
+
+
+ a tuple of (email, password), defaults to None + |
+
+ None
+ |
+
base_url |
+
+ str
+ |
+
+
+
+ the base URL of the API, defaults to 'https://{city_name}.pulse.eco/rest/{end_point}' + |
+
+ PULSE_ECO_BASE_URL_FORMAT
+ |
+
session |
+
+ Session | None
+ |
+
+
+
+ a requests session , use this to customize the session and add retries, defaults to None + |
+
+ None
+ |
+
pulseeco/api/pulse_eco_api.py
avg_data(period, from_, to, type, sensor_id=None)
+
+Get average data for a city.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
period |
+
+ str
+ |
+
+
+
+ the period of the average data (day, week, month) + |
+ + required + | +
from_ |
+
+ str | datetime
+ |
+
+
+
+ the start datetime of the data as a datetime object or an isoformat string + |
+ + required + | +
to |
+
+ str | datetime
+ |
+
+
+
+ the end datetime of the data as a datetime object or an isoformat string + |
+ + required + | +
type |
+
+ str
+ |
+
+
+
+ the data value type + |
+ + required + | +
sensor_id |
+
+ str | None
+ |
+
+
+
+ the unique ID of the sensor, defaults to None + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ list[DataValueAvg]
+ |
+
+
+
+ a list of average data values + |
+
pulseeco/api/pulse_eco_api.py
current()
+
+Get the last received valid data for each sensor in a city
+Will not return sensor data older than 2 hours.
+ + + +Returns:
+Type | +Description | +
---|---|
+ list[DataValueRaw]
+ |
+
+
+
+ a list of current data values + |
+
pulseeco/api/pulse_eco_api.py
data24h()
+
+Get 24h data for a city.
+The data values are sorted ascending by their timestamp.
+ + + +Returns:
+Type | +Description | +
---|---|
+ list[DataValueRaw]
+ |
+
+
+
+ a list of data values for the past 24 hours + |
+
pulseeco/api/pulse_eco_api.py
data_raw(from_, to, type=None, sensor_id=None)
+
+Get raw data for a city.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
from_ |
+
+ str | datetime
+ |
+
+
+
+ the start datetime of the data as a datetime object or an isoformat string + |
+ + required + | +
to |
+
+ str | datetime
+ |
+
+
+
+ the end datetime of the data as a datetime object or an isoformat string + |
+ + required + | +
type |
+
+ str | None
+ |
+
+
+
+ the data value type, defaults to None + |
+
+ None
+ |
+
sensor_id |
+
+ str | None
+ |
+
+
+
+ the unique ID of the sensor, defaults to None + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ list[DataValueRaw]
+ |
+
+
+
+ a list of data values + |
+
pulseeco/api/pulse_eco_api.py
overall()
+
+Get the current average data for all sensors per value for a city.
+{
+ 'cityName': 'skopje',
+ 'values': {
+ 'no2': '22',
+ 'o3': '4',
+ 'pm25': '53',
+ 'pm10': '73',
+ 'temperature': '7',
+ 'humidity': '71',
+ 'pressure': '992',
+ 'noise_dba': '43'
+ }
+}
+
Returns:
+Type | +Description | +
---|---|
+ Overall
+ |
+
+
+
+ the overall data for the city + |
+
pulseeco/api/pulse_eco_api.py
sensor(sensor_id)
+
+Get a sensor by it's ID
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sensor_id |
+
+ str
+ |
+
+
+
+ the unique ID of the sensor + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ Sensor
+ |
+
+
+
+ a sensor + |
+
sensors()
+
+Get all sensors for a city.
+ + + +Returns:
+Type | +Description | +
---|---|
+ list[Sensor]
+ |
+
+
+
+ a list of sensors + |
+
PulseEcoClient
+
+
+High level pulse.eco client.
+ +pulseeco/client.py
18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 |
|
__init__(city_name, auth=None, base_url=PULSE_ECO_BASE_URL_FORMAT, session=None, pulse_eco_api=None)
+
+Initialize the pulse.eco client.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
city_name |
+
+ str
+ |
+
+
+
+ the city name + |
+ + required + | +
auth |
+
+ tuple[str, str] | None
+ |
+
+
+
+ a tuple of (email, password), defaults to None + |
+
+ None
+ |
+
base_url |
+
+ str
+ |
+
+
+
+ the base URL of the API, defaults to 'https://{city_name}.pulse.eco/rest/{end_point}' + |
+
+ PULSE_ECO_BASE_URL_FORMAT
+ |
+
session |
+
+ Session | None
+ |
+
+
+
+ a requests session use this to customize the session and add retries, defaults to None, + |
+
+ None
+ |
+
pulse_eco_api |
+
+ PulseEcoAPIBase | None
+ |
+
+
+
+ a pulse.eco API wrapper, defaults to None, if set, the other parameters are ignored + |
+
+ None
+ |
+
pulseeco/client.py
avg_data(period, from_, to, type, sensor_id=None)
+
+Get average data for a city.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
period |
+
+ AveragePeriod
+ |
+
+
+
+ the period of the average data + |
+ + required + | +
from_ |
+
+ str | datetime
+ |
+
+
+
+ the start datetime of the data as a datetime object or an isoformat string + |
+ + required + | +
to |
+
+ str | datetime
+ |
+
+
+
+ the end datetime of the data as a datetime object or an isoformat string + |
+ + required + | +
type |
+
+ DataValueType
+ |
+
+
+
+ the data value type + |
+ + required + | +
sensor_id |
+
+ str | None
+ |
+
+
+
+ the unique ID of the sensor, defaults to None + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ list[DataValue]
+ |
+
+
+
+ a list of average data values + |
+
pulseeco/client.py
current()
+
+Get the last received valid data for each sensor in a city.
+Will not return sensor data older than 2 hours.
+ + + +Returns:
+Type | +Description | +
---|---|
+ list[DataValue]
+ |
+
+
+
+ a list of current data values + |
+
pulseeco/client.py
data24h()
+
+Get 24h data for a city.
+The data values are sorted ascending by their timestamp.
+ + + +Returns:
+Type | +Description | +
---|---|
+ list[DataValue]
+ |
+
+
+
+ a list of data values for the past 24 hours + |
+
pulseeco/client.py
data_raw(from_, to, type=None, sensor_id=None)
+
+Get raw data for a city.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
from_ |
+
+ str | datetime
+ |
+
+
+
+ the start datetime of the data as a datetime object or an isoformat string + |
+ + required + | +
to |
+
+ str | datetime
+ |
+
+
+
+ the end datetime of the data as a datetime object or an isoformat string + |
+ + required + | +
type |
+
+ DataValueType | None
+ |
+
+
+
+ the data value type, defaults to None + |
+
+ None
+ |
+
sensor_id |
+
+ str | None
+ |
+
+
+
+ the unique ID of the sensor, defaults to None + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ list[DataValue]
+ |
+
+
+
+ a list of data values + |
+
pulseeco/client.py
overall()
+
+Get the current average data for all sensors per value for a city.
+ + + +Returns:
+Type | +Description | +
---|---|
+ Overall
+ |
+
+
+
+ the overall data for the city + |
+
sensor(sensor_id)
+
+Get a sensor by it's ID.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sensor_id |
+
+ str
+ |
+
+
+
+ the unique ID of the sensor + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ Sensor
+ |
+
+
+
+ a sensor + |
+
sensors()
+
+Get all sensors for a city.
+ + + +Returns:
+Type | +Description | +
---|---|
+ list[Sensor]
+ |
+
+
+
+ a list of sensors + |
+
Environment variable: PULSE_ECO_BASE_URL_FORMAT
The default base URL format is https://{city_name}.pulse.eco/rest/{end_point}
.
Authentication is not required for fetching data. But if provided, it has to be valid for the city.
+Credentials can also be provided as environment variables. To provide credentials for a city, use the following format:
+ +Example environmtent variables in priority order:
+PULSE_ECO_SKOPJE_USERNAME
+PULSE_ECO_SKOPJE_PASSWORD
+
+PULSE_ECO_skopje_USERNAME
+PULSE_ECO_skopje_PASSWORD
+
+PULSE_ECO_USERNAME
+PULSE_ECO_PASSWORD
+
Only use the generic PULSE_ECO_USERNAME
and PULSE_ECO_PASSWORD
environment variables
+if your application requests data from a single city.
Authentication is not required for fetching data. But if provided, it has to be valid. Authentication is per city.
+from pulseeco import PulseEcoClient
+
+pulse_eco = PulseEcoClient(city_name="skopje", auth=("user", "pass"))
+
>>> pulse_eco.sensors()
+[
+ Sensor(
+ sensor_id='sensor_dev_60237_141',
+ position='42.03900255426,21.40771061182',
+ comments='Imported Sensor.community #60237',
+ type='20004',
+ description='Sensor.community 60237',
+ status='NOT_CLAIMED'
+ ),
+ Sensor(
+ sensor_id='sensor_dev_10699_244',
+ position='41.986,21.452',
+ comments='Imported Sensor.community #10699',
+ type='20004',
+ description='Sensor.community 10699',
+ status='NOT_CLAIMED_UNCONFIRMED'
+ ),
+ Sensor(
+ sensor_id='66710fdc-cdfc-4bbe-93a8-7e796fb8a88d',
+ position='41.995238146587674,21.402708292007443',
+ comments='V1 WiFi sensor in Kozle',
+ type='1',
+ description='Kozle',
+ status='ACTIVE'
+ ),
+ ...
+]
+
>>> pulse_eco.sensor(sensor_id="1000")
+Sensor(
+ sensor_id='1000',
+ position='41.99249998,21.4236110',
+ comments='MOEPP sensor at Centar',
+ type='0',
+ description='MOEPP Centar',
+ status='ACTIVE'
+)
+
from_
and to
can be either datetime.datetime
objects or str
in ISO 8601 format.
>>> import datetime
+>>> from pulseeco import DataValueType
+>>> pulse_eco.data_raw(
+... from_=datetime.datetime(year=2017, month=3, day=15, hour=2),
+... to=datetime.datetime(year=2017, month=4, day=19, hour=12),
+... type=DataValueType.PM10,
+... sensor_id="1001",
+... )
+[
+ DataValue(sensor_id='1001', stamp=datetime.datetime(2017, 3, 15, 3, 0, 8, tzinfo=TzInfo(+01:00)), type='pm10', position='41.9783,21.47', value=28, year=None),
+ DataValue(sensor_id='1001', stamp=datetime.datetime(2017, 3, 15, 4, 0, 8, tzinfo=TzInfo(+01:00)), type='pm10', position='41.9783,21.47', value=55, year=None),
+ ...
+ DataValue(sensor_id='1001', stamp=datetime.datetime(2017, 4, 19, 12, 0, 9, tzinfo=TzInfo(+02:00)), type='pm10', position='41.9783,21.47', value=6, year=None),
+ DataValue(sensor_id='1001', stamp=datetime.datetime(2017, 4, 19, 13, 0, 9, tzinfo=TzInfo(+02:00)), type='pm10', position='41.9783,21.47', value=31, year=None)
+]
+
sensor_id "-1"
is a magic value that gives average values for the whole city.
>>> import datetime
+>>> from pulseeco import AveragePeriod, DataValueType
+>>> pulse_eco.avg_data(
+... period=AveragePeriod.MONTH,
+... from_=datetime.datetime(year=2019, month=3, day=1, hour=12),
+... to=datetime.datetime(year=2020, month=5, day=1, hour=12),
+... type=DataValueType.PM10,
+... sensor_id="-1",
+... )
+[
+ DataValue(sensor_id='-1', stamp=datetime.datetime(2019, 3, 1, 13, 0, tzinfo=TzInfo(+01:00)), type='pm10', position='', value=29, year=None),
+ DataValue(sensor_id='-1', stamp=datetime.datetime(2019, 4, 1, 14, 0, tzinfo=TzInfo(+02:00)), type='pm10', position='', value=19, year=None),
+ ...
+ DataValue(sensor_id='-1', stamp=datetime.datetime(2020, 4, 1, 14, 0, tzinfo=TzInfo(+02:00)), type='pm10', position='', value=17, year=None),
+ DataValue(sensor_id='-1', stamp=datetime.datetime(2020, 5, 1, 14, 0, tzinfo=TzInfo(+02:00)), type='pm10', position='', value=12, year=None)
+]
+
Get the last received valid data for each sensor in a city.
+ +Get the current average data for all sensors per value for a city.
+ + + + + + + +pulse.eco client for Python.
+pulse-eco is avialiable on PyPI:
+ +Requires Python version 3.8+.
+Official pulse.eco REST API documentation can be found on pulse.eco/restapi.
+API Reference and User Guide for this package is available on GitHub Pages.
+The pulse.eco API limits the maximum time span of data you can get from one request.
+For /dataRaw
it is one week, while for /avgData
it is one year.
If the time range is larger than the maximum, the pulse.eco client creates multiple requests to the API and then joins the data together. Be aware of this.
+https://hatch.pypa.io/latest/install/
+Activate a Python 3.8 environment and run:
+ +Set auth credentials in .env
file:
This command must pass without errors before committing:
+ +To preview the docs locally, run:
+ + + + + + + +pulse.eco client for Python.
"},{"location":"#installation","title":"Installation","text":"pulse-eco is avialiable on PyPI:
python -m pip install pulse-eco\n
Requires Python version 3.8+.
"},{"location":"#documentation","title":"Documentation","text":"Official pulse.eco REST API documentation can be found on pulse.eco/restapi.
API Reference and User Guide for this package is available on GitHub Pages.
"},{"location":"#requesting-data-with-a-larger-time-range","title":"Requesting data with a larger time range","text":"The pulse.eco API limits the maximum time span of data you can get from one request. For /dataRaw
it is one week, while for /avgData
it is one year.
If the time range is larger than the maximum, the pulse.eco client creates multiple requests to the API and then joins the data together. Be aware of this.
"},{"location":"#development","title":"Development","text":""},{"location":"#install-hatch","title":"Install Hatch","text":"https://hatch.pypa.io/latest/install/
"},{"location":"#create-dev-environment","title":"Create dev environment","text":"Activate a Python 3.8 environment and run:
hatch env create dev\n
"},{"location":"#install-pre-commit-hooks","title":"Install pre-commit hooks","text":"hatch run dev:setup\n
"},{"location":"#create-env-file","title":"Create .env file","text":"Set auth credentials in .env
file:
cp .env.example .env\n
"},{"location":"#before-committing","title":"Before committing","text":"This command must pass without errors before committing:
hatch run dev:check\n
"},{"location":"#docs","title":"Docs","text":"To preview the docs locally, run:
hatch run dev:docs-serve\n
"},{"location":"PulseEcoAPI/","title":"PulseEcoAPI","text":""},{"location":"PulseEcoAPI/#pulseeco.api.PulseEcoAPI","title":"PulseEcoAPI
","text":" Bases: PulseEcoAPIBase
Low level unsafe pulse.eco API wrapper.
Source code inpulseeco/api/pulse_eco_api.py
class PulseEcoAPI(PulseEcoAPIBase):\n\"\"\"Low level unsafe pulse.eco API wrapper.\"\"\"\ndef __init__(\nself,\ncity_name: str,\nauth: tuple[str, str] | None = None,\nbase_url: str = PULSE_ECO_BASE_URL_FORMAT,\nsession: requests.Session | None = None,\n) -> None:\n\"\"\"Initialize the pulse.eco API wrapper.\n :param city_name: the city name\n :param auth: a tuple of (email, password), defaults to None\n :param base_url: the base URL of the API, defaults to\n 'https://{city_name}.pulse.eco/rest/{end_point}'\n :param session: a requests session\n , use this to customize the session and add retries, defaults to None\n \"\"\"\nself.city_name = city_name\nif base_url is not None and PULSE_ECO_BASE_URL_FORMAT_ENV_KEY in os.environ:\nbase_url = os.environ[PULSE_ECO_BASE_URL_FORMAT_ENV_KEY]\nif session is not None:\nself._session = session\nelse:\nself._session = requests.Session()\nif auth is None:\nauth = get_auth_from_env(city_name=city_name)\nif auth is not None:\nself._session.auth = auth\nself._base_url = base_url\ndef _base_request(\nself, end_point: str, params: dict[str, Any] | None = None\n) -> Any: # noqa: ANN401\n\"\"\"Make a request to the PulseEco API.\n :param end_point: an end point of the API\n :param params: get parameters, defaults to None\n :return: the response json\n \"\"\"\nif params is None:\nparams = {}\nurl = self._base_url.format(city_name=self.city_name, end_point=end_point)\nresponse = self._session.get(url, params=params)\nresponse.raise_for_status()\nreturn response.json()\ndef sensors(self) -> list[Sensor]:\n\"\"\"Get all sensors for a city.\n :return: a list of sensors\n \"\"\"\nreturn cast(\"list[Sensor]\", self._base_request(\"sensor\"))\ndef sensor(self, sensor_id: str) -> Sensor:\n\"\"\"Get a sensor by it's ID\n :param sensor_id: the unique ID of the sensor\n :return: a sensor\n \"\"\"\nreturn cast(Sensor, self._base_request(f\"sensor/{sensor_id}\"))\ndef data_raw(\nself,\nfrom_: str | datetime.datetime,\nto: str | datetime.datetime,\ntype: str | None = None,\nsensor_id: str | None = None,\n) -> list[DataValueRaw]:\n\"\"\"Get raw data for a city.\n :param from_: the start datetime of the data\n as a datetime object or an isoformat string\n :param to: the end datetime of the data\n as a datetime object or an isoformat string\n :param type: the data value type, defaults to None\n :param sensor_id: the unique ID of the sensor, defaults to None\n :return: a list of data values\n \"\"\"\nif sensor_id is None and type is None:\nwarnings.warn(\n\"Warning! If you encounter an error, \"\n\"you should probably specify either sensor_id or type.\",\nstacklevel=2,\n)\ndata: list[DataValueRaw] = []\ndatetime_spans = split_datetime_span(from_, to, DATA_RAW_MAX_SPAN)\nfor from_temp, to_temp in datetime_spans:\nparams = {\n\"sensorId\": sensor_id,\n\"type\": type,\n\"from\": convert_datetime_to_str(from_temp),\n\"to\": convert_datetime_to_str(to_temp),\n}\nparams = {k: v for k, v in params.items() if v is not None}\ndata_value = cast(\n\"list[DataValueRaw]\",\nself._base_request(\"dataRaw\", params=params),\n)\ndata += data_value\nreturn data\ndef avg_data(\nself,\nperiod: str,\nfrom_: str | datetime.datetime,\nto: str | datetime.datetime,\ntype: str,\nsensor_id: str | None = None,\n) -> list[DataValueAvg]:\n\"\"\"Get average data for a city.\n :param period: the period of the average data (day, week, month)\n :param from_: the start datetime of the data\n as a datetime object or an isoformat string\n :param to: the end datetime of the data\n as a datetime object or an isoformat string\n :param type: the data value type\n :param sensor_id: the unique ID of the sensor, defaults to None\n :return: a list of average data values\n \"\"\"\nif period not in {\"day\", \"week\", \"month\"}:\nwarnings.warn(\n\"Warning! Invalid value for period. \"\n\"Should be one of: day, week, month\",\nstacklevel=2,\n)\ndata: list[DataValueAvg] = []\ndatetime_spans = split_datetime_span(from_, to, AVG_DATA_MAX_SPAN)\nfor from_temp, to_temp in datetime_spans:\nparams = {\n\"sensorId\": sensor_id,\n\"type\": type,\n\"from\": convert_datetime_to_str(from_temp),\n\"to\": convert_datetime_to_str(to_temp),\n}\nparams = {k: v for k, v in params.items() if v is not None}\ndata_value = cast(\n\"list[DataValueAvg]\",\nself._base_request(f\"avgData/{period}\", params=params),\n)\ndata += data_value\nreturn data\ndef data24h(self) -> list[DataValueRaw]:\n\"\"\"Get 24h data for a city.\n The data values are sorted ascending by their timestamp.\n :return: a list of data values for the past 24 hours\n \"\"\"\nreturn cast(\"list[DataValueRaw]\", self._base_request(\"data24h\"))\ndef current(self) -> list[DataValueRaw]:\n\"\"\"Get the last received valid data for each sensor in a city\n Will not return sensor data older than 2 hours.\n :return: a list of current data values\n \"\"\"\nreturn cast(\"list[DataValueRaw]\", self._base_request(\"current\"))\ndef overall(\nself,\n) -> Overall:\n\"\"\"Get the current average data for all sensors per value for a city.\n ## Example:\n ```python\n {\n 'cityName': 'skopje',\n 'values': {\n 'no2': '22',\n 'o3': '4',\n 'pm25': '53',\n 'pm10': '73',\n 'temperature': '7',\n 'humidity': '71',\n 'pressure': '992',\n 'noise_dba': '43'\n }\n }\n ```\n :return: the overall data for the city\n \"\"\"\nreturn cast(Overall, self._base_request(\"overall\"))\n
"},{"location":"PulseEcoAPI/#pulseeco.api.PulseEcoAPI.__init__","title":"__init__(city_name, auth=None, base_url=PULSE_ECO_BASE_URL_FORMAT, session=None)
","text":"Initialize the pulse.eco API wrapper.
Parameters:
Name Type Description Defaultcity_name
str
the city name
requiredauth
tuple[str, str] | None
a tuple of (email, password), defaults to None
None
base_url
str
the base URL of the API, defaults to 'https://{city_name}.pulse.eco/rest/{end_point}'
PULSE_ECO_BASE_URL_FORMAT
session
Session | None
a requests session , use this to customize the session and add retries, defaults to None
None
Source code in pulseeco/api/pulse_eco_api.py
def __init__(\nself,\ncity_name: str,\nauth: tuple[str, str] | None = None,\nbase_url: str = PULSE_ECO_BASE_URL_FORMAT,\nsession: requests.Session | None = None,\n) -> None:\n\"\"\"Initialize the pulse.eco API wrapper.\n :param city_name: the city name\n :param auth: a tuple of (email, password), defaults to None\n :param base_url: the base URL of the API, defaults to\n 'https://{city_name}.pulse.eco/rest/{end_point}'\n :param session: a requests session\n , use this to customize the session and add retries, defaults to None\n \"\"\"\nself.city_name = city_name\nif base_url is not None and PULSE_ECO_BASE_URL_FORMAT_ENV_KEY in os.environ:\nbase_url = os.environ[PULSE_ECO_BASE_URL_FORMAT_ENV_KEY]\nif session is not None:\nself._session = session\nelse:\nself._session = requests.Session()\nif auth is None:\nauth = get_auth_from_env(city_name=city_name)\nif auth is not None:\nself._session.auth = auth\nself._base_url = base_url\n
"},{"location":"PulseEcoAPI/#pulseeco.api.PulseEcoAPI.avg_data","title":"avg_data(period, from_, to, type, sensor_id=None)
","text":"Get average data for a city.
Parameters:
Name Type Description Defaultperiod
str
the period of the average data (day, week, month)
requiredfrom_
str | datetime
the start datetime of the data as a datetime object or an isoformat string
requiredto
str | datetime
the end datetime of the data as a datetime object or an isoformat string
requiredtype
str
the data value type
requiredsensor_id
str | None
the unique ID of the sensor, defaults to None
None
Returns:
Type Descriptionlist[DataValueAvg]
a list of average data values
Source code inpulseeco/api/pulse_eco_api.py
def avg_data(\nself,\nperiod: str,\nfrom_: str | datetime.datetime,\nto: str | datetime.datetime,\ntype: str,\nsensor_id: str | None = None,\n) -> list[DataValueAvg]:\n\"\"\"Get average data for a city.\n :param period: the period of the average data (day, week, month)\n :param from_: the start datetime of the data\n as a datetime object or an isoformat string\n :param to: the end datetime of the data\n as a datetime object or an isoformat string\n :param type: the data value type\n :param sensor_id: the unique ID of the sensor, defaults to None\n :return: a list of average data values\n \"\"\"\nif period not in {\"day\", \"week\", \"month\"}:\nwarnings.warn(\n\"Warning! Invalid value for period. \"\n\"Should be one of: day, week, month\",\nstacklevel=2,\n)\ndata: list[DataValueAvg] = []\ndatetime_spans = split_datetime_span(from_, to, AVG_DATA_MAX_SPAN)\nfor from_temp, to_temp in datetime_spans:\nparams = {\n\"sensorId\": sensor_id,\n\"type\": type,\n\"from\": convert_datetime_to_str(from_temp),\n\"to\": convert_datetime_to_str(to_temp),\n}\nparams = {k: v for k, v in params.items() if v is not None}\ndata_value = cast(\n\"list[DataValueAvg]\",\nself._base_request(f\"avgData/{period}\", params=params),\n)\ndata += data_value\nreturn data\n
"},{"location":"PulseEcoAPI/#pulseeco.api.PulseEcoAPI.current","title":"current()
","text":"Get the last received valid data for each sensor in a city
Will not return sensor data older than 2 hours.
Returns:
Type Descriptionlist[DataValueRaw]
a list of current data values
Source code inpulseeco/api/pulse_eco_api.py
def current(self) -> list[DataValueRaw]:\n\"\"\"Get the last received valid data for each sensor in a city\n Will not return sensor data older than 2 hours.\n :return: a list of current data values\n \"\"\"\nreturn cast(\"list[DataValueRaw]\", self._base_request(\"current\"))\n
"},{"location":"PulseEcoAPI/#pulseeco.api.PulseEcoAPI.data24h","title":"data24h()
","text":"Get 24h data for a city.
The data values are sorted ascending by their timestamp.
Returns:
Type Descriptionlist[DataValueRaw]
a list of data values for the past 24 hours
Source code inpulseeco/api/pulse_eco_api.py
def data24h(self) -> list[DataValueRaw]:\n\"\"\"Get 24h data for a city.\n The data values are sorted ascending by their timestamp.\n :return: a list of data values for the past 24 hours\n \"\"\"\nreturn cast(\"list[DataValueRaw]\", self._base_request(\"data24h\"))\n
"},{"location":"PulseEcoAPI/#pulseeco.api.PulseEcoAPI.data_raw","title":"data_raw(from_, to, type=None, sensor_id=None)
","text":"Get raw data for a city.
Parameters:
Name Type Description Defaultfrom_
str | datetime
the start datetime of the data as a datetime object or an isoformat string
requiredto
str | datetime
the end datetime of the data as a datetime object or an isoformat string
requiredtype
str | None
the data value type, defaults to None
None
sensor_id
str | None
the unique ID of the sensor, defaults to None
None
Returns:
Type Descriptionlist[DataValueRaw]
a list of data values
Source code inpulseeco/api/pulse_eco_api.py
def data_raw(\nself,\nfrom_: str | datetime.datetime,\nto: str | datetime.datetime,\ntype: str | None = None,\nsensor_id: str | None = None,\n) -> list[DataValueRaw]:\n\"\"\"Get raw data for a city.\n :param from_: the start datetime of the data\n as a datetime object or an isoformat string\n :param to: the end datetime of the data\n as a datetime object or an isoformat string\n :param type: the data value type, defaults to None\n :param sensor_id: the unique ID of the sensor, defaults to None\n :return: a list of data values\n \"\"\"\nif sensor_id is None and type is None:\nwarnings.warn(\n\"Warning! If you encounter an error, \"\n\"you should probably specify either sensor_id or type.\",\nstacklevel=2,\n)\ndata: list[DataValueRaw] = []\ndatetime_spans = split_datetime_span(from_, to, DATA_RAW_MAX_SPAN)\nfor from_temp, to_temp in datetime_spans:\nparams = {\n\"sensorId\": sensor_id,\n\"type\": type,\n\"from\": convert_datetime_to_str(from_temp),\n\"to\": convert_datetime_to_str(to_temp),\n}\nparams = {k: v for k, v in params.items() if v is not None}\ndata_value = cast(\n\"list[DataValueRaw]\",\nself._base_request(\"dataRaw\", params=params),\n)\ndata += data_value\nreturn data\n
"},{"location":"PulseEcoAPI/#pulseeco.api.PulseEcoAPI.overall","title":"overall()
","text":"Get the current average data for all sensors per value for a city.
"},{"location":"PulseEcoAPI/#pulseeco.api.PulseEcoAPI.overall--example","title":"Example:","text":"{\n'cityName': 'skopje',\n'values': {\n'no2': '22',\n'o3': '4',\n'pm25': '53',\n'pm10': '73',\n'temperature': '7',\n'humidity': '71',\n'pressure': '992',\n'noise_dba': '43'\n}\n}\n
Returns:
Type DescriptionOverall
the overall data for the city
Source code inpulseeco/api/pulse_eco_api.py
def overall(\nself,\n) -> Overall:\n\"\"\"Get the current average data for all sensors per value for a city.\n ## Example:\n ```python\n {\n 'cityName': 'skopje',\n 'values': {\n 'no2': '22',\n 'o3': '4',\n 'pm25': '53',\n 'pm10': '73',\n 'temperature': '7',\n 'humidity': '71',\n 'pressure': '992',\n 'noise_dba': '43'\n }\n }\n ```\n :return: the overall data for the city\n \"\"\"\nreturn cast(Overall, self._base_request(\"overall\"))\n
"},{"location":"PulseEcoAPI/#pulseeco.api.PulseEcoAPI.sensor","title":"sensor(sensor_id)
","text":"Get a sensor by it's ID
Parameters:
Name Type Description Defaultsensor_id
str
the unique ID of the sensor
requiredReturns:
Type DescriptionSensor
a sensor
Source code inpulseeco/api/pulse_eco_api.py
def sensor(self, sensor_id: str) -> Sensor:\n\"\"\"Get a sensor by it's ID\n :param sensor_id: the unique ID of the sensor\n :return: a sensor\n \"\"\"\nreturn cast(Sensor, self._base_request(f\"sensor/{sensor_id}\"))\n
"},{"location":"PulseEcoAPI/#pulseeco.api.PulseEcoAPI.sensors","title":"sensors()
","text":"Get all sensors for a city.
Returns:
Type Descriptionlist[Sensor]
a list of sensors
Source code inpulseeco/api/pulse_eco_api.py
def sensors(self) -> list[Sensor]:\n\"\"\"Get all sensors for a city.\n :return: a list of sensors\n \"\"\"\nreturn cast(\"list[Sensor]\", self._base_request(\"sensor\"))\n
"},{"location":"PulseEcoClient/","title":"PulseEcoClient","text":""},{"location":"PulseEcoClient/#pulseeco.client.PulseEcoClient","title":"PulseEcoClient
","text":"High level pulse.eco client.
Source code inpulseeco/client.py
class PulseEcoClient:\n\"\"\"High level pulse.eco client.\"\"\"\ndef __init__(\nself,\ncity_name: str,\nauth: tuple[str, str] | None = None,\nbase_url: str = PULSE_ECO_BASE_URL_FORMAT,\nsession: requests.Session | None = None,\npulse_eco_api: PulseEcoAPIBase | None = None,\n) -> None:\n\"\"\"Initialize the pulse.eco client.\n :param city_name: the city name\n :param auth: a tuple of (email, password), defaults to None\n :param base_url: the base URL of the API, defaults to\n 'https://{city_name}.pulse.eco/rest/{end_point}'\n :param session: a requests session\n use this to customize the session and add retries, defaults to None,\n :param pulse_eco_api: a pulse.eco API wrapper, defaults to None,\n if set, the other parameters are ignored\n \"\"\"\nself._pulse_eco_api: PulseEcoAPIBase\nif pulse_eco_api is None:\nself._pulse_eco_api = PulseEcoAPI(\ncity_name=city_name, auth=auth, base_url=base_url, session=session\n)\nelse:\nself._pulse_eco_api = pulse_eco_api\ndef sensors(self) -> list[Sensor]:\n\"\"\"Get all sensors for a city.\n :return: a list of sensors\n \"\"\"\nreturn [\nSensor.model_validate(sensor) for sensor in self._pulse_eco_api.sensors()\n]\ndef sensor(self, sensor_id: str) -> Sensor:\n\"\"\"Get a sensor by it's ID.\n :param sensor_id: the unique ID of the sensor\n :return: a sensor\n \"\"\"\nreturn Sensor.model_validate(self._pulse_eco_api.sensor(sensor_id=sensor_id))\ndef data_raw(\nself,\nfrom_: str | datetime.datetime,\nto: str | datetime.datetime,\ntype: DataValueType | None = None,\nsensor_id: str | None = None,\n) -> list[DataValue]:\n\"\"\"Get raw data for a city.\n :param from_: the start datetime of the data\n as a datetime object or an isoformat string\n :param to: the end datetime of the data\n as a datetime object or an isoformat string\n :param type: the data value type, defaults to None\n :param sensor_id: the unique ID of the sensor, defaults to None\n :return: a list of data values\n \"\"\"\nreturn [\nDataValue.model_validate(data_value)\nfor data_value in self._pulse_eco_api.data_raw(\nfrom_=from_,\nto=to,\ntype=type,\nsensor_id=sensor_id,\n)\n]\ndef avg_data(\nself,\nperiod: AveragePeriod,\nfrom_: str | datetime.datetime,\nto: str | datetime.datetime,\ntype: DataValueType,\nsensor_id: str | None = None,\n) -> list[DataValue]:\n\"\"\"Get average data for a city.\n :param period: the period of the average data\n :param from_: the start datetime of the data\n as a datetime object or an isoformat string\n :param to: the end datetime of the data\n as a datetime object or an isoformat string\n :param type: the data value type\n :param sensor_id: the unique ID of the sensor, defaults to None\n :return: a list of average data values\n \"\"\"\nreturn [\nDataValue.model_validate(data_value)\nfor data_value in self._pulse_eco_api.avg_data(\nperiod=period,\nfrom_=from_,\nto=to,\ntype=type,\nsensor_id=sensor_id,\n)\n]\ndef data24h(self) -> list[DataValue]:\n\"\"\"Get 24h data for a city.\n The data values are sorted ascending by their timestamp.\n :return: a list of data values for the past 24 hours\n \"\"\"\nreturn [\nDataValue.model_validate(data_value)\nfor data_value in self._pulse_eco_api.data24h()\n]\ndef current(self) -> list[DataValue]:\n\"\"\"Get the last received valid data for each sensor in a city.\n Will not return sensor data older than 2 hours.\n :return: a list of current data values\n \"\"\"\nreturn [\nDataValue.model_validate(data_value)\nfor data_value in self._pulse_eco_api.current()\n]\ndef overall(self) -> Overall:\n\"\"\"Get the current average data for all sensors per value for a city.\n :return: the overall data for the city\n \"\"\"\nreturn Overall.model_validate(self._pulse_eco_api.overall())\n
"},{"location":"PulseEcoClient/#pulseeco.client.PulseEcoClient.__init__","title":"__init__(city_name, auth=None, base_url=PULSE_ECO_BASE_URL_FORMAT, session=None, pulse_eco_api=None)
","text":"Initialize the pulse.eco client.
Parameters:
Name Type Description Defaultcity_name
str
the city name
requiredauth
tuple[str, str] | None
a tuple of (email, password), defaults to None
None
base_url
str
the base URL of the API, defaults to 'https://{city_name}.pulse.eco/rest/{end_point}'
PULSE_ECO_BASE_URL_FORMAT
session
Session | None
a requests session use this to customize the session and add retries, defaults to None,
None
pulse_eco_api
PulseEcoAPIBase | None
a pulse.eco API wrapper, defaults to None, if set, the other parameters are ignored
None
Source code in pulseeco/client.py
def __init__(\nself,\ncity_name: str,\nauth: tuple[str, str] | None = None,\nbase_url: str = PULSE_ECO_BASE_URL_FORMAT,\nsession: requests.Session | None = None,\npulse_eco_api: PulseEcoAPIBase | None = None,\n) -> None:\n\"\"\"Initialize the pulse.eco client.\n :param city_name: the city name\n :param auth: a tuple of (email, password), defaults to None\n :param base_url: the base URL of the API, defaults to\n 'https://{city_name}.pulse.eco/rest/{end_point}'\n :param session: a requests session\n use this to customize the session and add retries, defaults to None,\n :param pulse_eco_api: a pulse.eco API wrapper, defaults to None,\n if set, the other parameters are ignored\n \"\"\"\nself._pulse_eco_api: PulseEcoAPIBase\nif pulse_eco_api is None:\nself._pulse_eco_api = PulseEcoAPI(\ncity_name=city_name, auth=auth, base_url=base_url, session=session\n)\nelse:\nself._pulse_eco_api = pulse_eco_api\n
"},{"location":"PulseEcoClient/#pulseeco.client.PulseEcoClient.avg_data","title":"avg_data(period, from_, to, type, sensor_id=None)
","text":"Get average data for a city.
Parameters:
Name Type Description Defaultperiod
AveragePeriod
the period of the average data
requiredfrom_
str | datetime
the start datetime of the data as a datetime object or an isoformat string
requiredto
str | datetime
the end datetime of the data as a datetime object or an isoformat string
requiredtype
DataValueType
the data value type
requiredsensor_id
str | None
the unique ID of the sensor, defaults to None
None
Returns:
Type Descriptionlist[DataValue]
a list of average data values
Source code inpulseeco/client.py
def avg_data(\nself,\nperiod: AveragePeriod,\nfrom_: str | datetime.datetime,\nto: str | datetime.datetime,\ntype: DataValueType,\nsensor_id: str | None = None,\n) -> list[DataValue]:\n\"\"\"Get average data for a city.\n :param period: the period of the average data\n :param from_: the start datetime of the data\n as a datetime object or an isoformat string\n :param to: the end datetime of the data\n as a datetime object or an isoformat string\n :param type: the data value type\n :param sensor_id: the unique ID of the sensor, defaults to None\n :return: a list of average data values\n \"\"\"\nreturn [\nDataValue.model_validate(data_value)\nfor data_value in self._pulse_eco_api.avg_data(\nperiod=period,\nfrom_=from_,\nto=to,\ntype=type,\nsensor_id=sensor_id,\n)\n]\n
"},{"location":"PulseEcoClient/#pulseeco.client.PulseEcoClient.current","title":"current()
","text":"Get the last received valid data for each sensor in a city.
Will not return sensor data older than 2 hours.
Returns:
Type Descriptionlist[DataValue]
a list of current data values
Source code inpulseeco/client.py
def current(self) -> list[DataValue]:\n\"\"\"Get the last received valid data for each sensor in a city.\n Will not return sensor data older than 2 hours.\n :return: a list of current data values\n \"\"\"\nreturn [\nDataValue.model_validate(data_value)\nfor data_value in self._pulse_eco_api.current()\n]\n
"},{"location":"PulseEcoClient/#pulseeco.client.PulseEcoClient.data24h","title":"data24h()
","text":"Get 24h data for a city.
The data values are sorted ascending by their timestamp.
Returns:
Type Descriptionlist[DataValue]
a list of data values for the past 24 hours
Source code inpulseeco/client.py
def data24h(self) -> list[DataValue]:\n\"\"\"Get 24h data for a city.\n The data values are sorted ascending by their timestamp.\n :return: a list of data values for the past 24 hours\n \"\"\"\nreturn [\nDataValue.model_validate(data_value)\nfor data_value in self._pulse_eco_api.data24h()\n]\n
"},{"location":"PulseEcoClient/#pulseeco.client.PulseEcoClient.data_raw","title":"data_raw(from_, to, type=None, sensor_id=None)
","text":"Get raw data for a city.
Parameters:
Name Type Description Defaultfrom_
str | datetime
the start datetime of the data as a datetime object or an isoformat string
requiredto
str | datetime
the end datetime of the data as a datetime object or an isoformat string
requiredtype
DataValueType | None
the data value type, defaults to None
None
sensor_id
str | None
the unique ID of the sensor, defaults to None
None
Returns:
Type Descriptionlist[DataValue]
a list of data values
Source code inpulseeco/client.py
def data_raw(\nself,\nfrom_: str | datetime.datetime,\nto: str | datetime.datetime,\ntype: DataValueType | None = None,\nsensor_id: str | None = None,\n) -> list[DataValue]:\n\"\"\"Get raw data for a city.\n :param from_: the start datetime of the data\n as a datetime object or an isoformat string\n :param to: the end datetime of the data\n as a datetime object or an isoformat string\n :param type: the data value type, defaults to None\n :param sensor_id: the unique ID of the sensor, defaults to None\n :return: a list of data values\n \"\"\"\nreturn [\nDataValue.model_validate(data_value)\nfor data_value in self._pulse_eco_api.data_raw(\nfrom_=from_,\nto=to,\ntype=type,\nsensor_id=sensor_id,\n)\n]\n
"},{"location":"PulseEcoClient/#pulseeco.client.PulseEcoClient.overall","title":"overall()
","text":"Get the current average data for all sensors per value for a city.
Returns:
Type DescriptionOverall
the overall data for the city
Source code inpulseeco/client.py
def overall(self) -> Overall:\n\"\"\"Get the current average data for all sensors per value for a city.\n :return: the overall data for the city\n \"\"\"\nreturn Overall.model_validate(self._pulse_eco_api.overall())\n
"},{"location":"PulseEcoClient/#pulseeco.client.PulseEcoClient.sensor","title":"sensor(sensor_id)
","text":"Get a sensor by it's ID.
Parameters:
Name Type Description Defaultsensor_id
str
the unique ID of the sensor
requiredReturns:
Type DescriptionSensor
a sensor
Source code inpulseeco/client.py
def sensor(self, sensor_id: str) -> Sensor:\n\"\"\"Get a sensor by it's ID.\n :param sensor_id: the unique ID of the sensor\n :return: a sensor\n \"\"\"\nreturn Sensor.model_validate(self._pulse_eco_api.sensor(sensor_id=sensor_id))\n
"},{"location":"PulseEcoClient/#pulseeco.client.PulseEcoClient.sensors","title":"sensors()
","text":"Get all sensors for a city.
Returns:
Type Descriptionlist[Sensor]
a list of sensors
Source code inpulseeco/client.py
def sensors(self) -> list[Sensor]:\n\"\"\"Get all sensors for a city.\n :return: a list of sensors\n \"\"\"\nreturn [\nSensor.model_validate(sensor) for sensor in self._pulse_eco_api.sensors()\n]\n
"},{"location":"environment-variables/","title":"Environment variables","text":""},{"location":"environment-variables/#base-url-format","title":"Base URL format","text":"Environment variable: PULSE_ECO_BASE_URL_FORMAT
The default base URL format is https://{city_name}.pulse.eco/rest/{end_point}
.
Authentication is not required for fetching data. But if provided, it has to be valid for the city.
Credentials can also be provided as environment variables. To provide credentials for a city, use the following format:
PULSE_ECO_{city_name}_USERNAME\nPULSE_ECO_{city_name}_PASSWORD\n
Example environmtent variables in priority order:
PULSE_ECO_SKOPJE_USERNAME\nPULSE_ECO_SKOPJE_PASSWORD\n\nPULSE_ECO_skopje_USERNAME\nPULSE_ECO_skopje_PASSWORD\n\nPULSE_ECO_USERNAME\nPULSE_ECO_PASSWORD\n
Only use the generic PULSE_ECO_USERNAME
and PULSE_ECO_PASSWORD
environment variables if your application requests data from a single city.
Authentication is not required for fetching data. But if provided, it has to be valid. Authentication is per city.
from pulseeco import PulseEcoClient\npulse_eco = PulseEcoClient(city_name=\"skopje\", auth=(\"user\", \"pass\"))\n
"},{"location":"example-usage/#get-all-sensors","title":"Get all sensors","text":">>> pulse_eco.sensors()\n[\n Sensor(\n sensor_id='sensor_dev_60237_141',\n position='42.03900255426,21.40771061182',\n comments='Imported Sensor.community #60237',\n type='20004',\n description='Sensor.community 60237',\n status='NOT_CLAIMED'\n ),\n Sensor(\n sensor_id='sensor_dev_10699_244',\n position='41.986,21.452',\n comments='Imported Sensor.community #10699',\n type='20004',\n description='Sensor.community 10699',\n status='NOT_CLAIMED_UNCONFIRMED'\n ),\n Sensor(\n sensor_id='66710fdc-cdfc-4bbe-93a8-7e796fb8a88d',\n position='41.995238146587674,21.402708292007443',\n comments='V1 WiFi sensor in Kozle',\n type='1',\n description='Kozle',\n status='ACTIVE'\n ),\n ...\n]\n
"},{"location":"example-usage/#get-a-sensor-by-id","title":"Get a sensor by id","text":">>> pulse_eco.sensor(sensor_id=\"1000\")\nSensor(\n sensor_id='1000',\n position='41.99249998,21.4236110',\n comments='MOEPP sensor at Centar',\n type='0',\n description='MOEPP Centar',\n status='ACTIVE'\n)\n
"},{"location":"example-usage/#get-raw-data","title":"Get raw data","text":"from_
and to
can be either datetime.datetime
objects or str
in ISO 8601 format.
>>> import datetime\n>>> from pulseeco import DataValueType\n>>> pulse_eco.data_raw(\n... from_=datetime.datetime(year=2017, month=3, day=15, hour=2),\n... to=datetime.datetime(year=2017, month=4, day=19, hour=12),\n... type=DataValueType.PM10,\n... sensor_id=\"1001\",\n... )\n[\n DataValue(sensor_id='1001', stamp=datetime.datetime(2017, 3, 15, 3, 0, 8, tzinfo=TzInfo(+01:00)), type='pm10', position='41.9783,21.47', value=28, year=None),\n DataValue(sensor_id='1001', stamp=datetime.datetime(2017, 3, 15, 4, 0, 8, tzinfo=TzInfo(+01:00)), type='pm10', position='41.9783,21.47', value=55, year=None),\n ...\n DataValue(sensor_id='1001', stamp=datetime.datetime(2017, 4, 19, 12, 0, 9, tzinfo=TzInfo(+02:00)), type='pm10', position='41.9783,21.47', value=6, year=None),\n DataValue(sensor_id='1001', stamp=datetime.datetime(2017, 4, 19, 13, 0, 9, tzinfo=TzInfo(+02:00)), type='pm10', position='41.9783,21.47', value=31, year=None)\n]\n
"},{"location":"example-usage/#get-average-data","title":"Get average data","text":"sensor_id \"-1\"
is a magic value that gives average values for the whole city.
>>> import datetime\n>>> from pulseeco import AveragePeriod, DataValueType\n>>> pulse_eco.avg_data(\n... period=AveragePeriod.MONTH,\n... from_=datetime.datetime(year=2019, month=3, day=1, hour=12),\n... to=datetime.datetime(year=2020, month=5, day=1, hour=12),\n... type=DataValueType.PM10,\n... sensor_id=\"-1\",\n... )\n[\n DataValue(sensor_id='-1', stamp=datetime.datetime(2019, 3, 1, 13, 0, tzinfo=TzInfo(+01:00)), type='pm10', position='', value=29, year=None),\n DataValue(sensor_id='-1', stamp=datetime.datetime(2019, 4, 1, 14, 0, tzinfo=TzInfo(+02:00)), type='pm10', position='', value=19, year=None),\n ...\n DataValue(sensor_id='-1', stamp=datetime.datetime(2020, 4, 1, 14, 0, tzinfo=TzInfo(+02:00)), type='pm10', position='', value=17, year=None),\n DataValue(sensor_id='-1', stamp=datetime.datetime(2020, 5, 1, 14, 0, tzinfo=TzInfo(+02:00)), type='pm10', position='', value=12, year=None)\n]\n
"},{"location":"example-usage/#get-24h-data","title":"Get 24h data","text":">>> pulse_eco.data24h()\n[ ... ]\n
"},{"location":"example-usage/#get-current-data","title":"Get current data","text":"Get the last received valid data for each sensor in a city.
>>> pulse_eco.current()\n[ ... ]\n
"},{"location":"example-usage/#get-overall-data","title":"Get overall data","text":"Get the current average data for all sensors per value for a city.
>>> pulse_eco.overall()\nOverall(\n city_name='skopje',\n values=OverallValues(\n no2=6,\n o3=10,\n so2=None,\n co=None,\n pm25=56,\n pm10=95,\n temperature=6,\n humidity=73,\n pressure=995,\n noise=None,\n noise_dba=42,\n gas_resistance=None\n )\n)\n
"}]}
\ No newline at end of file
diff --git a/sitemap.xml b/sitemap.xml
new file mode 100644
index 0000000..9edd751
--- /dev/null
+++ b/sitemap.xml
@@ -0,0 +1,28 @@
+
+