Even with solar panels on your roof, it's possible that your home is still being powered by fossil fuels.
Climate innovator and Python developer Anna Schneider is trying to change that.
At her company Wattime, consumers can source the cleanest energy available on the grid.
In this episode of Talk Python to Me, I talk to Anna about how Python powers Wattime,
some popular open source projects focused on renewable energy,
and a few other Python-based renewable energy startups.
This is Talk Python to Me, episode 76, recorded Monday, September 12, 2016.
Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.
This is your host, Michael Kennedy. Follow me on Twitter where I'm @mkennedy.
Keep up with the show and listen to past episodes at talkpython.fm, and follow the show on Twitter via at Talk Python.
This episode is brought to you by Hired and SnapCI.
Thank them for supporting the show on Twitter via at Hired underscore HQ and at Snap underscore CI.
Anna, welcome to the show.
Hi, Michael. Thanks for having me.
Yeah, I'm really excited to have you on the show today and to talk about what you've been up to in Python
and fighting climate change and working on renewable energy and all that good stuff.
It's going to be great.
Yeah, I'm excited.
Yeah, it's very exciting.
But before we get to that story, let's just start at the beginning.
Like, how did you get into programming in the first place?
Yeah, so I was a scientist for a long time.
That's how I thought of myself.
But I used code to do science.
So in undergrad, I was working on protein folding and protein structure research.
And so I would, that was my very first exposure to programming was doing some really simple bash stuff just to access the data that we were working with.
And it progressed from there during grad school.
Was that like the folding at home types data or was that other data?
It was data that I collected from its method called NMR for figuring out what proteins look like.
Okay, cool.
Yeah.
So you started programming that way, which I think a lot of people get into programming if they don't just go straight down the computer science track.
They get into programming because they needed it to try to do what they were actually doing.
And, you know, a lot of times I think people are like, wait, this is actually really more fun than the actual problem I started to solve.
Exactly.
That was how it worked for me, too.
So I had thought about when I was deciding what to do during grad school, I did my PhD in biophysics.
And so I was like, do I want to work in a laser lab?
Do I want to work in a protein structure lab?
Or do I want to study those problems but use code to do it instead of fancy equipment?
And I ended up realizing that I'm just a lot more creative when I'm writing code than when I'm working with physical objects in the real world.
And so that ended up being how I did my PhD.
Cool.
That makes sense to me.
And so how did you get into Python then?
So that was during my PhD when I started using Python.
So I had been writing these big C++ simulations for how the molecules inside plants that do photosynthesis, how they move around.
But then I needed something to analyze that data.
And Python was way nicer for that.
So I wrote a bunch of really crappy C++ code and then started writing some actually kind of okay Python.
Oh, that's excellent.
So you were studying how plants basically did photosynthesis and things like that?
Yeah.
So the part of a plant that acts like a solar panel, I was studying the molecules inside that and how they move around to make plants more or less efficient.
Interesting.
So how did you go from studying nature photosynthesis to what we're trying to do with solar energy?
Yeah, yeah.
So I got into that project because I knew that I wanted to work on energy software and energy data long term.
So at the end of undergrad, all my friends were either like pre-med or going to Google or something like that.
And either of those paths felt right to me.
So I was like, what do I care about as much as my friends care about medicine?
And energy and sustainability ended up being the answer for me.
So I deferred going to grad school and took a year to work at a tiny energy efficiency nonprofit and then at a place that does climate modeling for renewable energy projects.
And so I've sort of been on this trajectory for a long time.
Yeah, yeah.
That's really cool.
So did you do programming at those places or what kind of work do you do at like a climate nonprofit?
At the climate modeling for renewable energy place, I was doing programming and data analysis there.
So I worked with a bunch of atmospheric science PhDs and they would run big climate models when a wind developer would come to us and say like, I own this hill where should I put the turbines?
And so we would figure out what the typical wind patterns are in that place and what's the most efficient way to build new turbines.
So I learned Ruby there.
Oh, okay.
Interesting.
Yeah.
Like an optimization problem more or less, huh?
Yeah.
It's cool.
I think, you know, a lot of us care about climate change and we think as programmers and technologists, there must be something we can do.
I think certainly as programmers, we are in a better place to help in some way than a lot of the general public, right?
We could actually write some of the technology that makes these things go.
But at the same time, it also feels very much like this kind of stuff is the realm of giant companies that have deep seated interests that are not necessarily good for the world, but are good for them.
Yep.
Yeah.
And so you shared an article with me that's pretty interesting titled, What Can a Technologist Do About Climate Change?
A Personal View?
And that's at worrydream.com slash climate change.
Yeah.
So this was something put together by a guy called Brett Victor.
And the idea is just exactly what he said going through and saying there's so many places within our global energy system where people who write code for a living can make a real contribution.
So some of it is, he breaks it down by like funding, how energy is produced, how it's consumed, just the general tooling and simulation software.
A lot of this is very research heavy.
And so there's some really cool simulation methods that you can use.
Okay.
Nice.
And would you say in the end it comes out more on the dream side or more on the worry side?
I think it's a very optimistic piece that there's a lot of opportunities for people to get involved right now.
And one reason that's the case is that around 2012, there was a sort of flip in our economics of renewable energy where wind and solar started being cheaper than coal or natural gas in a lot of parts of the country.
I mean, increasingly in a lot of parts of the world too.
And so it's actually better business to be working on renewables right now.
And so funnily enough, there's a whole lot more companies working on it now that it's actually a really profitable business.
Yeah.
Surprise.
Once it's purely a good choice just from a business side, then all of a sudden, yeah, absolutely.
Yeah.
So that's part of why renewables is such an exciting place to be right now is it's not a choice between like, oh, fantasy and like, oh, feeling guilty about it.
It's actually like good business and good for the world and good for your technology career to move into this field.
Yeah.
I suspect the next 10 to 15 years are really going to transform a lot of the ways we think about energy and electricity and all sorts of second level effects of that as that really kicks into effect.
Yeah.
For sure.
Nice.
So when you think about like what, what can you do as a technologist?
Some people can buy carbon offsets.
I have in Portland, our electric company has this thing called Green Source where you can pay like extra for your bill.
It will basically guarantee 100% of your energy comes from renewable energy.
That probably offsets somebody who wouldn't pay that.
And so maybe it's not that great of a deal.
So we can make these little changes.
Or you could do something like you've done, like start a whole company.
Tell us about your company.
Yeah.
So I am the co-founder and CTO of a clean tech nonprofit called Watt Time.
It's watt like energy, time like times.
There's three T's in that.
And so what we do is we figure out when energy is clean or dirty coming from the grid in real time.
So if you think about flipping a light switch, is that turning on a coal plant right now or a windmill or solar or natural gas or something else?
And that answer actually changes every five minutes as different power plants come on and off the grid.
So we figure out that data in real time.
And then we use it to control smart devices.
So things like smart thermostats or electric vehicles or whole building automation systems so that they can turn on when electricity is a little bit cleaner and off when it's a little bit dirtier and save carbon from the grid overall.
Yeah, that's really a great idea.
So imagine I have some kind of thermostat and an air conditioner at my house.
And I want to say I would much prefer to cool my house with renewable energy.
And that thermostat could subscribe to your service and decide if I were to turn on now, what kind of source would this energy come from, basically?
Exactly.
Okay.
Yeah.
And so our algorithms try to do it.
So your house will see more or less the same temperature all the time.
But it's like if the air conditioner needs to fire for like 10 minutes out of the hour to keep your house the temperature you want it, it would choose the cleanest 10 minutes.
Yeah.
Oh, that's excellent.
And what's the uptake like?
Are there a lot of companies reaching out to you to work on this?
Is this, how's it going?
We have some pretty good partners in the pipeline right now.
Yeah, it's pretty exciting.
Part of the trick is that a lot of smart device companies like IoT, Internet of Things, is this like big business.
It's really exciting, but it's not very standardized yet.
And so a lot of what we're also coming up against is just the fact like, well, do we have to write a separate integration for every company?
And as a nonprofit, it takes a lot of funding to get to the point where you have the manpower for that.
I bet it does.
Yeah, like there's not that many residential places that have that kind of connectivity, right?
Like I have some crummy little twisty thermostat on my wall and, you know, I doubt that it, I know it doesn't care about any of those sorts of things and it has no capability.
But so you're focusing more on large scale stuff, maybe like electric vehicle charging stations that are super intensive or a hospital air conditioner, things like that?
Exactly.
Although home thermostats is a really good market too.
There's a 40% of US power demand comes from homes.
And a lot of that is from heating and cooling.
Sure.
Absolutely.
So could I go buy a thermostat that would integrate with you guys and plug it into my house?
Yeah.
So you can go to our website and we have a waiting list right now to sign up for our very first smart thermostat from our partner, Energate.
How exciting.
Yeah.
Awesome.
So tell us about your company.
Where did it get started?
So I met my co-founder when we were doing our PhDs at UC Berkeley.
So like I said, I was doing biophysics, but I knew I wanted to do energy stuff.
And he was doing energy economics and behavioral economics.
And so he actually came up with the algorithms that are the foundation of lot time, sort of as an extension of his PhD.
And so we just met at a hackathon, just a regular weekend thing.
It was like, hey, you want to work on this thing?
This sounds awesome.
Cool.
Let's do it.
And then he's such an amazing volunteer organizer that he kept me around for the next few weeks, a month, and then years.
And then ongoing, huh?
Very cool.
Yeah.
What kind of hackathon was it?
What was the theme?
Or where was it hosted?
Things like that.
It was called the Berkeley Clean Web Hackathon.
So there's a clean web initiative is an international network that hosts energy focused hackathons.
Okay.
So it was specifically energy focused to start with.
I see.
Yeah.
Very nice.
Now, you said it's actually pretty hard to predict whether this energy is going to be clean or not.
And there's a lot of data science problems going on there, right?
Yeah.
So part of the fundamental challenge with getting to 100% renewables on the grid is that wind and solar are completely dependent on the weather when they're actually produced.
And so better prediction of that and better just use of that stochastic information is really interesting for data science.
Now, one of the things that maybe not everyone knows is the older energy sources like coal, which is especially bad, are very hard to change their capacity, right?
Yeah.
So the wind might blow hard for 10 minutes and then stop.
And that'll generate way more energy.
But you can't just necessarily pour that energy into the grid, right?
That's another reason why this is such a hard problem is exactly what you said.
That phenomenon is called curtailment.
So the idea that if there is way too much wind being produced right now, maybe the utility would prefer to use that instead of coal.
But it's so expensive to shut down a coal plant for just a few minutes.
And so they'll actually call the wind farm and be like, dudes, you have to turn off your clean, free, renewable energy.
That has to get wasted right now.
Yeah.
And what I think it's really especially unfortunate about that is that happens at the time when the most energy is being created, right?
Exactly.
Yeah.
It's like the, yeah, it gets punished for doing too well.
Yeah.
Exactly.
Whereas coal gets rewarded for not doing as well.
Wonderful.
Yeah.
You said you actually have.
Optimistic.
Really.
Well, you know, maybe it's a sign of something like coal.
It's, it's just doesn't really fit so well into the modern world where we have so many better answers, right?
So in, in the longterm, maybe it's a, another negative for coal, but still in the short term, it's a problem that you guys, that, that is a challenge for you.
Cause you can't just say, oh, it's a windy.
So it must be good.
Right.
It could have actually been the worst case scenario.
And you have two kinds of challenges that you're solving with Python.
One is right now, what is the energy?
Story for my air conditioner, right?
If I turn on my air conditioner, it comes on immediately and it does its air conditioning and then it turns back off shortly.
But if I had an electric car and I had it plugged in and I just said, look, I would like to drive to work at seven in the morning.
It's 10 PM.
You get my car charged as, you know, efficiently with renewable energy as possible.
That's a different kind of problem.
It's like a forecasting problem, right?
Yeah.
So for both of those kinds of problems, how our model works right now is that we get open data about what's going on on the power grid.
So there's entities called balancing authorities that make sure that supply and demand are matched in real time for what's on the power grid.
And they actually put a fair bit of open data online, which is the foundation of what we're able to do.
So we pull in that open data both for what's happening in real time and what they think is going to happen for the next few hours.
So it's interesting.
Their forecasts have some systematic bias, which we're working to correct also.
But as a start, like there, it's the forecast that the actual power grids are running on themselves.
So it's a good starting point for our algorithms.
Yeah, sure.
Oh, it's nice that you have that to start with.
You don't have to completely come up with the forecasting.
Exactly.
But the open data that we're based on isn't exactly the kind of data that we want to be using.
It tells us like overall what's happening on the grid, but it doesn't tell us exactly what your personal effect would be.
So if you think about like if you use a little bit more power right now, what power plant are you affecting most?
That's where our sort of special sauce comes in.
Yeah, sure.
Now you can't talk about your special sauce, but we could talk a little bit about the architecture.
So what technology do you use to build your API that these devices integrate with?
So we are Python top to bottom.
So it's a Django REST framework API that is pulling from the data from Postgres database and then serving it up.
So it looks sort of like a weather API, just time series data.
Yeah, it's got to be a lot of time series.
You know, all this data of Internet of Things you're collecting and serving.
You also use Panda for data analysis, right?
Yeah.
So on the back end, in order to collect all the open data about what's going on and then analyze it, Pandas is really big for that.
And then we use Celery for all the periodic task management of scraping the data from the sources and then sending those on off control signals to all the smart devices that we're working with.
You actually outlined this in a talk you gave at DjangoCon this year called Django for IoT from hackathon to production.
Yeah, that was a cool talk.
Really nicely done.
Thank you.
Yeah, it was such a treat to be able to speak at DjangoCon.
Yeah, I'm sure.
That's cool.
So one of the things you talked about were design patterns and anti-patterns for building Internet of Things services.
Yeah, so part of the basic premise of the talk was that you can, like, normally when we think of a Django, like, starter project, it might be a blog or a polls app or something.
But I think that an IoT project can be just as good a starter project for people to get started on with Django and with Python.
So one of the patterns there is that it really is all about time series data.
And so some of your data management, you have to think a little bit more carefully about your indices and things like that because your data gets so huge so quickly when you're dealing with Internet of Things data.
Yeah, if you have a thousand users and they have Internet of Things data putting time series in, that could be, you know, millions of records instead of thousands.
Very interesting.
Exactly.
Yeah.
So even just at a hackathon scale, like, if you're just doing a weekend project, you can still have a lot more data than you know what to do with, which is pretty fun.
Sure.
So one of the things I thought was interesting you talked about was you said normal Django apps are built around views and maybe a better way to think about it for APIs that work with Internet of Things devices.
is to think about tasks instead of views necessarily because everything is more or less asynchronous, right?
Right.
Yeah.
So that's the other big design pattern with IoT is that if you think about this is specifically for the use case where, say, you've bought some smart device and the company that made that thing has a server and they have an API.
And all you can do is send, get, or post requests to that API.
They won't send you anything unless you ask for it.
And so it has to be all about the machine communication and you have to do the work of initiating everything.
And so you can't wait for their server to send you a request.
You have to be able to initiate those.
And so that's a big part of where we use Celery for is running those periodic tasks.
And so that means all your, like, the code that really matters can't be looking inside your views.
It has to be in a similar kind of structure, but for machine-to-machine communication.
You can't really just, like, make a call to some server that's going to go out to a thermostat and wait for the thermostat to respond, right?
Your system would just lock up.
So a lot of it is, you know, begin sending this message asynchronously, throw it onto a queue of some sort, and then say the message was sent and just wait for some kind of response later, right?
Exactly.
Yeah.
So there's the whole other part of the architecture where the devices have to communicate with their maker's server and then their server has to communicate with yours.
So everything's sort of set up in its own very special way.
Sure.
So every device that you play with is going to have a slightly different setup.
Yeah.
And they may be responsive.
They may be high latency.
They may be flaky.
All right.
You never know about these cheap little devices.
Interesting.
The other thing you talked about was that you maybe don't build just one application, but you might have a family of applications around some kind of project.
So you might have one that talks to devices, one that receives observations, one for like a vendor portal, things like that, right?
It might be a suite of web apps, if you will.
Yeah.
So every kind of application that you're doing, since there are so many users of an app like this, there is the human like in their home doing whatever.
There is the company that you're working with.
There is the physical devices.
Each of these needs its own kind of user interface.
So it's kind of fun thinking of thermostats as the user of your application.
And what's a good user experience for the thermostat.
Yeah.
That is a funky visualization to think of the thermostats as your user.
But yeah.
Yeah.
I guess that's the UX problem I spend a lot of my time solving.
The thermostats are much happier if we implement it this way.
It's kind of true.
Oh, sure.
The other thing you said is one of the challenges you can run into is you might have a, if you're trying to spin up a quick prototype, like at a hackathon, for your example, or just, you know, some quick proof of concept, you might have one way of implementing things, like especially the like the background tasks and stuff.
And then if you're doing a production, it probably needs a lot more careful attention.
I'm a big fan of Heroku, especially for hackathons.
And so Heroku has one really nice feature called the Heroku scheduler.
And that allows you to, for free, run periodic tasks every 10 minutes or every hour or once a day.
And so that can be a really good first pass option.
And if you want to do something really quick and easy at a hackathon where, like you've written the code to say, okay, I want to hit the thermostat API every 10 minutes.
That's a free way to do it where you don't need all the pain and sort of extra structure of setting up Celery.
But as soon as you need more reliability or more flexibility in terms of when you're running the tasks, then Celery is definitely the right option there.
So if people aren't familiar with Celery, this is a distributed message queue framework for Python.
So it's great for either running asynchronous tasks.
So something like if someone signs up for your service and you want to send them a user signup email, you can send the email in the background while you return a view to them.
But you can also use it for scheduling periodic tasks.
So something like every five or 10 minutes.
Sure.
Yeah, I think it's thought of more often for long running things.
I'm going to do some kind of report and it's going to take too long for the request.
So we'll initiate it as a task and then pull for the response or something like this.
But the scheduling aspect of it is cool too.
Yeah.
So it's like if you would normally do something with Cron on your laptop, this is the way that you can use a similar kind of way of thinking about things.
But in a distributed environment, like where you're actually running your web apps.
This portion of Talk Python is brought to you by Hired.
Hired is the platform for top Python developer jobs.
Create your profile and instantly get access to 3,500 companies who will work to compete with you.
Take it from one of Hired's users who recently got a job and said,
I had my first offer on Thursday after going live on Monday and I ended up getting eight offers in total.
I've worked with recruiters in the past, but they've always been pretty hit and miss.
I tried LinkedIn, but I found Hired to be the best.
I really like knowing the salary up front.
Privacy was also a huge seller for me.
Sounds awesome, doesn't it?
Well, wait until you hear about the sign-in bonus.
Everyone who accepts a job from Hired gets $1,000 sign-in bonus.
And as Talk Python listeners, it gets way sweeter.
Use the link Hired.com slash Talk Python to me and Hired will double the signing bonus to $2,000.
Opportunities knocking.
Visit Hired.com slash Talk Python to me and answer the door.
So one of the things that you talked about a lot is IoT and your service, your company is more focused around providing data for other people's things on the internet.
But you said you end up building some every now and then as proof of concepts yourself because someone's got to show that this works before someone else will buy into it, right?
Exactly.
Yeah.
So starting as just one step above a student project when we were just getting started, one of our first partnerships was University of California at Merced has all of these electric golf carts that the maintenance people use to drive around.
So this is the simplest thing that's approximation of an electric vehicle charging system we could use.
So we got these smart plugs.
It's like something you plug into the wall and then you can plug anything else into that.
And then we had all of the electric golf carts plug into those and then we would manage the charging from there.
So there's a brand called ThinkEco that has an API that you can use to control these smart plugs.
So we got those and we were able to write an app that does the full end-to-end integrations, everything from figuring out the best times to be charging, forecasting that for the next few hours,
and then sending the signals all the way down to the charging system to say, okay, turn on now.
Okay, turn off now.
How interesting.
So talk to me about the architecture a little bit.
Did you have a Linux server on the same network as the smart plugs and something like this and they just kind of watch that?
Or how did you put it together?
Yeah, so for that part of the communication, there's a couple different models.
So the one that we used for that project, there was a hub, so sort of like a local gateway.
So there's a protocol called ZigBee.
That's pretty common for Internet of Things communication between the device and then some central hub.
And then you plug the hub into Ethernet and that's able to talk back out to a real server.
Okay.
Yeah, so the smart plugs could get out and check on what they're supposed to do.
Exactly.
Okay.
Very cool.
How much did one of those little plugs cost if like listeners are like, I'm going to build one of those?
Is it a cheap thing that you can put in your house or is it kind of pricey?
Different brands are anywhere between like 30 bucks and 100 bucks.
Okay.
There's a range of prices and there's some pretty cool things you can do with them.
So one called BelkinWemo is on If This Then That.
And so that's something where you barely have to write any code at all to start hacking around with it.
Oh, wow.
That is pretty cool that it's built on that.
Yeah.
Interesting.
So you guys are writing a lot of Python code around renewable energy and whatnot.
You've got some open source projects at github.com/watttime.
And your most, I guess, generally applicable one, like you have your API code there and stuff like that.
But one of them that's kind of general purpose is this thing called PyISO, P-Y-I-S-O.
Want to tell us about that?
PySO is a set of Python client libraries that we use for scraping data from different online sources about what's happening at the power grid.
So one thing that we think is really cool and that other people like playing with, too, is what is the mix of generation sources that's on the grid at any given time?
So maybe in California, we have some number of megawatts of natural wind, some number of coal, some number of solar, some number of wind.
And that's going to be different in five minutes.
And it's going to be different in the Midwest.
And it's going to be different in New York.
And so PySO is a set of libraries that anyone can use to start scraping some of that data and playing around with it yourself so that you can understand where your power comes from.
So if you wanted to build a business like yours, this is some of the foundational data that you might need.
Exactly.
And it's been really fun to get open source requests from people at solar companies or people doing research on these systems.
So there's a lot of users out there and very open to contributors.
Yeah.
Oh, excellent.
Yeah.
So if you want to help, check it out.
I'll be sure to link to it in the show notes.
Cool.
Yeah.
One specific thing that would be really cool to get help with is we have coverage for a lot of the United States right now.
But there's also similar open data available in Canada and in Europe and Australia and other parts of the world.
So if you're listening to this show and you're like, oh, everything she's talking about is in the U.S., like there's opportunities in the rest of the world to chip into.
Okay.
So you're taking this from some kind of governmental source in the U.S. or regulatory place that gets this data.
What are the data sources of this library?
So that's the annoying part.
That's why they need a whole library for it is that I mentioned the balancing authorities a few minutes ago.
So that's where we get the data from.
But each balancing authority publishes data in a totally different format.
So some are like zipped CSVs.
Some are XML.
Some is a nice JSON API.
And so that's a big part of the point of PySO is to hide all that ugly stuff in the background and make it easy for you to just write one little Python line and have everything else to get taken care of.
So that's a lot of pandas and beautiful soup in the background of that.
Okay.
And requests.
Oh, yeah.
That's a good combination.
Yep.
Pandas, beautiful soup, and requests.
Yeah.
So I've heard of a lot of variation in APIs.
You know, maybe this is an HTTP JSON service.
Maybe that's a SOAP web service.
But I've never heard of it being so broad as we've got zipped CSV mixed with like some probably the beautiful soup is for like some kind of web scraping on some other service.
Yeah.
And then you've got like an actual API, right?
Yeah.
So different balancing authorities in different parts of the U.S. have just put their data online in different formats.
So there hasn't been any real reason for them to standardize it.
And a lot of them don't employ nice fancy Python developers to write a good service.
So it's just whatever people have been able to throw together.
I think of one of the challenges of getting renewable energy really working has to do with having a better power grid.
Yes.
But maybe that is obviously like an important physics problem.
But I think maybe, you know, it sounds like there's even more fundamental things.
Like if there's not some kind of standard API for even discussing what kind of energy is being used and so on.
Like if it's down to a zipped CSV, that's probably not a system that in its mind is about real time.
No.
Yeah.
I completely agree.
And that's something that there's a lot of rhetoric in the community about like we're moving towards real time and everything's going to be real time.
The future is going to be amazing.
But it's we're still pretty early in the process of building that future.
So there's a lot of opportunities.
Sure.
But it's cool at least that you have a library that means people don't have to live in that past.
They can work in the future.
And if that balancing authority comes up and says, all right, we actually have a real API now, they won't have to change their code, right?
You guys just fix that open source library to use the new format and it's good to go.
That's the idea.
Yeah.
And so keeping it up to date has been another fun challenge.
At every daylight savings time transition, I have to wake up early on a Sunday and fix whatever bugs came up because there's also no standardized way of handling the daylight savings time of these data sets.
Oh, yeah.
So you said that there were actually quite a number of other open source projects and startups that were either open source projects focused on renewable energy or maybe they're even written in Python, as well as a number of renewable energy startups using Django and other Python web frameworks.
Yeah.
I sort of like to break down the field of what's happening in renewables into a few different categories.
So sort of the lowest level is to just build more renewables.
It doesn't matter what we build.
We just want as much as possible.
The next layer is to build the right renewables that produce energy at the right times.
So like we were talking about before, if there is like too much wind, where there's also too much other kinds of energy being produced, it can't be useful.
So getting that next level of optimization right matters.
And then sort of the highest level is, okay, we have the constraint of what energy has been produced.
How can we use it in the best way?
Right.
And that's kind of where you live a little bit.
Exactly.
But there is really cool work happening at all three of those levels.
Well, and there's also efficiency, right?
Just like build more efficient buildings.
Use less energy, right?
Use less.
Yeah.
So efficiency is sort of like step zero.
Yeah, exactly.
It's not as fun to talk about, but it matters at least as much as anything else.
So turn off your lights.
Yeah.
I talk to my kids all the time.
I'll go into their bathroom, my daughters, and we have like this, I don't know, like this lighting thing for the mirror.
There's like six lights and they're all on while they're at school.
I'm like, kids, how many lights you just left on when you left?
So yeah, that definitely makes sense.
And there's actually an open source project for that that you pointed out, right?
Called what?
Energy Plus?
Yeah.
So Energy Plus is a simulation program that's used by architects and engineers for building new energy efficient buildings.
So doing some of that design work.
So there's a lot of cool simulation work that's a part of that for like thermal modeling and energy flow and how like sunlight is hitting a building to make sure that part's efficient.
So that project is mostly in C++ and Fortran, actually.
I'm not sure if there's Python bindings for it, but that's a very active open source project maintained by the National Renewable Energy Lab in Colorado, NREL.
Sure.
So let's talk about some of the build more ones.
Some of the Python startups are in that area, right?
Yeah.
So that's an area where there's a lot of startups right now because the biggest challenge for building more renewables right now, especially in solar,
is not the cost of the equipment itself, which is amazing that that's so cheap now.
But so the bigger part of the cost that people are trying to work on is sort of the soft costs.
So things like marketing and customer acquisition and making it easy to design systems quickly and get them installed quickly.
So there's a whole bunch of Python based startups that are working in the sector.
Sure.
So one of them is utility API.
Another one is Sighton, Fossum Labs, and EnergySage.
So what are those guys doing with Python?
What's their business model, each one of them?
Yeah.
So utility API is one of our friends in Oakland.
There's a lot of this in California.
And what they do is they do sort of the flip side of what PISO does, but for utility build data.
So they say, like, utility builds are also in these, like, it'll be a PDF or some sort of, like, horrible, unscrapable format.
And so they've written scrapers for a bunch of different utilities that either individuals can use, but really other solar companies can use to say, okay, this is what someone's power bill has looked like in the past.
Maybe they're going to be a good solar customer.
Maybe they're going to be not as good a solar customer.
And so simply opening up that data access is a really foundational part of the pipeline.
Right.
Because our API is zipped CSV files.
Gives you a sense of accessibility of the data, right?
Yeah.
It's like PDFs in this case.
Exactly.
Yeah.
So they have a pretty hard problem.
Yes, they do.
Wow.
So if, like, for example, if I want to add solar energy to my house or some kind of renewable energy and I went to some solar energy company and I said, hey, what could you guys do for me?
They have this huge problem of, like, well, go and download the last year of your data and zip it up and send it to us or something crazy like that.
And this utility API basically reverses that and makes it possible to go have a look at what my actual data is in an API form.
Exactly.
Yeah.
Okay.
So they've been growing really quickly.
Nice.
And they're using Django as well?
Yeah.
So they have Django and they're more Python on the back end, too.
So lots of regular expressions and other scraping packages.
Yeah.
I can imagine.
Cool.
And then Citan.io?
Citan and Folsom Labs are two of the Python-based energy startups that focus on designing the systems for actually getting the solar panels on roofs.
So another challenge that solar developers want to be solving quickly is what's the angle of your rooftop?
What is the right number of panels to put on your roof?
What's the best way to hook all the modules up together?
And so Citan and Folsom Labs both handle different parts of that problem.
Yeah, because otherwise you're using something like AutoCAD and you're just starting entirely from scratch and there's nothing about solar energy or any of these types of things, right?
So this is a much quicker, like a rad design tool for your physical deployment of solar.
Interesting.
Exactly.
Yeah.
And so those are kind of fun because there is both the physics modeling to make sure that the electrons are flowing in all the right places.
And also some of the financial modeling to see, like, is this going to produce the right cash flow both for the customer and for the company who's actually installing the panels?
Sure.
And then Energy Sage is about getting quotes.
It's like Expedia for renewable energy, right?
Yeah.
So there's several of these different services where you can go and say, like, there's so many tiny solar companies in different parts of the country, just mom and pop shops.
And so it can be really hard as, like, if you're just a regular person and you want to put solar on your roof, you don't know who to call.
And so Energy Sage is one of the startups that is trying to make it easy for, not for companies to find you, but for you to find companies.
So there's people going both ways.
We all want to ship our software faster, respond to user requests quicker, and build an edge on the competition.
But the faster you go, the more likely a bug or issue will slip by and cause your users grief.
I have the same trade-offs with my Talk Python websites and infrastructure.
That's why I use SnapCI.
Every time I check in at GitHub, SnapCI springs into action.
A clean copy of code is pulled from GitHub.
A Python 3 virtual environment is created.
All the packages and dependencies are installed.
The unit tests are run.
Finally, I'm notified in Slack and a menu bar on my Mac about the outcome.
That way, I know it's safe to ship a shiny new version of my web app.
Ship your software faster with a 30-day free trial at snap.ci slash Talk Python.
Let's talk about building the right renewables.
So right amount of energy, right time, that kind of thing.
In this space, there's this problem called the duck curve.
What's the duck curve?
It's a kind of weird name for a kind of cool graph.
So if you Google duck curve, you will find these graphs that show right now in some parts of the world, the amount of renewables that's being put on the grid is sort of balancing the other things that's being produced.
So there is not really a problem.
But as more and more solar in particular is put on the grid, that will mean that sometimes there can actually be more solar production in the middle of the day than there is demand.
So this is a huge problem because that means that if we're just spending money on building new solar panels willy-nilly, that's not actually solving the real problem.
And so there's a problem with how to...
Right.
Because like the coal plants have to stay online, so you just have to dump that energy anyway.
Exactly.
Or like even if we were able to turn off the coal plants, there might still be too much solar, which is a kind of fun problem to have.
But that really is the future that we're moving towards.
And so building the right mix of energy in the right places is something that is mostly a sort of research and policy problem at this point.
So there's a lot of cool work going on at research labs, including some of the national DOE labs on this part of the work.
Excellent.
Yeah.
And that was kind of your first job, right?
Yeah.
So there's also some work going on at like consulting companies like what I was at.
And also the big solar and wind companies will have in-house groups that do some of this work to be like, okay, we need to get this project permitted to put on the grid.
How can we simulate exactly how much energy our wind farms or solar farms are going to be producing in 10 years?
Okay.
Yeah.
So there's a lot of interesting open source.
There's a couple of popular open source Python related projects trying to help answer this question, right?
Mm-hmm.
Yeah.
So there's one for wind called wind ML, ML like machine learning.
And there's a similar one called PVLib, and that has a Python binding.
So both of these are Python projects that for the first one, it can help you collect data about what your wind farm might do and analyze that data.
And for the second one, it does the same thing for, but for calculating a solar PV output.
So if you have solar, like photovoltaic panels, what kind of power are they going to be producing when?
And so you can plan around that.
Mm-hmm.
And if you wanted to treat this like a data science problem, are there like cool data sets and stuff that you can use?
Yeah.
So both of those will give you access to data sets.
And then the National Renewable Energy Lab also hosts a similar data set called PVWants.
So that's something that like there's been a lot of effort put into developing these data sets.
But that one's kind of interesting is that I wasn't able to find good Python bindings for it or a good Python client.
So that's an opportunity for someone to start a new open source project and see if it catches on.
And then the last part, the third category you said was using the right energy when it's available.
And that's what Wattime works on.
That's what PyISO, your project works on.
What else is going on around there?
Part of why this is so hard is that this isn't something that the good operators can really just do by themselves.
You can't just plan for it and then have it work.
Because at the end of the day, it's a behavioral problem.
It's happening at the user's side of the equation.
So almost every energy hackathon that I've been at, someone is super excited to be like, oh, if people could just see where their energy is coming from, then they'll take all the right actions.
And you can make some really fun graphs that way.
But unfortunately, none of them have ever really caught on.
Like Google and Apple and Microsoft have all tried these two.
And unfortunately, it's just like a really hard behavioral problem to get people to pay attention to where their energy comes from.
Yeah, they don't really seem to catch on.
Yeah.
You put an interesting factoid up here that says people spend less than 10 minutes a year thinking about their power bill.
Yeah.
So it's true.
Like people don't really care even though they think they do and even though they want to.
And so that's why technology can be so impactful in this part of the problem is because it's all about automation and smart devices and the Internet of Things in order to really solve the problem in a way that sticks.
Yeah.
You almost have to take the person out of the loop, right?
If the thing that controls the house is connected back to another place that cares about how this works and the person still spends maybe 12 minutes now because they have some blinky lights to look at thinking about this per year, it's still like if it does the right thing, that's way better.
Yeah, exactly.
So what we do at WattTime is part of that.
Another project that is in some ways related is the sort of category of ways of dealing with the energy problem is called demand response.
Making the power demand be responsive to what's happening on the power grid.
And so one open source project is there's something called the OpenADR, which is Open Automated Demand Response.
And so this is a standard or like a protocol for developing implementations for smart devices that will actually turn on and off at the right times.
Oh, that's pretty neat.
Yeah.
So there's a few different open source implementations of this protocol.
And those are something that are a real opportunity for people to get involved and develop those more fully because it's sort of a pain if the first thing you have to do in order to be able to work with a bunch of different devices is to re-implement a standard every time.
Yeah, absolutely.
So that's a really impactful place where people could jump in.
And then another area around here, it seems to me, is if you know there's excess energy, if you could somehow store it.
And there's a lot of interesting ways that I learned that you can store energy.
Like you could pump water uphill and then let it back out and use it almost as like water power when there's less energy and things like that.
But probably the biggest one that's affecting residential areas, at least, I would say, is probably the Tesla Powerwall, right?
Yeah.
So that's definitely the sort of sexiest option out there right now.
Yeah, for sure.
And maybe not everyone knows what it is.
Maybe you could just tell us what is the Powerwall.
Yeah.
So that is battery that you can stick on the wall in your garage and you can buy it from Tesla and you can feel fancy because you bought the thing from Tesla even though you couldn't afford a car.
Essentially.
And it can talk to Tesla servers and turn on and off at different times that you can be.
I'm not sure exactly what features they've built out so far in terms of what different kinds of grid events it can respond to.
Right.
Maybe it is paying attention to price or maybe it's paying attention to renewable energy or not.
Something like that.
Who knows?
Yeah.
I don't have one either.
But there's a lot of possibilities it could trigger on you.
Yeah.
And so there is also other similar things where like you can get used electric vehicle batteries and use those for the same thing.
So it doesn't it's like recycling electric vehicle batteries.
There's a secondary market where you can stick them in your garage and have them be useful.
Oh, that's really interesting.
That I had not heard of.
Yeah.
Cool.
You'll have to give us some links to something like that so I can put on the show notes.
Sure.
You know, maybe some people out there listening are getting excited about like, hey, maybe I could participate in this.
There actually are a bunch of energy focused startup incubators.
Kind of like YC, but for energy, right?
Yeah.
So that's a these are great places to start if you have your own idea for an energy project or you just want to meet people who are involved and maybe get hired at an existing startup.
So there's a bunch of these in different cities.
One, two blocks from my office in Oakland, California is called Powerhouse.
There's another called Acre in New York City.
Greentown Labs in Boston.
Energy Foundry in Chicago.
1976 in D.C.
So there's ones all over the U.S. and I'm sure some in other countries, too.
Is the process pretty similar to going to Y Combinator?
You come in with an idea.
They help you grow it, turn it into a company.
But it's really just got this mission around energy.
Exactly.
Yeah.
So each one has a slightly different model, but a lot of them also have meetups.
So even if you aren't ready to make this your full time job yet, you can still go to some of their public community events and learn more about what's going on.
Okay.
That's great.
Yeah.
Too bad there's not a Portland one.
Maybe someday.
Oh, someone could start one.
That's true.
They sure could.
All right.
Well, this has been a really interesting conversation.
And before we wrap it up, let me ask you two questions I always ask of all my guests.
One is, if you're going to write some code, Python code in particular, what editor do you open up?
I like Sublime these days.
Sublime.
Very nice.
Yep.
Although in grad school, there's something called Spider with a Y.
And that's sort of like an R studio or a MATLAB clone, but for Python.
Yeah.
That one comes with the Anaconda distribution, right?
I think from the Continuum guys.
So you can get it that way.
That's cool.
Yeah.
But if I'm writing Django, I like Sublime.
Yeah.
Right.
Yeah.
If you're doing data science, maybe Spider is pretty awesome.
But if you're doing Django, yeah, Sublime.
Okay, cool.
I saw the other day there's 88,000 plus packages on PyPI.io.
Whoa.
It's crazy.
I mean, that's why it's so great to work in Python, right?
Just mostly what you need is already out there.
What one's your favorite these days?
One I heard about recently is called retrying.
So since a lot of what we've talked about is like all these different IoT data sources
and grid data sources are really flaky.
So retrying is something that makes it a lot easier to be like, okay, this rub request,
this HTTP request failed, but let's try it again.
So there's a nice little decorator that just retry.
Wow.
Can you say like retry like 10 times with some kind of like backup level or like what's it
look like?
Yeah.
Nice.
Yeah.
So you can figure out all of that.
Awesome.
If people want to get involved, what can they do?
How do they work with Wattime or what other advice or call to action can you give them?
Yeah.
So if you want to get involved in helping with PYSO, that's P-Y-I-S-O.
And you can check out our GitHub page and or just email me or chat me up on Twitter and
we can find a way to start working together.
So my personal Twitter is windsupanna and Wattime is on Twitter at Wattime.
Excellent.
Yeah.
And I'll put those in the links, of course.
Great.
And if you want to get on the waiting list for some of our smart devices, there's a
smart thermostat that you can sign up for or an electric vehicle charging station.
Or if you have like if you actually manage commercial building, we have a lot of other services that
we can hook you up with also.
That's awesome.
And it won't be just renewable energy doing good, but you'll have the warm feeling that
Python is in the back end making it go, right?
Exactly.
The real positive motivation there.
Not saving the world, just saving Python.
That's right.
Saving the world with Python.
Yep.
All right.
Well, let's leave it at that.
Anna, thanks so much for being on the show and sharing the story about what you're doing
around renewable energy.
It's inspiring.
Thank you.
This is really fun.
Yep.
You bet.
Talk to you later.
Talk to you.
Bye.
This has been another episode of Talk Python to Me.
Today's guest has been Anna Schneider, and this episode has been sponsored by Hired and
SnapCI.
Thank you both for supporting the show.
Hired wants to help you find your next big thing.
Visit Hired.com slash Talk Python to Me to get five or more offers with salary and equity
presented right up front and a special listener signing bonus of $2,000.
SnapCI is modern, continuous integration and delivery.
Build, test, and deploy your code directly from GitHub, all in your browser with debugging,
Docker, and parallels included.
Try them for free at snap.ci slash Talk Python.
Are you or a colleague trying to learn Python?
Have you tried books and videos that just left you bored by covering topics point by point?
Well, check out my online course, Python Jumpstart by Building 10 Apps at talkpython.fm
slash course to experience a more engaging way to learn Python.
And if you're looking for something a little more advanced, try my Write Pythonic Code course
at talkpython.fm/Pythonic.
You can find the links from this episode at talkpython.fm/episodes slash show slash 76.
Be sure to subscribe to the show.
Open your favorite podcatcher and search for Python.
We should be right at the top.
You can also find the iTunes feed at /itunes, Google Play feed at /play, and direct RSS feed at /rss on talkpython.fm.
Our theme music is Developers, Developers, Developers by Corey Smith, who goes by Smix.
Corey just recently started selling his tracks on iTunes, so I recommend you check it out at talkpython.fm/music.
You can browse his tracks he has for sale on iTunes and listen to the full-length version of the theme song.
This is your host, Michael Kennedy.
Thanks so much for listening.
I really appreciate it.
Smix, let's get out of here.
Outro Music.
Don't forget.
Thank you.