-
Notifications
You must be signed in to change notification settings - Fork 3
Connecting to the backend
Guido Schmitz edited this page Nov 7, 2020
·
4 revisions
The Home Control backend consists two parts, one called Mydevolo and one called HomeControl. To connect to this backend, you need the credentials of your my devolo account. The following snippet will connect to Mydevolo, ask for all gateway serial numbers attached to that account and connect to HomeControl with the first serial number found.
from devolo_home_control_api.homecontrol import HomeControl
from devolo_home_control_api.mydevolo import Mydevolo
user = "username"
password = "password"
mydevolo = Mydevolo()
mydevolo.user = user
mydevolo.password = password
gateway_id = mydevolo.get_gateway_ids()[0]
homecontrol = HomeControl(gateway_id=gateway_id, mydevolo_instance=mydevolo)Of course you do not need to limit your calls to the first gateway but can create a HomeControl instance for every gateway found.
There is an open websocket connection that continues running in an own thread. It needs to be closed as soon as you are not interested in updates anymore.
homecontrol.websocket_disconnect()Alternatively, you can use a with-statement. It will then take care of closing the websocket.
from devolo_home_control_api.homecontrol import HomeControl
from devolo_home_control_api.mydevolo import Mydevolo
user = "username"
password = "password"
mydevolo = Mydevolo()
mydevolo.user = user
mydevolo.password = password
gateway_id = mydevolo.get_gateway_ids()[0]
with HomeControl(gateway_id=gateway_id, mydevolo_instance=mydevolo) as homecontrol:
# do what needs to be done