Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Commit

Permalink
Added "IP address" action that says Pi's IP
Browse files Browse the repository at this point in the history
  • Loading branch information
t1m0thyj committed Oct 16, 2017
1 parent 13e59cc commit 885b35f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/assistant_library_with_local_commands_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def reboot_pi():
subprocess.call('sudo reboot', shell=True)


def say_ip():
ip_address = subprocess.check_output("hostname -I | cut -d' ' -f1", shell=True).decode("utf8")
aiy.audio.say("My IP address is " + ip_address)


def process_event(assistant, event):
status_ui = aiy.voicehat.get_status_ui()
if event.type == EventType.ON_START_FINISHED:
Expand All @@ -63,12 +68,15 @@ def process_event(assistant, event):
elif event.type == EventType.ON_RECOGNIZING_SPEECH_FINISHED and event.args:
text = event.args['text']
print('You said:', text)
if text == 'power off':
if text == 'raspberry power off':
assistant.stop_conversation()
power_off_pi()
elif text == 'reboot':
elif text == 'raspberry reboot':
assistant.stop_conversation()
reboot_pi()
elif text == 'IP address':
assistant.stop_conversation()
say_ip()

elif event.type == EventType.ON_END_OF_UTTERANCE:
status_ui.status('thinking')
Expand Down

0 comments on commit 885b35f

Please sign in to comment.