I recently built a Messenger Bot. This is the third post in a series describing how I built it and what I learned.
My first encounter with my solar power system’s API was not with Messenger but with Alexa. Alexa is the voice recognition and processing system behind the Amazon Echo.
Starting with Alexa
Shortly after I setup my Alexa, I was geeking out on things to do with it. After setting up a wifi lightbulb, I started thinking about other household tasks for Alexa. This was right around the time of the $300 power bill. Putting two and two together, I figured Alexa could help me get smarter about my solar power system.
The first Google search result for “Enphase Alexa” was a winner. I found a github project that did exactly this, except it’s pull not push. It wouldn’t notify me. But it would let me see examples of working with my Enphase solar system’s API. I’m fascinated by what Amazon is doing with Alexa and am always looking for new use cases for my Echo. This was a turnkey opportunity.
It was straightforward to setup. I had to:
- Configure an AWS Lamba instance.
- Create an Alexa skill.
- Provision a developer account with Enphase
- Enable API access on my solar system.
The human element
I spent around four hours total to get this going. Our landlord owns our rooftop solar power system, which we are very lucky to have! But we had to work together to figure out how to enable system-level API access. The Enphase help center didn’t have clear instructions on how to do this – I provisioned a token and didn’t realize until hours later that the system owner also has to flip a switch.
The technical part
I’m also pretty rusty on tools like vim, bash, and python. But it’s like riding a bike. It’s amazing how some tools are the same as they’ve been for decades but others turnover so quickly.
AWS Lambda is a pretty awesome service. It lets you run stateless python code, taking an input and providing outputs. No data is stored anywhere. The way it works: Lambda receives the processed query from Alexa, pulls data from the solar system’s API, and then returns it to Alexa who speaks the answer back to me through my echo device. All this happens in a matter of milliseconds. I already have an AWS account from a backup S3 storage system, so there was no friction to get this going.
The Enphase solar system’s API is straightforward. Their documentation is okay – I got stuck on figuring out that I had to replace the systemID with my own. They also have a testing endpoint where you can query a fake solar system if you don’t have a real one to query.
Setting up the Alexa skill was easy, just copy/pasting node.js code and linking it to my Lambda instance. Most of this is around recognizing and mapping semantics. I had to redo the Lambda setup a few times as it would only work from US-East and not other AWS datacenter locations.
Next step: Push notifications
This was a big step forward – having a talking speaker ask my solar system how much power it’s producing in realtime. Or how much I produced in January. Ten years ago, I never thought I’d have solar power. I definitely didn’t think Amazon would produce a hockey puck sized conversation for $49.99 (Echo Dot).
It works great when I’m home, but I need something I can access from anywhere. I also need something that would push notify me.
Next post I’ll share how I used this experience to get started with Messenger