Python module for easily accessing the openHAB REST API

Hi All
(my first post)

@sim0nx I like your work.
I’m a noob but I’d like to learn this module.
Can you give some exemples for switch and contact?
I’m running openhab2 on raspberry pi 2 and I try to turn on/off a led.

My wrong code is

Items
Switch led "Led" (Lights) { gpio="pin:16" }

python-openhab

from openhab import openHAB
base_url = 'http://localhost:8080/rest'
openhab = openHAB(base_url)
# fetch all items
items = openhab.fetch_all_items()

gg = items.get('led')
print(gg.state)
gg.on()

OH2 printe OFF state and turn ON my switch but don’t turn ON my led
events.log
[ItemStateChangedEvent ] - led changed from OFF to ON

When I switch through BasicUI or Android app led turn ON
events.log

[ItemCommandEvent          ] - Item 'led' received command ON
[ItemStateChangedEvent     ] - led changed from OFF to ON

…and led works.

Someone can help me?