This repository was archived by the owner on Dec 29, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·36 lines (27 loc) · 1.09 KB
/
Copy pathrun.py
File metadata and controls
executable file
·36 lines (27 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import asyncio
import logging
from os import environ
from autobahn.asyncio.websocket import WebSocketClientFactory
from loxone_websocket_client import ClientProtocol
_LOGGER = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
MINISERVER_HOST = environ.get('MINISERVER_HOST', '127.0.0.1')
MINISERVER_PORT = environ.get('MINISERVER_PORT', 80)
MINISERVER_USERNAME = environ.get('MINISERVER_USERNAME', 'admin')
MINISERVER_PASSWORD = environ.get('MINISERVER_PASSWORD', 'admin')
if __name__ == '__main__':
_LOGGER.info('Start WebSocket connection')
ws_factory = WebSocketClientFactory('ws://{host}:{port}/ws/rfc6455'.format(
host=MINISERVER_HOST,
port=MINISERVER_PORT),
protocols=['remotecontrol'])
ws_factory.protocol = ClientProtocol
ws_factory.username = MINISERVER_USERNAME
ws_factory.password = MINISERVER_PASSWORD
loop = asyncio.get_event_loop()
coro = loop.create_connection(ws_factory, MINISERVER_HOST, MINISERVER_PORT)
loop.run_until_complete(coro)
loop.run_forever()
loop.close()