An adapter to connect mosaik with InfluxDB 2
Project description
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_size
when 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
datetime
module) 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_time
attribute (again, as a string). If you give both, the value on thelocal_time
attribute 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mosaik_influxdb2-0.3.0.tar.gz
.
File metadata
- Download URL: mosaik_influxdb2-0.3.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.11 Linux/5.4.109+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f0a5400257d51d7cdfeb5e62e4263ad224d3a37f2ceeaae57aa1f120a3c4272 |
|
MD5 | e8922f27795852e8d2614dcbc8b23532 |
|
BLAKE2b-256 | dcdaf9744c5b58b003bf518ff07f8d619c86d38f41f1f9ab8782a20b48fea261 |
File details
Details for the file mosaik_influxdb2-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: mosaik_influxdb2-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.11 Linux/5.4.109+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 865e85c3fa52f5a5c26a087da7795e2d96fddf5fd06528791afa476b9737f10e |
|
MD5 | 8361c9c4058a5cce5e0aad3f86189128 |
|
BLAKE2b-256 | 05d1368eccc72726da7346d18be0444667f0d1bb0fef86a9b1216c1fd41f8adc |