Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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