Message types for the openhab_bridge. It is based on the Item Types and Command Types of openHAB.

Install the openhab_msgs

In the next step you have to install the openhab_msgs in your catkin workspace:

cd ~/catkin_ws/src
git clone --branch <branchname> https://github.com/Michdo93/openhab_msgs
cd ~/catkin_ws
catkin_make

Please replace <branchname> with your branch, as example kinetic-devel, melodic-devel or noetic-devel.

Explanation

For subscribing from openHAB a State Message Type is used and for publishing to openHAB a Command Message Type is used. For an item type (openHAB), this means that two message types (ROS) are used in this event bus.

Type Name

State Message Type

Command Message Type

Color

openhab_msgs/ColorState

openhab_msgs/ColorCommand

Contact

openhab_msgs/ContactState

openhab_msgs/ContactCommand

DateTime

openhab_msgs/DateTimeState

openhab_msgs/DateTimeCommand

Dimmer

openhab_msgs/DimmerState

openhab_msgs/DimmerCommand

Group

openhab_msgs/GroupState

n/a

Image

openhab_msgs/ImageState

openhab_msgs/ImageCommand

Location

openhab_msgs/LocationState

openhab_msgs/LocationCommand

Number

openhab_msgs/NumberState

openhab_msgs/NumberCommand

Player

openhab_msgs/PlayerState

openhab_msgs/PlayerCommand

Rollershutter

openhab_msgs/RollershutterState

openhab_msgs/RollershutterCommand

String

openhab_msgs/StringState

openhab_msgs/StringCommand

Switch

openhab_msgs/SwitchState

openhab_msgs/SwitchCommand

Item Types

To subscribe the items from openHAB or to publish an item including a command to openHAB you need the appropriate message types. These are based on the Item Types and Command Types of openHAB.

The Item type defines what kind of state can be stored in that Item and which commands the Item will accept. Item types are comparable to basic variable data types in programming languages. Each Item type has been optimized for a particular kind of component in your smart home. This optimization is reflected in the data and command types.

Available Item types are:

Item Type

Description

Command Types

Color

Color information (HSB)

OnOff, IncreaseDecrease, Percent, HSB

Contact

Status of contacts, e.g. door/window contacts. Does not accept commands, only status updates.

-

DateTime

Stores date and time

-

Dimmer

Percentage value for dimmers

OnOff, IncreaseDecrease, Percent

Group

Item to nest other items / collect them in groups

-

Image

Binary data of an image. This means a base64 encoded string

-

Location

GPS coordinates

Point

Number

Values in number format

Decimal

Player

Allows control of players (e.g. audio players)

PlayPause, NextPrevious, RewindFastforward

Rollershutter

Rollershutter Item, typically used for blinds

UpDown, StopMove, Percent

String

Stores texts

String

Switch

Switch Item, used for anything that needs to be switched ON and OFF

OnOff

Command Types

In the last step we take a closer look at the Command Types and its Range of Values.

Command Type

Range of Values

Decimal

<int> or <float>
So theoretically the max values of an integer or float in Java.

HSB

"<hue>,<saturation>,<brightness>"
<hue>: 0...360
<saturation>: 0...100
<brightness>: 0...100

IncreaseDecrease

"INCREASE" or "DECREASE"

NextPrevious

"NEXT" or "PREVIOUS"

OnOff

"ON" or "OFF"

OpenClosed

"OPEN" or "CLOSED"

Percent

0...100

PlayPause

"PLAY" or "PAUSE"

Point

"<longitude>,<latitude>,<altitude>"
<longitude>: -180.0...0...180.0 degrees
<latitude>: -90.0...0...90.0 degrees
<altitude>: <float> in meters. There are locations that are below sea level and there are mountains that are quite a bit higher. A limit value is not known.

RewindFastforward

"REWIND" or "FASTFORWARD"

StopMove

"STOP" or "MOVE"

String

<String>
So theoretically the maximum size of an String in Java.

UpDown

"UP" or "DOWN"

A command type like OnOff is ultimately an enum and contains the strings "ON" and "OFF" as constants (this is why they are written in UPPERCASE), so the other enum commands actually look the same. This means that there are only two constants per each enum type.

The Command Types are only used within openHAB. The openhab_msgs also have these enums in their field description, but you may have to work with a string in parts of your program!

Wiki: openhab_msgs (last edited 2022-10-28 14:17:17 by Michdo93)