Skip to main content

python library for accessing the openHAB REST API

Project description

Codacy badge Documentation Status pypi version travis-ci status

python library for accessing the openHAB REST API

This library allows for easily accessing the openHAB REST API. A number of features are implemented but not all, this is work in progress.


  • python >= 3.5
  • python :: dateutil
  • python :: requests
  • openHAB version 2


Install the latest version using pip:

pip install python-openhab


Example usage of the library:

from openhab import OpenHAB

base_url = 'http://localhost:8080/rest'
openhab = OpenHAB(base_url)

# fetch all items
items = openhab.fetch_all_items()

sunset = items.get('Sunset')

# fetch a single item
item = openhab.get_item('light_switch')

# turn a switch on

# send a state update (this only update the state)
item.state = 'OFF'

# send a command

# check if item state is NULL
if item.state is None and item.is_state_null():

# check if item state is UNDEF
if item.state is None and item.is_state_undef():

# fetch some group
lights_group = openhab.get_item('lights_group')

# send command to group

# send update to each member
for v in lights_group.members.values():

Note on NULL and UNDEF

In openHAB items may have two states named NULL and UNDEF, which have distinct meanings but basically indicate that an item has no usable value. This library sets the state of an item, regardless of their openHAB value being NULL or UNDEF, to None. This in order to ease working with the library as we do cast certain types to native types.

In order to check if an item’s state is either NULL or UNDEF, you can use the helper functions:


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 python-openhab, version 2.14.1
Filename, size File type Python version Upload date Hashes
Filename, size python_openhab-2.14.1-py3-none-any.whl (23.5 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page