Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify readme about connection callbacks #187

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ GATEWAY = mysensors.SerialGateway('/dev/ttyACM0', event)
GATEWAY.start()
```

In the above example PyMysensors will call "event" whenever a node in the Mysensors network has been updated. The message passed to the callback handler has the following data:
In the above example pymysensors will call "event" whenever a node in the Mysensors network has been updated. The message passed to the callback handler has the following data:

```
Message
Expand Down Expand Up @@ -153,6 +153,10 @@ instance. The connection lost callback should also accept a second parameter
for possible connection error exception argument. If connection was lost
without error, eg when disconnecting, the error argument will be `None`.

**NOTE:**
The MQTT gateway doesn't support these callbacks since the connection to the
MQTT broker is handled outside of pymysensors.

```py
def conn_made(gateway):
"""React when the connection is made to the gateway device."""
Expand All @@ -167,6 +171,8 @@ def conn_lost(gateway, error):
GATEWAY.on_conn_lost = conn_lost
```



## Async gateway
The serial, TCP and MQTT gateways now also have versions that support asyncio. Use the
`AsyncSerialGateway` class, `AsyncTCPGateway` class or `AsyncMQTTGateway` class to make a gateway that
Expand Down