Client for Mewa server
Project description
# pymewa
## About
This is Python library which simplifies connection to the [Channel Server](https://github.com/AnthillTech/mewa).
## Requirements
* [WebSocket client](https://github.com/liris/websocket-client)
## Instalation
```bash
pip install mewa
```
## Sample usage pattern
```python
connection = Connection("ws://mewa.cc/ws")
def onConnected():
connection.getDevices()
connection.sendEvent("serviceA.event2", "78")
connection.sendMessage("device66", "serviceA.level", "34")
def onEvent(fromDevice, eventId, params):
print("received event %s from %s with params %s" % (fromDevice, eventId, params))
def onMessage(fromDevice, eventId, params):
print("received message %s from %s with params %s" % (fromDevice, eventId, params))
def onDevicesEvent(devices):
print("Found devices:")
print(devices)
def onPropertyChanged(device, propertyName, value):
print("Property %s on device %s was changed to %s" % (device, propertyName, value))
if __name__ == "__main__":
connection.onConnected = onConnected
connection.onEvent = onEvent
connection.onMessage = onMessage
connection.onDevicesEvent = onDevicesEvent
connection.connect("test", "python", "pass")
```
## Redistributing
This code is distributed under BSD3 License. It may be freely redistributed, subject to the provisions of this license.
## About
This is Python library which simplifies connection to the [Channel Server](https://github.com/AnthillTech/mewa).
## Requirements
* [WebSocket client](https://github.com/liris/websocket-client)
## Instalation
```bash
pip install mewa
```
## Sample usage pattern
```python
connection = Connection("ws://mewa.cc/ws")
def onConnected():
connection.getDevices()
connection.sendEvent("serviceA.event2", "78")
connection.sendMessage("device66", "serviceA.level", "34")
def onEvent(fromDevice, eventId, params):
print("received event %s from %s with params %s" % (fromDevice, eventId, params))
def onMessage(fromDevice, eventId, params):
print("received message %s from %s with params %s" % (fromDevice, eventId, params))
def onDevicesEvent(devices):
print("Found devices:")
print(devices)
def onPropertyChanged(device, propertyName, value):
print("Property %s on device %s was changed to %s" % (device, propertyName, value))
if __name__ == "__main__":
connection.onConnected = onConnected
connection.onEvent = onEvent
connection.onMessage = onMessage
connection.onDevicesEvent = onDevicesEvent
connection.connect("test", "python", "pass")
```
## Redistributing
This code is distributed under BSD3 License. It may be freely redistributed, subject to the provisions of this license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mewa-0.4.tar.gz
(2.2 kB
view details)
Built Distribution
mewa-0.4.linux-i686.tar.gz
(3.9 kB
view details)
File details
Details for the file mewa-0.4.tar.gz
.
File metadata
- Download URL: mewa-0.4.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | be879851921fa62b7d0891401c9c34b1b24317812c2afc6a6187033bd36b9338 |
|
MD5 | 7fceabe82afe3aeb49f7688baf2c1a19 |
|
BLAKE2b-256 | 72f47df3cc6b45e9ffd197d9eb02be2b72c6a1340575c214d517b0a6e61d319e |
File details
Details for the file mewa-0.4.linux-i686.tar.gz
.
File metadata
- Download URL: mewa-0.4.linux-i686.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 444cd60bb62dd645b36f384a9e33dcaca8f0091818067425b09ce25a18b134d7 |
|
MD5 | ba06eadfb6b7f5ed1c32a3e784a7a7a9 |
|
BLAKE2b-256 | daba21b82cff3a569ff035f94f9c6e615799ae8108b03f03fb0979473ff5456b |