htcollector.Database
Measurement— Represents a measurement of temperature and humidity by a station.</>MeasurementDatabase— Implements a databases containing measurements and station descriptions.</>
htcollector.Database.Measurement(stationid, temperature, humidity)
Represents a measurement of temperature and humidity by a station.
stationid(str) — station identification. Must contain only 1 or more alphnumeric characters or hyphenstemperature(float) — descriptionhumidity(float) — description
ValueError— if the stationid argument contains illegal characters or temperature or humidity arguments are not compatible to floats
htcollector.Database.MeasurementDatabase(database, host, port, user, password)
Implements a databases containing measurements and station descriptions.
The backing database should be a MariaDB database server.
database(str) — name of the databasehost(str) — hostname or ip-address of teh database serverport(str) — port that the database server is listening onuser(str) — username of a user with access privileges to the databasepassword(str) — password of the user
names(stationid,name)(dict) — Insert or replace a name for a stationid, or return a list of all stations._</>retrieveDatetimeBefore(stationid,t)(datetime or None) — Returns the time of the last measurement preceding a given time.</>retrieveLastMeasurement(stationid,_names,_unique_stations)(list) — Return the last measurement data for a station or all stations.</>retrieveMeasurements(stationid,starttime,endtime)(list) — Get measurements inside a given timeframe.</>storeMeasurement(measurement)— Store a measurement into the database.</>
storeMeasurement(measurement)
Store a measurement into the database.
measurement(Measurement) — the measurement
Measurements do not contain timestamps, the are added automatically.
retrieveMeasurements(stationid, starttime, endtime=None)
Get measurements inside a given timeframe.
stationid(str) — stationid or asterisk '*'starttime(datetime) — starttime of measurement period (inclusive)endtime(datetime, optional) — endtime of measurement period (inclusive) or None for now. Defaults to None.
of dict(timestamp:t, stationid:id, temperature:t, humidity:h)
retrieveLastMeasurement(stationid=None, _names=None, _unique_stations=None)
Return the last measurement data for a station or all stations.
stationid(str) — the stationid or an asterisk '*'
a list of dict objects, one for each station
retrieveDatetimeBefore(stationid, t)
Returns the time of the last measurement preceding a given time.
stationid(str) — the station idt(datetime) — the timestamp
the time of the last measurement preceding a given time or None if the isn one
names(stationid, name=None)
Insert or replace a name for a stationid, or return a list of all stations._
stationid(str) — the shellyht station id or an asterisk '*'name(str) — the name to associate with a stationid (ignored if stationid is '*')
a dict(stationid:name)