Skip to content

Commit aeb8dd7

Browse files
committed
添加倒计时和实时数据支持
1 parent 0f401d3 commit aeb8dd7

File tree

10 files changed

+296
-71
lines changed

10 files changed

+296
-71
lines changed

example/data_read.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# -*- coding: utf-8 -*-
22

33
"""
4-
mqtt数据处理
4+
mqtt其它数据处理
55
"""
66

77
__author__ = 'stao'
88

99
from blinker import Device
1010

1111

12-
def data_read_func():
12+
async def ready_func():
1313
print(device.data_reader.get())
1414

1515

16-
device = Device("authKey", protocol="mqtts", ready_func=data_read_func)
16+
device = Device("authKey", ready_func=ready_func)
1717

1818
if __name__ == '__main__':
1919
device.run()

example/realtime.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
实时数据
5+
"""
6+
7+
__author__ = 'stao'
8+
9+
import random
10+
11+
from blinker import Device
12+
13+
14+
def generate_data():
15+
return random.randint(1, 100)
16+
17+
18+
async def realtime_func(keys):
19+
print("realtime func received {0}".format(keys))
20+
for key in keys:
21+
if key == "humi":
22+
await device.sendRtData(key, generate_data)
23+
elif key == "temp":
24+
await device.sendRtData(key, generate_data)
25+
26+
27+
device = Device("authKey", realtime_func=realtime_func)
28+
29+
if __name__ == '__main__':
30+
device.run()

example/timing_and_countdown.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
定时和倒计时
5+
"""
6+
7+
__author__ = 'stao'
8+
9+
from blinker import Device
10+
11+
12+
async def builtin_switch_func(msg):
13+
print("received msg: {0}".format(msg))
14+
15+
16+
device = Device("authKey", builtin_switch_func=builtin_switch_func)
17+
18+
if __name__ == '__main__':
19+
device.run()

requirements.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@ aiohttp~=3.7.4
22
certifi~=2021.10.8
33
loguru~=0.5.3
44
paho-mqtt~=1.6.1
5-
Rx~=3.2.0
5+
Rx~=3.2.0
6+
websockets~=10.2
7+
apscheduler~=3.9.1
8+
getmac~=0.8.3
9+
zeroconf~=0.38.4
10+
requests~=2.27.1

setup.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ install_requires =
2525
loguru~=0.5.3
2626
paho-mqtt~=1.6.1
2727
Rx~=3.2.0
28+
websockets~=10.2
29+
apscheduler~=3.9.1
30+
getmac~=0.8.3
31+
zeroconf~=0.38.4
32+
requests~=2.27.1
2833

2934
[options.packages.find]
3035
where = src

setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
'certifi~=2021.10.8',
3131
'loguru~=0.5.3',
3232
'paho-mqtt~=1.6.1',
33-
'Rx~=3.2.0'
33+
'Rx~=3.2.0',
34+
"websockets~=10.2",
35+
'apscheduler~=3.9.1',
36+
'getmac~=0.8.3',
37+
'zeroconf~=0.38.4',
38+
'requests~=2.27.1',
3439
],
3540
)

0 commit comments

Comments
 (0)