forked from jalmeroth/homie-python
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mqtt.html
407 lines (364 loc) · 33 KB
/
mqtt.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module mqtt</title>
<meta charset="utf-8">
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>mqtt</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/Users/jan/R-D/homie-python/homie/mqtt.py">/Users/jan/R-D/homie-python/homie/mqtt.py</a></font></td></tr></table>
<p></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="logging.html">logging</a><br>
</td><td width="25%" valign=top><a href="paho.mqtt.client.html">paho.mqtt.client</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="paho.mqtt.client.html#Client">paho.mqtt.client.Client</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="mqtt.html#HomieMqtt">HomieMqtt</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="HomieMqtt">class <strong>HomieMqtt</strong></a>(<a href="paho.mqtt.client.html#Client">paho.mqtt.client.Client</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>docstring for <a href="#HomieMqtt">HomieMqtt</a><br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="mqtt.html#HomieMqtt">HomieMqtt</a></dd>
<dd><a href="paho.mqtt.client.html#Client">paho.mqtt.client.Client</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="HomieMqtt-__del__"><strong>__del__</strong></a>(self)</dt></dl>
<dl><dt><a name="HomieMqtt-__init__"><strong>__init__</strong></a>(self, homieObj, deviceId)</dt></dl>
<dl><dt><a name="HomieMqtt-on_connect"><strong>on_connect</strong></a>(self, mqttc, obj, flags, rc)</dt></dl>
<dl><dt><a name="HomieMqtt-on_disconnect"><strong>on_disconnect</strong></a>(self, mqttc, obj, rc)</dt></dl>
<dl><dt><a name="HomieMqtt-on_message"><strong>on_message</strong></a>(self, mqttc, obj, msg)</dt></dl>
<dl><dt><a name="HomieMqtt-on_publish"><strong>on_publish</strong></a>(self, mqttc, obj, mid)</dt></dl>
<dl><dt><a name="HomieMqtt-on_subscribe"><strong>on_subscribe</strong></a>(self, mqttc, obj, mid, granted_qos)</dt></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>connected</strong></dt>
</dl>
<hr>
Methods inherited from <a href="paho.mqtt.client.html#Client">paho.mqtt.client.Client</a>:<br>
<dl><dt><a name="HomieMqtt-connect"><strong>connect</strong></a>(self, host, port<font color="#909090">=1883</font>, keepalive<font color="#909090">=60</font>, bind_address<font color="#909090">=''</font>)</dt><dd><tt>Connect to a remote broker.<br>
<br>
host is the hostname or IP address of the remote broker.<br>
port is the network port of the server host to connect to. Defaults to<br>
1883. Note that the default port for MQTT over SSL/TLS is 8883 so if you<br>
are using <a href="#HomieMqtt-tls_set">tls_set</a>() the port may need providing.<br>
keepalive: Maximum period in seconds between communications with the<br>
broker. If no other messages are being exchanged, this controls the<br>
rate at which the client will send ping messages to the broker.</tt></dd></dl>
<dl><dt><a name="HomieMqtt-connect_async"><strong>connect_async</strong></a>(self, host, port<font color="#909090">=1883</font>, keepalive<font color="#909090">=60</font>, bind_address<font color="#909090">=''</font>)</dt><dd><tt>Connect to a remote broker asynchronously. This is a non-blocking<br>
connect call that can be used with <a href="#HomieMqtt-loop_start">loop_start</a>() to provide very quick<br>
start.<br>
<br>
host is the hostname or IP address of the remote broker.<br>
port is the network port of the server host to connect to. Defaults to<br>
1883. Note that the default port for MQTT over SSL/TLS is 8883 so if you<br>
are using <a href="#HomieMqtt-tls_set">tls_set</a>() the port may need providing.<br>
keepalive: Maximum period in seconds between communications with the<br>
broker. If no other messages are being exchanged, this controls the<br>
rate at which the client will send ping messages to the broker.</tt></dd></dl>
<dl><dt><a name="HomieMqtt-connect_srv"><strong>connect_srv</strong></a>(self, domain<font color="#909090">=None</font>, keepalive<font color="#909090">=60</font>, bind_address<font color="#909090">=''</font>)</dt><dd><tt>Connect to a remote broker.<br>
<br>
domain is the DNS domain to search for SRV records; if None,<br>
try to determine local domain name.<br>
keepalive and bind_address are as for <a href="#HomieMqtt-connect">connect</a>()</tt></dd></dl>
<dl><dt><a name="HomieMqtt-disconnect"><strong>disconnect</strong></a>(self)</dt><dd><tt>Disconnect a connected client from the broker.</tt></dd></dl>
<dl><dt><a name="HomieMqtt-loop"><strong>loop</strong></a>(self, timeout<font color="#909090">=1.0</font>, max_packets<font color="#909090">=1</font>)</dt><dd><tt>Process network events.<br>
<br>
This function must be called regularly to ensure communication with the<br>
broker is carried out. It calls select() on the network socket to wait<br>
for network events. If incoming data is present it will then be<br>
processed. Outgoing commands, from e.g. <a href="#HomieMqtt-publish">publish</a>(), are normally sent<br>
immediately that their function is called, but this is not always<br>
possible. <a href="#HomieMqtt-loop">loop</a>() will also attempt to send any remaining outgoing<br>
messages, which also includes commands that are part of the flow for<br>
messages with QoS>0.<br>
<br>
timeout: The time in seconds to wait for incoming/outgoing network<br>
traffic before timing out and returning.<br>
max_packets: Not currently used.<br>
<br>
Returns MQTT_ERR_SUCCESS on success.<br>
Returns >0 on error.<br>
<br>
A ValueError will be raised if timeout < 0</tt></dd></dl>
<dl><dt><a name="HomieMqtt-loop_forever"><strong>loop_forever</strong></a>(self, timeout<font color="#909090">=1.0</font>, max_packets<font color="#909090">=1</font>, retry_first_connection<font color="#909090">=False</font>)</dt><dd><tt>This function call <a href="#HomieMqtt-loop">loop</a>() for you in an infinite blocking loop. It<br>
is useful for the case where you only want to run the MQTT client loop<br>
in your program.<br>
<br>
<a href="#HomieMqtt-loop_forever">loop_forever</a>() will handle reconnecting for you. If you call<br>
<a href="#HomieMqtt-disconnect">disconnect</a>() in a callback it will return.<br>
<br>
<br>
timeout: The time in seconds to wait for incoming/outgoing network<br>
traffic before timing out and returning.<br>
max_packets: Not currently used.<br>
retry_first_connection: Should the first connection attempt be retried on failure.<br>
<br>
Raises socket.error on first connection failures unless retry_first_connection=True</tt></dd></dl>
<dl><dt><a name="HomieMqtt-loop_misc"><strong>loop_misc</strong></a>(self)</dt><dd><tt>Process miscellaneous network events. Use in place of calling <a href="#HomieMqtt-loop">loop</a>() if you<br>
wish to call select() or equivalent on.<br>
<br>
Do not use if you are using the threaded interface <a href="#HomieMqtt-loop_start">loop_start</a>().</tt></dd></dl>
<dl><dt><a name="HomieMqtt-loop_read"><strong>loop_read</strong></a>(self, max_packets<font color="#909090">=1</font>)</dt><dd><tt>Process read network events. Use in place of calling <a href="#HomieMqtt-loop">loop</a>() if you<br>
wish to handle your client reads as part of your own application.<br>
<br>
Use <a href="#HomieMqtt-socket">socket</a>() to obtain the client socket to call select() or equivalent<br>
on.<br>
<br>
Do not use if you are using the threaded interface <a href="#HomieMqtt-loop_start">loop_start</a>().</tt></dd></dl>
<dl><dt><a name="HomieMqtt-loop_start"><strong>loop_start</strong></a>(self)</dt><dd><tt>This is part of the threaded client interface. Call this once to<br>
start a new thread to process network traffic. This provides an<br>
alternative to repeatedly calling <a href="#HomieMqtt-loop">loop</a>() yourself.</tt></dd></dl>
<dl><dt><a name="HomieMqtt-loop_stop"><strong>loop_stop</strong></a>(self, force<font color="#909090">=False</font>)</dt><dd><tt>This is part of the threaded client interface. Call this once to<br>
stop the network thread previously created with <a href="#HomieMqtt-loop_start">loop_start</a>(). This call<br>
will block until the network thread finishes.<br>
<br>
The force parameter is currently ignored.</tt></dd></dl>
<dl><dt><a name="HomieMqtt-loop_write"><strong>loop_write</strong></a>(self, max_packets<font color="#909090">=1</font>)</dt><dd><tt>Process read network events. Use in place of calling <a href="#HomieMqtt-loop">loop</a>() if you<br>
wish to handle your client reads as part of your own application.<br>
<br>
Use <a href="#HomieMqtt-socket">socket</a>() to obtain the client socket to call select() or equivalent<br>
on.<br>
<br>
Use <a href="#HomieMqtt-want_write">want_write</a>() to determine if there is data waiting to be written.<br>
<br>
Do not use if you are using the threaded interface <a href="#HomieMqtt-loop_start">loop_start</a>().</tt></dd></dl>
<dl><dt><a name="HomieMqtt-max_inflight_messages_set"><strong>max_inflight_messages_set</strong></a>(self, inflight)</dt><dd><tt>Set the maximum number of messages with QoS>0 that can be part way<br>
through their network flow at once. Defaults to 20.</tt></dd></dl>
<dl><dt><a name="HomieMqtt-max_queued_messages_set"><strong>max_queued_messages_set</strong></a>(self, queue_size)</dt><dd><tt>Set the maximum number of messages in the outgoing message queue.<br>
0 means unlimited.</tt></dd></dl>
<dl><dt><a name="HomieMqtt-message_callback_add"><strong>message_callback_add</strong></a>(self, sub, callback)</dt><dd><tt>Register a message callback for a specific topic.<br>
Messages that match 'sub' will be passed to 'callback'. Any<br>
non-matching messages will be passed to the default on_message<br>
callback.<br>
<br>
Call multiple times with different 'sub' to define multiple topic<br>
specific callbacks.<br>
<br>
Topic specific callbacks may be removed with<br>
<a href="#HomieMqtt-message_callback_remove">message_callback_remove</a>().</tt></dd></dl>
<dl><dt><a name="HomieMqtt-message_callback_remove"><strong>message_callback_remove</strong></a>(self, sub)</dt><dd><tt>Remove a message callback previously registered with<br>
<a href="#HomieMqtt-message_callback_add">message_callback_add</a>().</tt></dd></dl>
<dl><dt><a name="HomieMqtt-message_retry_set"><strong>message_retry_set</strong></a>(self, retry)</dt><dd><tt>Set the timeout in seconds before a message with QoS>0 is retried.<br>
20 seconds by default.</tt></dd></dl>
<dl><dt><a name="HomieMqtt-publish"><strong>publish</strong></a>(self, topic, payload<font color="#909090">=None</font>, qos<font color="#909090">=0</font>, retain<font color="#909090">=False</font>)</dt><dd><tt>Publish a message on a topic.<br>
<br>
This causes a message to be sent to the broker and subsequently from<br>
the broker to any clients subscribing to matching topics.<br>
<br>
topic: The topic that the message should be published on.<br>
payload: The actual message to send. If not given, or set to None a<br>
zero length message will be used. Passing an int or float will result<br>
in the payload being converted to a string representing that number. If<br>
you wish to send a true int/float, use struct.pack() to create the<br>
payload you require.<br>
qos: The quality of service level to use.<br>
retain: If set to true, the message will be set as the "last known<br>
good"/retained message for the topic.<br>
<br>
Returns a MQTTMessageInfo class, which can be used to determine whether<br>
the message has been delivered (using info.is_published()) or to block<br>
waiting for the message to be delivered (info.wait_for_publish()). The<br>
message ID and return code of the <a href="#HomieMqtt-publish">publish</a>() call can be found at<br>
info.mid and info.rc.<br>
<br>
For backwards compatibility, the MQTTMessageInfo class is iterable so<br>
the old construct of (rc, mid) = client.<a href="#HomieMqtt-publish">publish</a>(...) is still valid.<br>
<br>
rc is MQTT_ERR_SUCCESS to indicate success or MQTT_ERR_NO_CONN if the<br>
client is not currently connected. mid is the message ID for the<br>
publish request. The mid value can be used to track the publish request<br>
by checking against the mid argument in the <a href="#HomieMqtt-on_publish">on_publish</a>() callback if it<br>
is defined.<br>
<br>
A ValueError will be raised if topic is None, has zero length or is<br>
invalid (contains a wildcard), if qos is not one of 0, 1 or 2, or if<br>
the length of the payload is greater than 268435455 bytes.</tt></dd></dl>
<dl><dt><a name="HomieMqtt-reconnect"><strong>reconnect</strong></a>(self)</dt><dd><tt>Reconnect the client after a disconnect. Can only be called after<br>
<a href="#HomieMqtt-connect">connect</a>()/<a href="#HomieMqtt-connect_async">connect_async</a>().</tt></dd></dl>
<dl><dt><a name="HomieMqtt-reinitialise"><strong>reinitialise</strong></a>(self, client_id<font color="#909090">=''</font>, clean_session<font color="#909090">=True</font>, userdata<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="HomieMqtt-socket"><strong>socket</strong></a>(self)</dt><dd><tt>Return the socket or ssl object for this client.</tt></dd></dl>
<dl><dt><a name="HomieMqtt-subscribe"><strong>subscribe</strong></a>(self, topic, qos<font color="#909090">=0</font>)</dt><dd><tt>Subscribe the client to one or more topics.<br>
<br>
This function may be called in three different ways:<br>
<br>
Simple string and integer<br>
-------------------------<br>
e.g. <a href="#HomieMqtt-subscribe">subscribe</a>("my/topic", 2)<br>
<br>
topic: A string specifying the subscription topic to subscribe to.<br>
qos: The desired quality of service level for the subscription.<br>
Defaults to 0.<br>
<br>
String and integer tuple<br>
------------------------<br>
e.g. <a href="#HomieMqtt-subscribe">subscribe</a>(("my/topic", 1))<br>
<br>
topic: A tuple of (topic, qos). Both topic and qos must be present in<br>
the tuple.<br>
qos: Not used.<br>
<br>
List of string and integer tuples<br>
------------------------<br>
e.g. <a href="#HomieMqtt-subscribe">subscribe</a>([("my/topic", 0), ("another/topic", 2)])<br>
<br>
This allows multiple topic subscriptions in a single SUBSCRIPTION<br>
command, which is more efficient than using multiple calls to<br>
<a href="#HomieMqtt-subscribe">subscribe</a>().<br>
<br>
topic: A list of tuple of format (topic, qos). Both topic and qos must<br>
be present in all of the tuples.<br>
qos: Not used.<br>
<br>
The function returns a tuple (result, mid), where result is<br>
MQTT_ERR_SUCCESS to indicate success or (MQTT_ERR_NO_CONN, None) if the<br>
client is not currently connected. mid is the message ID for the<br>
subscribe request. The mid value can be used to track the subscribe<br>
request by checking against the mid argument in the <a href="#HomieMqtt-on_subscribe">on_subscribe</a>()<br>
callback if it is defined.<br>
<br>
Raises a ValueError if qos is not 0, 1 or 2, or if topic is None or has<br>
zero string length, or if topic is not a string, tuple or list.</tt></dd></dl>
<dl><dt><a name="HomieMqtt-tls_insecure_set"><strong>tls_insecure_set</strong></a>(self, value)</dt><dd><tt>Configure verification of the server hostname in the server certificate.<br>
<br>
If value is set to true, it is impossible to guarantee that the host<br>
you are connecting to is not impersonating your server. This can be<br>
useful in initial server testing, but makes it possible for a malicious<br>
third party to impersonate your server through DNS spoofing, for<br>
example.<br>
<br>
Do not use this function in a real system. Setting value to true means<br>
there is no point using encryption.<br>
<br>
Must be called before <a href="#HomieMqtt-connect">connect</a>().</tt></dd></dl>
<dl><dt><a name="HomieMqtt-tls_set"><strong>tls_set</strong></a>(self, ca_certs, certfile<font color="#909090">=None</font>, keyfile<font color="#909090">=None</font>, cert_reqs<font color="#909090">=2</font>, tls_version<font color="#909090">=3</font>, ciphers<font color="#909090">=None</font>)</dt><dd><tt>Configure network encryption and authentication options. Enables SSL/TLS support.<br>
<br>
ca_certs : a string path to the Certificate Authority certificate files<br>
that are to be treated as trusted by this client. If this is the only<br>
option given then the client will operate in a similar manner to a web<br>
browser. That is to say it will require the broker to have a<br>
certificate signed by the Certificate Authorities in ca_certs and will<br>
communicate using TLS v1, but will not attempt any form of<br>
authentication. This provides basic network encryption but may not be<br>
sufficient depending on how the broker is configured.<br>
<br>
certfile and keyfile are strings pointing to the PEM encoded client<br>
certificate and private keys respectively. If these arguments are not<br>
None then they will be used as client information for TLS based<br>
authentication. Support for this feature is broker dependent. Note<br>
that if either of these files in encrypted and needs a password to<br>
decrypt it, Python will ask for the password at the command line. It is<br>
not currently possible to define a callback to provide the password.<br>
<br>
cert_reqs allows the certificate requirements that the client imposes<br>
on the broker to be changed. By default this is ssl.CERT_REQUIRED,<br>
which means that the broker must provide a certificate. See the ssl<br>
pydoc for more information on this parameter.<br>
<br>
tls_version allows the version of the SSL/TLS protocol used to be<br>
specified. By default TLS v1 is used. Previous versions (all versions<br>
beginning with SSL) are possible but not recommended due to possible<br>
security problems.<br>
<br>
ciphers is a string specifying which encryption ciphers are allowable<br>
for this connection, or None to use the defaults. See the ssl pydoc for<br>
more information.<br>
<br>
Must be called before <a href="#HomieMqtt-connect">connect</a>() or <a href="#HomieMqtt-connect_async">connect_async</a>().</tt></dd></dl>
<dl><dt><a name="HomieMqtt-unsubscribe"><strong>unsubscribe</strong></a>(self, topic)</dt><dd><tt>Unsubscribe the client from one or more topics.<br>
<br>
topic: A single string, or list of strings that are the subscription<br>
topics to unsubscribe from.<br>
<br>
Returns a tuple (result, mid), where result is MQTT_ERR_SUCCESS<br>
to indicate success or (MQTT_ERR_NO_CONN, None) if the client is not<br>
currently connected.<br>
mid is the message ID for the unsubscribe request. The mid value can be<br>
used to track the unsubscribe request by checking against the mid<br>
argument in the <a href="#HomieMqtt-on_unsubscribe">on_unsubscribe</a>() callback if it is defined.<br>
<br>
Raises a ValueError if topic is None or has zero string length, or is<br>
not a string or list.</tt></dd></dl>
<dl><dt><a name="HomieMqtt-user_data_set"><strong>user_data_set</strong></a>(self, userdata)</dt><dd><tt>Set the user data variable passed to callbacks. May be any data type.</tt></dd></dl>
<dl><dt><a name="HomieMqtt-username_pw_set"><strong>username_pw_set</strong></a>(self, username, password<font color="#909090">=None</font>)</dt><dd><tt>Set a username and optionally a password for broker authentication.<br>
<br>
Must be called before <a href="#HomieMqtt-connect">connect</a>() to have any effect.<br>
Requires a broker that supports MQTT v3.1.<br>
<br>
username: The username to authenticate with. Need have no relationship to the client id.<br>
password: The password to authenticate with. Optional, set to None if not required.</tt></dd></dl>
<dl><dt><a name="HomieMqtt-want_write"><strong>want_write</strong></a>(self)</dt><dd><tt>Call to determine if there is network data waiting to be written.<br>
Useful if you are calling select() yourself rather than using <a href="#HomieMqtt-loop">loop</a>().</tt></dd></dl>
<dl><dt><a name="HomieMqtt-will_clear"><strong>will_clear</strong></a>(self)</dt><dd><tt>Removes a will that was previously configured with <a href="#HomieMqtt-will_set">will_set</a>().<br>
<br>
Must be called before <a href="#HomieMqtt-connect">connect</a>() to have any effect.</tt></dd></dl>
<dl><dt><a name="HomieMqtt-will_set"><strong>will_set</strong></a>(self, topic, payload<font color="#909090">=None</font>, qos<font color="#909090">=0</font>, retain<font color="#909090">=False</font>)</dt><dd><tt>Set a Will to be sent by the broker in case the client disconnects unexpectedly.<br>
<br>
This must be called before <a href="#HomieMqtt-connect">connect</a>() to have any effect.<br>
<br>
topic: The topic that the will message should be published on.<br>
payload: The message to send as a will. If not given, or set to None a<br>
zero length message will be used as the will. Passing an int or float<br>
will result in the payload being converted to a string representing<br>
that number. If you wish to send a true int/float, use struct.pack() to<br>
create the payload you require.<br>
qos: The quality of service level to use for the will.<br>
retain: If set to true, the will message will be set as the "last known<br>
good"/retained message for the topic.<br>
<br>
Raises a ValueError if qos is not 0, 1 or 2, or if topic is None or has<br>
zero string length.</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="paho.mqtt.client.html#Client">paho.mqtt.client.Client</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<dl><dt><strong>on_log</strong></dt>
<dd><tt>If implemented, called when the client has log information.<br>
Defined to allow debugging.</tt></dd>
</dl>
<dl><dt><strong>on_unsubscribe</strong></dt>
<dd><tt>If implemented, called when the broker responds to an unsubscribe<br>
request.</tt></dd>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-main"><strong>main</strong></a>()</dt></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>logger</strong> = <logging.Logger object></td></tr></table>
</body></html>