Skip to content

Commit

Permalink
Updating docs and logger
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-summers committed May 5, 2021
1 parent 1ad3f1d commit 05dc807
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions miniconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from gmqtt import Client as MqttClient

LOGGER = logging.getLogger(__name__)

class Miniconf:
"""An asynchronous API for controlling Miniconf devices using MQTT."""
Expand All @@ -39,7 +40,6 @@ def __init__(self, client, prefix):
self.inflight = {}
self.client.on_message = self._handle_response
self.client.subscribe(f'{prefix}/response/{self.uuid.hex}')
self.logger = logging.getLogger(__name__)

def _handle_response(self, _client, _topic, payload, _qos, properties):
"""Callback function for when messages are received over MQTT.
Expand Down Expand Up @@ -69,8 +69,7 @@ async def command(self, path, value):
value: The value to write to the path.
Returns:
(code, msg) tuple as a response to the command. `code` is zero for success and `msg` is
a use-readable message indicating further information.
The response to the command as a dictionary.
"""
setting_topic = f'{self.prefix}/settings/{path}'
response_topic = f'{self.prefix}/response/{self.uuid.hex}'
Expand All @@ -85,7 +84,7 @@ async def command(self, path, value):
}).encode('ascii')

value = json.dumps(value)
self.logger.info('Sending %s to "%s"', value, setting_topic)
LOGGER.info('Sending %s to "%s"', value, setting_topic)
fut = asyncio.get_running_loop().create_future()

self.inflight[request_id] = fut
Expand Down

0 comments on commit 05dc807

Please sign in to comment.