From 0d35be208db8c509c673cdaff9755d717399c57f Mon Sep 17 00:00:00 2001 From: Leon Wright Date: Sun, 24 Jan 2021 11:12:28 +0800 Subject: [PATCH 1/2] adds initial 'Send Leon a hug!' concept --- lib/aiko/services.py | 4 +++- lib/aiko/system_ui.py | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/aiko/services.py b/lib/aiko/services.py index 8aace2f..423a9eb 100644 --- a/lib/aiko/services.py +++ b/lib/aiko/services.py @@ -30,6 +30,7 @@ topic_in = None topic_log = None topic_out = None +topic_hugs = None topic_path = None topic_service = None topic_state = None @@ -83,7 +84,7 @@ def on_services_message(topic, payload_in): def initialise(settings=configuration.services.settings): global protocol, username, topic_in, topic_log - global topic_path, topic_out, topic_service, topic_state + global topic_path, topic_out, topic_service, topic_state, topic_hugs hostname, pid, protocol, username = get_configuration(settings) mqtt_host, mqtt_port, namespace = bootstrap() @@ -93,6 +94,7 @@ def initialise(settings=configuration.services.settings): topic_out = topic_path + "/out" topic_service = namespace + "/manager/service" topic_state = topic_path + "/state" + topic_hugs = topic_path + "/hugs" settings = configuration.mqtt.settings settings["host"] = mqtt_host diff --git a/lib/aiko/system_ui.py b/lib/aiko/system_ui.py index 597c964..39689ab 100644 --- a/lib/aiko/system_ui.py +++ b/lib/aiko/system_ui.py @@ -9,6 +9,8 @@ import aiko.button from aiko.common import map_value import aiko.oled as oled +import aiko.mqtt as mqtt +import aiko.services as services import aiko.upgrade import configuration.system_ui @@ -91,11 +93,13 @@ def console_log_feature(): oled.oleds_show_log() oled.oleds_system_use(False) -hugs_message = [ "", "hey Leon,", "Let's figure", "something out ?", "... andyg :)" ] +hugs_message = [ "", "hey Andy,", "I figured", "something out !", "... techman83 :)" ] def hugs_feature(): oled.oleds_system_use(True) oled.oleds_show_log(hugs_message) + # TODO: Make recipient configurable? + mqtt.client.publish(services.topic_hugs, "Leon") oled.oleds_system_use(False) features = [ From 9a0be3e5be5a31b8d0ac89e819dde942166661ff Mon Sep 17 00:00:00 2001 From: Leon Wright Date: Sun, 24 Jan 2021 11:36:00 +0800 Subject: [PATCH 2/2] Update hugs feature to use standard 'out' topic --- lib/aiko/services.py | 4 +--- lib/aiko/system_ui.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/aiko/services.py b/lib/aiko/services.py index 423a9eb..8aace2f 100644 --- a/lib/aiko/services.py +++ b/lib/aiko/services.py @@ -30,7 +30,6 @@ topic_in = None topic_log = None topic_out = None -topic_hugs = None topic_path = None topic_service = None topic_state = None @@ -84,7 +83,7 @@ def on_services_message(topic, payload_in): def initialise(settings=configuration.services.settings): global protocol, username, topic_in, topic_log - global topic_path, topic_out, topic_service, topic_state, topic_hugs + global topic_path, topic_out, topic_service, topic_state hostname, pid, protocol, username = get_configuration(settings) mqtt_host, mqtt_port, namespace = bootstrap() @@ -94,7 +93,6 @@ def initialise(settings=configuration.services.settings): topic_out = topic_path + "/out" topic_service = namespace + "/manager/service" topic_state = topic_path + "/state" - topic_hugs = topic_path + "/hugs" settings = configuration.mqtt.settings settings["host"] = mqtt_host diff --git a/lib/aiko/system_ui.py b/lib/aiko/system_ui.py index 39689ab..b08279c 100644 --- a/lib/aiko/system_ui.py +++ b/lib/aiko/system_ui.py @@ -99,7 +99,7 @@ def hugs_feature(): oled.oleds_system_use(True) oled.oleds_show_log(hugs_message) # TODO: Make recipient configurable? - mqtt.client.publish(services.topic_hugs, "Leon") + mqtt.client.publish(services.topic_out + "/hugs", "Leon") oled.oleds_system_use(False) features = [