Skip to content

Instantly share code, notes, and snippets.

@harthur
Last active January 6, 2020 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harthur/7063cac21b3d2aaa58ebfbdc1becf820 to your computer and use it in GitHub Desktop.
Save harthur/7063cac21b3d2aaa58ebfbdc1becf820 to your computer and use it in GitHub Desktop.
from hermes_python.hermes import Hermes
from display import SenseDisplay
from celestial import Celestial
from strings import CelestialStrings
MQTT_IP_ADDR = "localhost"
MQTT_PORT = 1883
MQTT_ADDR = "{}:{}".format(MQTT_IP_ADDR, str(MQTT_PORT))
class CelestialApp:
def __init__(self):
self.display = SenseDisplay()
self.celestial = Celestial()
self.start_listening()
def moon_phase_callback(self, hermes, intent_message):
phase_info = self.celestial.get_moon_phase()
self.display.display_moon_phase(phase_info)
msg = CelestialStrings.get_moon_phase_message(phase_info)
hermes.publish_end_session(intent_message.session_id, msg)
def start_listening(self):
with Hermes(MQTT_ADDR) as h:
h.subscribe_intent(
"harthur:MoonPhase", self.moon_phase_callback
).loop_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment