PulseEcoClient
PulseEcoClient
High level pulse.eco client.
Source code in pulseeco/client/client.py
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 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 |
|
__init__(city_name, auth=None, base_url=PULSE_ECO_BASE_URL_FORMAT, session=None, client=None, async_client=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 |
None
|
deprecated, use client and async_client instead |
None
|
client |
CLIENT | None
|
a sync http client, supported types are: requests.Session, httpx.Client, defaults to None which uses a new requests.Session for each request, use a context managed session for better performance and resource management |
None
|
async_client |
ASYNC_CLIENT | None
|
an async http client, supported types are: aiohttp.ClientSession, httpx.AsyncClient, defaults to None which will use the sync client |
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/client.py
aavg_data(period, from_, to, type, sensor_id=None)
async
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 |
Source code in pulseeco/client/client.py
acurrent()
async
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 |
Source code in pulseeco/client/client.py
adata24h()
async
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 |
Source code in pulseeco/client/client.py
adata_raw(from_, to, type=None, sensor_id=None)
async
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 |
Source code in pulseeco/client/client.py
aoverall()
async
Get the current average data for all sensors per value for a city.
Returns:
Type | Description |
---|---|
Overall
|
the overall data for the city |
asensor(sensor_id)
async
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 |
Source code in pulseeco/client/client.py
asensors()
async
Get all sensors for a city.
Returns:
Type | Description |
---|---|
list[Sensor]
|
a list of sensors |
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 |
Source code in pulseeco/client/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 |
Source code in pulseeco/client/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 |
Source code in pulseeco/client/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 |
Source code in pulseeco/client/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 |