Skip to content

Commit

Permalink
Minor logging tweaks around adding/removing sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
raetha committed Nov 30, 2020
1 parent ef87985 commit 185cc2c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions wyzesense2mqtt/wyzesense2mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def init_sensors():

# Validate sensor MAC
def valid_sensor_mac(sensor_mac):
LOGGER.debug(f"sensor_mac: {sensor_mac}")
#LOGGER.debug(f"Validating MAC: {sensor_mac}")
invalid_mac_list = [
"00000000",
"\0\0\0\0\0\0\0\0",
Expand All @@ -224,6 +224,7 @@ def valid_sensor_mac(sensor_mac):
# Add sensor to config
def add_sensor_to_config(sensor_mac, sensor_type, sensor_version):
global SENSORS
LOGGER.info(f"Adding sensor to config: {sensor_mac}")
SENSORS[sensor_mac] = dict()
SENSORS[sensor_mac]['name'] = f"Wyze Sense {sensor_mac}"
SENSORS[sensor_mac]['class'] = (
Expand All @@ -234,21 +235,19 @@ def add_sensor_to_config(sensor_mac, sensor_type, sensor_version):
if (sensor_version is not None):
SENSORS[sensor_mac]['sw_version'] = sensor_version

LOGGER.info("Writing Sensors Config File")
write_yaml_file(CONFIG_PATH + SENSORS_CONFIG_FILE, SENSORS)


# Delete sensor from config
def delete_sensor_from_config(sensor_mac):
global SENSORS
LOGGER.info(f"Deleting sensor from config: {sensor_mac}")
try:
del SENSORS[sensor_mac]
write_yaml_file(CONFIG_PATH + SENSORS_CONFIG_FILE, SENSORS)
except KeyError:
LOGGER.debug(f"{sensor_mac} not found in SENSORS")

LOGGER.info("Writing Sensors Config File")
write_yaml_file(CONFIG_PATH + SENSORS_CONFIG_FILE, SENSORS)


# Publish MQTT topic
def mqtt_publish(mqtt_topic, mqtt_payload):
Expand Down

0 comments on commit 185cc2c

Please sign in to comment.