From b9e940e9dead5481f5f71098cf1196898f3b1990 Mon Sep 17 00:00:00 2001 From: raspberry Date: Thu, 22 Feb 2018 11:03:57 +0300 Subject: [PATCH] Fix linter errors --- src/main.py | 4 +--- src/mqtt.py | 12 ++---------- src/xiaomihub.py | 2 +- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/main.py b/src/main.py index e0aa1b5..a1dbb4f 100644 --- a/src/main.py +++ b/src/main.py @@ -52,8 +52,6 @@ def read_motion_data(gateway, client, polling_interval, polling_models, stop_eve continue data = json.loads(sensor_resp['data']) - state = data.get("status", None) - short_id = sensor_resp['short_id'] if device['data'] != data or first: device['data'] = data _LOGGER.debug("Polling result differs for " + str(model) + " with sid(First: " + str(first) + "): " + str(sid) + "; " + str(data)) @@ -75,7 +73,7 @@ def process_mqtt_messages(gateway, client, stop_event): sid = data.get("sid", None) values = data.get("values", dict()) - resp = gateway.write_to_hub(sid, **values) + gateway.write_to_hub(sid, **values) client._queue.task_done() except Exception as e: _LOGGER.error('Error while sending from mqtt to gateway: ', str(e)) diff --git a/src/mqtt.py b/src/mqtt.py index 8cd4a71..4d62667 100644 --- a/src/mqtt.py +++ b/src/mqtt.py @@ -1,5 +1,4 @@ import paho.mqtt.client as mqtt -import os import logging from queue import Queue from threading import Thread @@ -89,7 +88,7 @@ class Mqtt: if (model in self.event_based_sensors): retain = False # fix for rgb format - if (key == "rgb" and self._is_int(value)): + if (key == "rgb" and value.isdigit()): value = self._color_xiaomi_to_rgb(value) items[key] = value @@ -157,7 +156,7 @@ class Mqtt: # use single value set method value = (msg.payload).decode('utf-8') - if self._is_int(value): + if value.isdigit(): value = int(value) # fix for rgb format @@ -202,10 +201,3 @@ class Mqtt: bright = 255 value = int('%02x%02x%02x%02x' % (bright, r, g, b), 16) return value - - def _is_int(self, x): - try: - tmp = int(x) - return True - except Exception as e: - return False diff --git a/src/xiaomihub.py b/src/xiaomihub.py index 3dfe331..24ccb06 100644 --- a/src/xiaomihub.py +++ b/src/xiaomihub.py @@ -237,7 +237,7 @@ class XiaomiHub: if isinstance(packet, dict): try: sid = packet['sid'] - model = packet['model'] + #model = packet['model'] data = json.loads(packet['data']) for device in self.XIAOMI_HA_DEVICES[sid]: