Updating docs and logger
This commit is contained in:
parent
1ad3f1d1a8
commit
05dc80709e
|
@ -14,6 +14,7 @@ import uuid
|
||||||
|
|
||||||
from gmqtt import Client as MqttClient
|
from gmqtt import Client as MqttClient
|
||||||
|
|
||||||
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
class Miniconf:
|
class Miniconf:
|
||||||
"""An asynchronous API for controlling Miniconf devices using MQTT."""
|
"""An asynchronous API for controlling Miniconf devices using MQTT."""
|
||||||
|
@ -39,7 +40,6 @@ class Miniconf:
|
||||||
self.inflight = {}
|
self.inflight = {}
|
||||||
self.client.on_message = self._handle_response
|
self.client.on_message = self._handle_response
|
||||||
self.client.subscribe(f'{prefix}/response/{self.uuid.hex}')
|
self.client.subscribe(f'{prefix}/response/{self.uuid.hex}')
|
||||||
self.logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
def _handle_response(self, _client, _topic, payload, _qos, properties):
|
def _handle_response(self, _client, _topic, payload, _qos, properties):
|
||||||
"""Callback function for when messages are received over MQTT.
|
"""Callback function for when messages are received over MQTT.
|
||||||
|
@ -69,8 +69,7 @@ class Miniconf:
|
||||||
value: The value to write to the path.
|
value: The value to write to the path.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
(code, msg) tuple as a response to the command. `code` is zero for success and `msg` is
|
The response to the command as a dictionary.
|
||||||
a use-readable message indicating further information.
|
|
||||||
"""
|
"""
|
||||||
setting_topic = f'{self.prefix}/settings/{path}'
|
setting_topic = f'{self.prefix}/settings/{path}'
|
||||||
response_topic = f'{self.prefix}/response/{self.uuid.hex}'
|
response_topic = f'{self.prefix}/response/{self.uuid.hex}'
|
||||||
|
@ -85,7 +84,7 @@ class Miniconf:
|
||||||
}).encode('ascii')
|
}).encode('ascii')
|
||||||
|
|
||||||
value = json.dumps(value)
|
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()
|
fut = asyncio.get_running_loop().create_future()
|
||||||
|
|
||||||
self.inflight[request_id] = fut
|
self.inflight[request_id] = fut
|
||||||
|
|
Loading…
Reference in New Issue