Custom iot:1 protocol
Project description
#IOT:1
My custom protocol for communication between devices at home. It uses UPD and broadcast. Messages are json strings.
## Message body:
{
"protocol": "iot:1",
"node": "Rpi-lcd-1",
"chip_id": "RpiB",
"event": "lcd.content",
"parameters: [
"content": "-(=^.^)"
],
"response": '',
"targets": [
"nodemcu-lcd-40x4"
]
}
protocol: defines name, currently iot:1
node: friendly node name like light-room-big or screen-one-kitchen
chip_id: a unique device id
event: event name like light.on or display
parameters: array of parameters. like rows to display
response: used when responding to request, ie returning toilet state
targets: message targets node with this names. special keyword ALL for all nodes in network
## set node name or/and chip_id
Message.chip_id = 'miau'
Message.node_name = 'miau_too'
### Message()
Create new instance. It is autamatically filled with chip_id and node_name if not set
### Message(string_message)
Creates message and fills with received data
input = """{"protocol": "iot:1", "node": "node_name", "chip_id": "aaa", "event": "channel.on", "parameters": {"channel": 0}, "response": "", "targets": ["node-north"]}"""
msg = factory.MessageFactory.create(input)
## functions
### set(dictionary)
msg = message.Message()
msg.set({
'event': 'event.test',
'parameters': {
'is_x': '1'
}
})
Fills message with params.
### send message
s.sendto(bytes(msg), address)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for iot_message-1.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92cccbcbfb7c8cab1fc31c7c61151b9737856c66a4c00b2865b7068af980d7cf |
|
MD5 | e84a0dcf00ee7ee474b9cc342e53250b |
|
BLAKE2b-256 | db3f08e202babe5ab2d7dae00e174bb79e510e9646673258f2e6fc5148f00bbb |