Compile before
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
#SHELL := /bin/bash
|
||||
|
||||
ARGS = `arg="$(filter-out $@,$(MAKECMDGOALS))" && echo $${arg:-${1}}`
|
||||
|
||||
commit:
|
||||
lint:
|
||||
rm -rf "src/__pycache__"
|
||||
python3 -m compileall src
|
||||
rm -rf "src/__pycache__"
|
||||
|
||||
commit: lint
|
||||
git add .
|
||||
git commit -m "$(call ARGS,\"updating to lastest local code\")"
|
||||
git push
|
||||
|
||||
%:
|
||||
@:
|
||||
@:
|
||||
|
||||
+7
-8
@@ -1,7 +1,6 @@
|
||||
import logging
|
||||
import time
|
||||
import threading
|
||||
import os
|
||||
import json
|
||||
import signal
|
||||
|
||||
@@ -41,16 +40,16 @@ def read_motion_data(gateway, client, polling_interval, polling_models, stop_eve
|
||||
devices = gateway.XIAOMI_DEVICES[device_type]
|
||||
for device in devices:
|
||||
model = device.get("model", "")
|
||||
if (model not in polling_models):
|
||||
if model not in polling_models:
|
||||
continue
|
||||
sid = device['sid']
|
||||
|
||||
sensor_resp = gateway.get_from_hub(sid)
|
||||
if (sensor_resp == None):
|
||||
continue;
|
||||
if (sensor_resp['sid'] != sid):
|
||||
if sensor_resp is None:
|
||||
continue
|
||||
if sensor_resp['sid'] != sid:
|
||||
_LOGGER.error("Error: Response sid(" + sensor_resp['sid'] + ") differs from requested(" + sid + "). Skipping.")
|
||||
continue;
|
||||
continue
|
||||
|
||||
data = json.loads(sensor_resp['data'])
|
||||
state = data.get("status", None)
|
||||
@@ -93,7 +92,7 @@ def exit_handler(signal, frame):
|
||||
|
||||
if __name__ == "__main__":
|
||||
_LOGGER.info("Loading config file...")
|
||||
config=yamlparser.load_yaml('config/config.yaml')
|
||||
config = yamlparser.load_yaml('config/config.yaml')
|
||||
gateway_pass = yamlparser.get_gateway_password(config)
|
||||
polling_interval = config['gateway'].get("polling_interval", 2)
|
||||
polling_models = config['gateway'].get("polling_models", ['motion'])
|
||||
@@ -111,7 +110,7 @@ if __name__ == "__main__":
|
||||
client.subscribe("plug", "+", "status", "set")
|
||||
|
||||
gateway = XiaomiHub(gateway_pass, gateway_ip, config)
|
||||
stop_event= threading.Event()
|
||||
stop_event = threading.Event()
|
||||
t1 = threading.Thread(target=process_gateway_messages, args=[gateway, client, stop_event])
|
||||
t1.daemon = True
|
||||
t1.start()
|
||||
|
||||
Reference in New Issue
Block a user