How to summon Prometheus, god of fire, using Mycroft and a Raspberry Pi
According to myth, the titan Prometheus stole fire from the gods and gave it to humanity. But for whom, specifically, did he steal it?
How to command a Titan of your own
Things you'll need:
- a gas stove that can be controlled with a relay
- a raspbery pi with a relay
- a Mycroft voice assistant (you could potentially install this on the same Pi as the relay, or even use your desktop)
I'm going to explain this more conceptually than with cut & paste instructions, as I don't think any body is going to replicate this project exactly and I did the Node-Red parts quite some time ago. If you have any questions, please feel free to ask.
The stove controller
The stove controller is a Raspberry Pi 3A+ with a relay HAT, running Node-Red. I'm using the now-discontinued Pimoroni Automation pHAT. It's has protection and screw terminals, making it easy to wire up to the stove's thermostat control. I also have a temperature sensor connected to this board, allowing me to turn the stove on and off automatically, when Prometheus has the day off.
I set up Node-Red following these instructions. Once you have Node-Red up and running, you want to lay out these nodes:
The first node is an HTTP GET request with the path stove/on. Coming off that node, the top branch turns the stove on and the bottom branch replies to the HTTP request. In the top branch, the 'set on' node sets the payload to 1. The next node, labeled 'Stove', is a switch node, which remembers its state. That node in turn sets pin 36 on the Pi's gpio, which is where the relay is connected. The bottom branch simply returns the word 'On'.
So in your web browser, when you go to the address http://yourhostname:1880/stove/on the stove is turned on and the text 'On' is returned in your browser.
Setting up Mycroft was a lot easier than I expected. I used a Pi 4, Sony PlayStation PS3 Eye, and an analog speaker connected to the audio jack. Then I downloaded the PiCroft image and followed the onscreen instructions. That's all it takes to get a functioning Mycroft assistant. Then I created a new skill and wake word.
Creating a skill
Connect to the Mycroft via ssh and press Control-C to exit mycroft-cli-client. Run the command `msk create`. You'll received the following prompts:
Enter a short unique skill name (ie. "siren alarm" or "pizza orderer"): bring me fire
Enter some example phrases to trigger your skill: bring me fire
Enter what your skill should say to respond: .
(I didn't want a response, but if you leave this blank it responds with the task name, so I put a period in)
The rest of the settings don't really matter. When you're done, you'll have a new skill in /opt/mycroft/skills/bring-me-fire-skill
Its contents will look like this:
from mycroft import MycroftSkill, intent_file_handler class BringMeFire(MycroftSkill): def __init__(self): MycroftSkill.__init__(self) @intent_file_handler('fire.me.bring.intent') def handle_fire_me_bring(self, message): self.speak_dialog('fire.me.bring') def create_skill(): return BringMeFire()
And all you need to do is add two lines:
from mycroft import MycroftSkill, intent_file_handler import requests class BringMeFire(MycroftSkill): def __init__(self): MycroftSkill.__init__(self) @intent_file_handler('fire.me.bring.intent') def handle_fire_me_bring(self, message): requests.get('http://yourhostname:1880/stove/on') self.speak_dialog('fire.me.bring') def create_skill(): return BringMeFire()
import requests imports the HTTP library.
requests.get('http://yourhostname:1880/stove/on') makes the HTTP request when you say "Bring me fire"
Setting up a Wake Word
I used PocketSphinx to create the wake word. The default listener, Precise, is better, but harder to configure. First, configure ~/.mycroft/mycroft.conf to use the new wake word:
"phonemes": "P R AH M IY TH IY AH S .",
Then run `mycroft-config reload` and set the listener to PocketSphinx with your voice: "Hey Mycroft, set the listener to PocketSphinx".
I have the treshold set a lot lower than Mycroft's example, because 'prometheus' doesn't seem to work very well as a wake word. If you're using this just for the occasional parlor trick, you could even set the wake word to prom (P R AA M .). I usually keep mine on 'hey mycroft' because I use it for other stuff, and I want it to work reliably. If anybody tries doing prometheus in Precise, I'd really like to hear how it goes for you.
Say "Prometheus, bring me fire," and he will.
Special thanks to Prometheus for his dedication to this project.