Code Examples

This examples can be used as kick-off before jumping into the bco development. They pick up the basic functions like how to query, control and access any units.

Note: Please make sure spread and bco are started within your network before executing the howtos.

Java DAL Remote

For running any java examples you only need to include the dal remote dependency in your maven or gradle project description:

<dependency>
    <groupId>org.openbase</groupId>
    <artifactId>bco.dal.remote</artifactId>
    <version>[2.0-SNAPSHOT,2.1-alpha)</version>
</dependency>
1
2
3
4
5

How to activate a scene

Request the unit

    LOGGER.info("request the scene with the label \"WatchingTV\"");
    testScene = Units.getUnitByLabel("WatchingTV", true, Units.SCENE);
1
2

Control the unit

    LOGGER.info("activate the scene");
    testScene.setActivationState(ActivationState.State.ACTIVE);
1
2

How to control a colorable light

Request the unit

    LOGGER.info("request the light unit with the label \"TestUnit_0\"");
    testLight = Units.getUnitByLabel("TestUnit_0", true, Units.LIGHT_COLORABLE);
1
2

Control the unit

    LOGGER.info("switch the light on");
    testLight.setPowerState(PowerState.State.ON);

    LOGGER.info("switch light color to blue");
    testLight.setColor(Color.BLUE);
1
2
3
4
5

How to observe a location specific reed contact

How to observe service state changes

Java RSB

How to observe service state changes

Python RSB

How to request, control and observe units

Last Updated: 3/27/2019, 3:07:24 PM