mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 21:27:49 +02:00
Add driver app
This commit is contained in:
35
dcc/driver/connector.py
Normal file
35
dcc/driver/connector.py
Normal file
@@ -0,0 +1,35 @@
|
||||
class Connector:
|
||||
|
||||
@classmethod
|
||||
def __mqtt_pub(self, message):
|
||||
# to be encoded
|
||||
print(message)
|
||||
return True
|
||||
|
||||
def passthrough(self, address, data):
|
||||
self.__mqtt_pub(data)
|
||||
|
||||
def ops(self, address, data, function=False):
|
||||
if function:
|
||||
message = "<F {0} {1} {2}>".format(address, data['function'],
|
||||
data['state'])
|
||||
else:
|
||||
message = "<t 1 {0} {1} {2}>".format(address, data['speed'],
|
||||
data['direction'])
|
||||
self.__mqtt_pub(message)
|
||||
return True
|
||||
|
||||
def infra(self, data):
|
||||
power = data['power']
|
||||
if "track" in data:
|
||||
track = " {}".forma(data['track'].upper())
|
||||
else:
|
||||
track = ""
|
||||
|
||||
if power:
|
||||
self.__mqtt_pub('<1{}>'.format(track))
|
||||
else:
|
||||
self.__mqtt_pub('<0{}>'.format(track))
|
||||
|
||||
def emergency(self):
|
||||
self.__mqtt_pub('<!>')
|
Reference in New Issue
Block a user