(a merge of sim0nx/python-openhab, with commit from kabili207 to support Dimmer and Color item)
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
- python :: typing
The current version is focused on OpenHAB 2.x; OpenHAB 1.x might still work, though this is not tested. If you require older OpenHAB support, please use an older version of this library.
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')
print(sunset.state)
# fetch a single item
item = openhab.get_item('light_switch')
# turn a swith on
item.on()
# send a state update (this only update the state)
item.state = 'OFF'
# send a command
item.command('ON')