mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 13:17:50 +02:00
36 lines
996 B
Python
36 lines
996 B
Python
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('<!>')
|