forked from openviess/PyViCare
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
49 lines (31 loc) · 1.28 KB
/
test.py
File metadata and controls
49 lines (31 loc) · 1.28 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
37
38
39
40
41
42
43
44
45
46
47
48
import asyncio
import logging
from PyViCareLive.PyViCare import PyViCare
client_id = "d382a049bd6ebd7e9a219d45b6de72f3" #From ViCare APP
email = "test@test.net"
password = "lol1234"
logger = logging.getLogger('ViCare')
logger.setLevel(level=logging.INFO)
logger.addHandler(logging.StreamHandler())
class mainClass():
def __init__(self):
print(PyViCare)
print(type(PyViCare))
self.vicare = PyViCare()
self.vicare.init_with_credentials(email, password, client_id, "token.save")
async def start(self):
for device in self.vicare.devices:
for feature in device.getFeatures():
device.subscribeToLiveUpdatesForProperty(self.updatesProperty, feature)
def renew(self):
print("Renew was called")
self.vicare.init_with_credentials(email, password, client_id, "token.save")
self.vicare.websocket_manager.add_renew_listener(self.renew)
def updatesProperty(self, device_id, property_name: str, data: Any) -> None:
for property,prop_data in data["properties"].items():
print(f"{device_id}/{property_name.replace('.', '/')}/{property} with value {prop_data}")
async def main():
mainC = mainClass()
await mainC.start()
if __name__ == "__main__":
asyncio.run(main())