|
4 years ago | |
---|---|---|
dist | 4 years ago | |
fhem | 4 years ago | |
.gitignore | 4 years ago | |
CHANGELOG | 4 years ago | |
README.md | 4 years ago | |
setup.py | 4 years ago |
Descripton
Useful to send commands to Fhem and handle the received answer. A own connection is created for each command which is send to the Fhem-server.
Example
#: import needed API
from fhem import WebApi
# creates an api class with the WebApi. WebAuth is used so username and password are given.
# for more security we activate ssl (is on by default). We used a self-sign cert so we disable the verify.
api = WebApi('192.168.1.101', 8083, user='admin', pwd='s3cR3t', ssl=True, verify=False)
#: send the command to toggle "MainBulb01" on. In This case None is returned.
api.send('set MainBulb01 on')
#: saved the received answer from get-command to recv. In this case may a hex color code like 2AFF0F
recv = api.send('get MainBulb01 rgb')
#: print out the received answer
print(recv)