Skip to main content

Sends mosaik simulation data to ZeroMQ socket.

Project description


This adapter was built to send mosaik simulation data to the data stream management system Odysseus. Odysseus allows to process and visualise the simulation results online during the simulation. More information can be found in the mosaik documentation.

But due to the use of ZeroMQ, which is a high-performance asynchronous messaging library, the mosaik-zmq adapter can also be used to process or store results of a simulation in any software supporting ZeroMQ sockets.


mosaik-zmq can be installed using pip:

$ pip install mosaik-zmq

mosaik-zmq uses the pyzmq module. If you get an error during installation, install the python 3 headers and python-zmq package (e.g., sudo apt-get install python3-dev python-zmq)

If installation is still not working you may need to install a C compiler (e.g. sudo apt-get install build-essential)


The mosaik-zmq adapter can be added to a simulation scenario like any other component. First you have to add the following code to the sim_config:

sim_config = {
   'ZMQ': {
      'cmd': 'mosaik-zmq %(addr)s',


When you start mosaik-zmq, you have to provide a step_size and a duration argument. The step_size defines how often data will be sent. The duration is the simulation end time in seconds.


zmqModel = world.start('ZMQ', step_size=15*60, duration=15*60*24*30)

Model instantiation

Every instance of mosaik-zmq allows you to create instances of its Socket model. The Socket has the following parameters:

  • host (default: ‘tcp://*:’) is the address of the host the data will be sent to.
  • port (default: 5558) is the port on which the host will receive data.
  • socket_type (default: ‘PUB’) is the type of the ZeroMQ socket to open for connection between the adapter and the host. Two different patterns can be used. The default is ‘PUB’, which stands for the publish subscribe pattern . Alternatively the push pull pattern (‘PUSH’) can be used.

Example code:

zmq = zmqModel.Socket(host='tcp://*:', port=5558, socket_type='PUB')


To get data sent to the host the zmq model has to be connected to an other model in the scenario definition. Based on the mosaik-demo the scenario could look like this:

pvsim = world.start('CSV', sim_start=START, datafile=PV_DATA)
pvs = pvsim.PV.create(20)

zmqModel = world.start('ZMQ', step_size=15*60, duration=15*60*24*30)
zmq = zmqModel.Socket(host='tcp://*:', port=5558, socket_type='PUB')

connect_many_to_one(world, pvs, zmq, 'P')

Getting help

If you need help, please visit the mosaik-users mailing list.


0.1.1 – 2016-01-20

  • Updated documentation

0.1 – 2015-12-16

  • Initial release


The mosaik ZeroMQ connector was created by Jan Sören Schwarz.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for mosaik-zmq, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size mosaik_zmq-0.1.1-py3-none-any.whl (6.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size mosaik-zmq-0.1.1.tar.gz (12.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page