mirror of
https://github.com/vvzvlad/vestasync.git
synced 2024-12-26 04:01:00 +03:00
add args
This commit is contained in:
parent
2cd5789036
commit
456fe8ed4e
@ -2,6 +2,11 @@ import paho.mqtt.client as mqtt
|
|||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description="MQTT Device Error Status")
|
||||||
|
parser.add_argument("-a", "--wb", type=str, required=True, help="WB address")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
def get_modbus_devices():
|
def get_modbus_devices():
|
||||||
devices = {}
|
devices = {}
|
||||||
@ -16,7 +21,7 @@ def get_modbus_devices():
|
|||||||
client = mqtt.Client()
|
client = mqtt.Client()
|
||||||
client.on_connect = on_connect
|
client.on_connect = on_connect
|
||||||
client.on_message = on_message
|
client.on_message = on_message
|
||||||
client.connect("192.168.98.244", 1883, 60)
|
client.connect(args.wb, 1883, 60)
|
||||||
client.loop_start()
|
client.loop_start()
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
client.loop_stop()
|
client.loop_stop()
|
||||||
@ -37,12 +42,10 @@ def get_all_controls(devices):
|
|||||||
client = mqtt.Client()
|
client = mqtt.Client()
|
||||||
client.on_connect = on_connect
|
client.on_connect = on_connect
|
||||||
client.on_message = on_message
|
client.on_message = on_message
|
||||||
client.connect("192.168.98.244", 1883, 60)
|
client.connect(args.wb, 1883, 60)
|
||||||
client.loop_start()
|
client.loop_start()
|
||||||
time.sleep(0.5)
|
time.sleep(3)
|
||||||
client.loop_stop()
|
client.loop_stop()
|
||||||
for device in devices.keys():
|
|
||||||
client.unsubscribe(f"/devices/{device}/controls/+")
|
|
||||||
client.disconnect()
|
client.disconnect()
|
||||||
return devices
|
return devices
|
||||||
|
|
||||||
@ -66,7 +69,7 @@ def get_all_controls_errors(devices):
|
|||||||
client = mqtt.Client()
|
client = mqtt.Client()
|
||||||
client.on_connect = on_connect
|
client.on_connect = on_connect
|
||||||
client.on_message = on_message
|
client.on_message = on_message
|
||||||
client.connect("192.168.98.244", 1883, 60)
|
client.connect(args.wb, 1883, 60)
|
||||||
client.loop_start()
|
client.loop_start()
|
||||||
|
|
||||||
def sort_devices(devices):
|
def sort_devices(devices):
|
||||||
|
Loading…
Reference in New Issue
Block a user