mosaik-influxdb2
This package contains an adapter to write data from a mosaik simulation into an InfluxDB 2 database.
Installation
This package is on pypi, so you can install it using pip:
pip install mosaik-influxdb2
Usage
To use the simulator, first add it to your sim_config:
sim_config = {
"InfluxWriter": {"python": "mosaik_components.influxdb2.writer:Simulator"},
# ...
}
Next, you need to start the simulator. Here, you have two choices to make:
- The simulator can run both in time-based mode with a fixed step size or in
event-based mode without a step size. You can choose the time-based mode by giving
the parameter
step_sizewhen starting the simulator. If you givestep_size=None(or don’t specify anything), the simulator will use the event-based mode. - You can either supply a start date (as a string parseable by Python’s
datetimemodule) which will be combined with the (mosaik) time and time resolution to calculate each step’s time, or you can supply the time for each step on thelocal_timeattribute (again, as a string). If you give both, the value on thelocal_timeattribute will take precedence.
So one possible invocation would be
influx_sim = world.start("InfluxWriter",
step_size=900,
start_date="2022-01-01 00:00:00Z",
)
to start the simulator in time-based mode with a step size of 900 and times based on the given start date. You can leave off either argument with the effects described above.
Finally, the model needs to be started with your Influx credentials:
influx = influx_sim.Database(
url="http://localhost:8086",
org='.',
bucket='my_bucket',
token='secret_token',
measurement='experiment_0001'
)
We recommend setting a new value for the measurement on each simulation run. (For example, you can use the start time of your simulation or a random UUID.)
Afterwards, you can define world.connect(other_entity, influx, attrs) as you like.
The simulator supports only one instance of the Database model. If you want to connect to several databases, you will need to start several instances of the simulator as well.
Other settings
By default, the adapter will save the simulator ID and entity ID of the producer of each data point in the src_sim and src_entity tags on that data point.
You can change the name of these tags by passing the src_sim_tag and src_entity_tag to the start call.
Setting them to None will disable writing the corresponding tag entirely.
Additionally, you can use the extra method register_src_types on the influx_sim object to pass a dict mapping entities' full IDs to arbitrary strings.
Entities for which the full ID is registered in this way will have their data point augmented by the tag src_type, with the corresponding value in the dict as the tag value.
You would usually use this to store an entities "type" (for example, bus, line, PV system, etc.) as the adapter cannot reliably deduce this from the entity IDs. (Not every simulator uses the convention "ModelName-Index" for those.)
The name of this tag can be changed via the src_type_tag parameter to start.
Metadata
Release files for mosaik-influxdb2 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mosaik_influxdb2-0.4.0.tar.gz | 4.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mosaik_influxdb2-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.7 kB
Release files / mosaik_influxdb2-0.4.0.tar.gz
| Download URL | mosaik_influxdb2-0.4.0.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cba138da1064c3a26a66ff155f024d8d54b2f541c1954965089d706504f6246d
|
|
BLAKE2b-256 checksum How to use checksums |
e4bce906bd5d84de349790d8c14821d9af7ff0fed2476e3ce0cdd5634af33de7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.10.19 Linux/5.15.154+
|
Release files / mosaik_influxdb2-0.4.0-py3-none-any.whl
| Download URL | mosaik_influxdb2-0.4.0-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7eeb88b87e753a6e35c156079925403bc12f8b86179674c4b29124c71d4cbb42
|
|
BLAKE2b-256 checksum How to use checksums |
52067462c5e5ff3bb561e84100af6557a5f8c47204ed04151c56d80134033cb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.10.19 Linux/5.15.154+
|