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 |
||
Contact |
||
DateTime |
||
Dimmer |
||
Group |
n/a |
|
Image |
||
Location |
||
Number |
||
Player |
||
Rollershutter |
||
String |
||
Switch |
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> |
HSB |
"<hue>,<saturation>,<brightness>" |
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>" |
RewindFastforward |
"REWIND" or "FASTFORWARD" |
StopMove |
"STOP" or "MOVE" |
String |
<String> |
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!