blob: c1096cc743e8234c7db0b7eacf90a036632b5d36 (
plain)
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
|
#!/usr/bin/env python3
import sys
import os.path
sys.path.extend([
os.path.realpath(
os.path.join(os.path.dirname(os.path.join(__file__)), '..')
)
])
from argparse import ArgumentParser
from src.home.config import config
from src.home.mqtt.relay import MQTTRelayController
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument('--on', action='store_true')
parser.add_argument('--off', action='store_true')
parser.add_argument('--stat', action='store_true')
config.load('test_mqtt_relay', parser=parser)
arg = parser.parse_args()
relay = MQTTRelayController('test')
relay.configure_tls()
relay.connect_and_loop(loop_forever=False)
if arg.on:
relay.set_power(True)
elif arg.off:
relay.set_power(False)
elif arg.stat:
relay.send_stat(dict(
state=False,
signal=-59,
fw_v=1.0
))
|