_read_unwanted_data_fix is now controlled via settings
This commit is contained in:
@@ -10,6 +10,7 @@ mqtt:
|
||||
gateway:
|
||||
ip: 192.168.0.47
|
||||
password: passw0rd
|
||||
unwanted_data_fix: True #leave it True if it works for you. Otherwise (if you didn't recieve any data from sensors) - set it to False
|
||||
polling_interval: 2
|
||||
polling_models:
|
||||
- motion
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
aqara:
|
||||
image: monster1025/aqara-mqtt:1-armhf
|
||||
#build: .
|
||||
#dockerfile: Dockerfile-armhf
|
||||
#image: monster1025/aqara-mqtt:1-armhf
|
||||
build: .
|
||||
dockerfile: Dockerfile-armhf
|
||||
container_name: aqara
|
||||
volumes:
|
||||
- "./config:/app/config"
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ if __name__ == "__main__":
|
||||
client.subscribe("gateway", "+", "write", None)
|
||||
client.subscribe("plug", "+", "status", "set")
|
||||
|
||||
gateway = XiaomiHub(gateway_pass, gateway_ip)
|
||||
gateway = XiaomiHub(gateway_pass, gateway_ip, config)
|
||||
stop_event= threading.Event()
|
||||
t1 = threading.Thread(target=process_gateway_messages, args=[gateway, client, stop_event])
|
||||
t1.daemon = True
|
||||
|
||||
+11
-3
@@ -28,7 +28,7 @@ class XiaomiHub:
|
||||
GATEWAY_DISCOVERY_PORT = 4321
|
||||
SOCKET_BUFSIZE = 1024
|
||||
|
||||
def __init__(self, key, gateway=None):
|
||||
def __init__(self, key, gateway_ip=None, config=None):
|
||||
self.GATEWAY_KEY = key
|
||||
self._listening = False
|
||||
self._queue = None
|
||||
@@ -36,9 +36,14 @@ class XiaomiHub:
|
||||
self._mcastsocket = None
|
||||
self._deviceCallbacks = defaultdict(list)
|
||||
self._threads = []
|
||||
self._read_unwanted_data_enabled = True
|
||||
|
||||
if gateway is not None:
|
||||
self.GATEWAY_DISCOVERY_ADDRESS = gateway
|
||||
if gateway_ip is not None:
|
||||
self.GATEWAY_DISCOVERY_ADDRESS = gateway_ip
|
||||
|
||||
if config is not None and 'gateway' in config and 'unwanted_data_fix' in config['gateway']:
|
||||
self._read_unwanted_data_enabled = (config['gateway']['unwanted_data_fix'] == True)
|
||||
_LOGGER.info('"Read unwanted data" fix is {0}'.format(self._read_unwanted_data_enabled))
|
||||
|
||||
try:
|
||||
_LOGGER.info('Discovering Xiaomi Gateways using address {0}'.format(self.GATEWAY_DISCOVERY_ADDRESS))
|
||||
@@ -113,6 +118,9 @@ class XiaomiHub:
|
||||
return self._send_socket(cmd, rtnCmd, self.GATEWAY_IP, self.GATEWAY_PORT)
|
||||
|
||||
def _read_unwanted_data(self):
|
||||
if not self._read_unwanted_data_enabled:
|
||||
return
|
||||
|
||||
try:
|
||||
socket = self._socket
|
||||
socket_list = [sys.stdin, socket]
|
||||
|
||||
+9
-9
@@ -13,12 +13,12 @@ def load_yaml(file):
|
||||
_LOGGER.error("Can't load yaml with sids %r (%r)" % (file, e))
|
||||
|
||||
def get_gateway_password(config, ip=""):
|
||||
if (config == None):
|
||||
raise "Config is null"
|
||||
configGateway = config.get("gateway", None)
|
||||
if (configGateway == None):
|
||||
raise "Config gateway is null"
|
||||
password = configGateway.get("password", None)
|
||||
if (password == None):
|
||||
raise "Config gateway passowrd is null"
|
||||
return password
|
||||
if (config == None):
|
||||
raise "Config is null"
|
||||
configGateway = config.get("gateway", None)
|
||||
if (configGateway == None):
|
||||
raise "Config gateway is null"
|
||||
password = configGateway.get("password", None)
|
||||
if (password == None):
|
||||
raise "Config gateway passowrd is null"
|
||||
return password
|
||||
|
||||
Reference in New Issue
Block a user