Merge pull request #17 from groggemans/add_sensor_models
Add sensor models
This commit is contained in:
@@ -12,6 +12,7 @@ from xiaomihub import XiaomiHub
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def process_gateway_messages(gateway, client, stop_event):
|
||||
while not stop_event.is_set():
|
||||
try:
|
||||
@@ -32,6 +33,7 @@ def process_gateway_messages(gateway, client, stop_event):
|
||||
_LOGGER.error('Error while sending from gateway to mqtt: ', str(e))
|
||||
_LOGGER.info("Stopping Gateway Thread ...")
|
||||
|
||||
|
||||
def read_motion_data(gateway, client, polling_interval, polling_models, stop_event):
|
||||
first = True
|
||||
while not stop_event.is_set():
|
||||
@@ -62,6 +64,7 @@ def read_motion_data(gateway, client, polling_interval, polling_models, stop_eve
|
||||
time.sleep(polling_interval)
|
||||
_LOGGER.info("Stopping Polling Thread ...")
|
||||
|
||||
|
||||
def process_mqtt_messages(gateway, client, stop_event):
|
||||
while not stop_event.is_set():
|
||||
try:
|
||||
@@ -79,6 +82,7 @@ def process_mqtt_messages(gateway, client, stop_event):
|
||||
_LOGGER.error('Error while sending from mqtt to gateway: ', str(e))
|
||||
_LOGGER.info("Stopping MQTT Thread ...")
|
||||
|
||||
|
||||
def exit_handler(signal, frame):
|
||||
print('Exiting')
|
||||
stop_event.set()
|
||||
|
||||
@@ -6,6 +6,7 @@ import json
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Mqtt:
|
||||
event_based_sensors = ["switch", "cube"]
|
||||
motion_sensors = ["motion", "sensor_motion.aq2"]
|
||||
|
||||
+7
-6
@@ -10,7 +10,8 @@ from threading import Thread
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
# MANDATORY!!!! NEED TO TURN OFF "_process_report" THREAD IF CODE IS UPDATED!!!!
|
||||
# MANDATORY!!!! NEED TO TURN OFF "_process_report" THREAD IF CODE IS UPDATED!!!
|
||||
|
||||
|
||||
class XiaomiHub:
|
||||
GATEWAY_KEY = None
|
||||
@@ -84,8 +85,10 @@ class XiaomiHub:
|
||||
|
||||
_LOGGER.info('Found {0} devices'.format(len(sids)))
|
||||
|
||||
sensors = ['sensor_ht', 'sensor_wleak.aq1']
|
||||
binary_sensors = ['magnet', 'motion', 'switch', '86sw1', '86sw2', 'cube']
|
||||
sensors = ['sensor_ht', 'weather.v1', 'sensor_wleak.aq1']
|
||||
binary_sensors = ['magnet', 'sensor_magnet.aq2', 'motion',
|
||||
'sensor_motion.aq2', 'switch', 'sensor_switch.aq2',
|
||||
'86sw1', '86sw2', 'cube']
|
||||
switches = ['plug', 'ctrl_neutral1', 'ctrl_neutral2']
|
||||
|
||||
for sid in sids:
|
||||
@@ -109,9 +112,6 @@ class XiaomiHub:
|
||||
else:
|
||||
device_type = 'sensor' # not really matters
|
||||
|
||||
if device_type == None:
|
||||
_LOGGER.error('Unsupported devices : {0}'.format(model))
|
||||
else:
|
||||
self.XIAOMI_DEVICES[device_type].append(xiaomi_device)
|
||||
|
||||
def _send_cmd(self, cmd, rtnCmd):
|
||||
@@ -248,6 +248,7 @@ class XiaomiHub:
|
||||
|
||||
self._queue.task_done()
|
||||
|
||||
|
||||
class XiaomiDevice():
|
||||
"""Representation a base Xiaomi device."""
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import logging
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def load_yaml(file):
|
||||
try:
|
||||
stram = open(file, "r")
|
||||
@@ -12,6 +13,7 @@ def load_yaml(file):
|
||||
raise
|
||||
_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"
|
||||
|
||||
Reference in New Issue
Block a user