Commit 6a613c95 authored by Gigadoc 2's avatar Gigadoc 2

emit_cmd

parent 3b387f7d
......@@ -98,6 +98,12 @@ class Eins:
if self._connected:
self._online_register_command(command)
def emit_cmd(self, cmd_name, **data):
self._mqttc.publish(topic = "edi/cmd/{}".format(cmd_name),
payload = json.dumps(data),
qos = self._pub_qos)
#TODO: on_publish
def _online_register_command(self, command):
"""Internal runtime command registration function.
......
......@@ -16,6 +16,7 @@ def on_connect():
@eins.handle_cmd
def test_running():
print("Test running called!")
eins.on_connect = on_connect
@eins.handle_cmd("print")
def cmd_print(a):
......@@ -41,6 +42,9 @@ def ètoile():
def brøther():
print("LÂMP")
eins.on_connect = on_connect
@eins.handle_cmd()
def reflector(**kwargs):
del kwargs['mqtt_topic']
eins.emit_cmd("reflector-target", **kwargs)
eins.run()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment