Link Search Menu Expand Document

Beginner Example - The bare minimum you need to start using ARENA-py

Let’s start by installing and importing the library

pip3 install arena-py

Ok, now let’s get started!

Setup environmental variables (reccomended but not required)

Replace [host], [realm], and [scene] with your desired mqtt broker, realm, and scene name, respectively.

export MQTTH=[host]
export REALM=[realm]
export SCENE=[scene]

Import the library

from arena import *

Start the client

arena = Scene()

You can also pass host and scene as arguments, if you don’t want to use environmental variables. These must be keyword arguments:

scene = Scene(host=[host], scene=[scene])

Note: ARENA-py will always favor environmental variables over arguments.

Define a task

ARENA-py works by running tasks in an event loop, so we need a main task for our sample program.

def main():

Our first object

Inside main(), lets make a box!

box = Box(object_id="my_box", position=Position(0,4,-2), scale=Scale(2,2,2))

Note the input arguments. The names must match what they will be in the ARENA JSON specification. We don’t have to worry too much about that now, but keep this in mind, as typos will be very bad!

Box is a type of “Object”. See objects.

Position and Scale are what we call “Attributes”. See attributes.

Adding our object to the ARENA


Start the event loop

Now, outside of main, we will write:


Now, go into the scene to see your box!


from arena import *

# setup library
scene = Scene(host="", scene="example")

def main():
    # make a box
    box = Box(object_id="my_box", position=Position(0,4,-2), scale=Scale(2,2,2))
    # add the box

# add and start tasks