Latest / Talk Python To Me / #122: Home Assistant: Pythonic Home Automation
Transcript
- 0:00The past few years have seen an explosion of IoT devices. Many of these are for the so-called
- 0:04smart home. Their true potential lies in the ability to coordinate and automate them as a
- 0:09group. How can your garage, Wi-Fi, Chromecast, and window shades work together automatically?
- 0:15Chances are these are all from different manufacturers with different protocols and
- 0:20apps. That's why you need something like Home Assistant. This Python-based app brings over
- 0:25740 devices together and allows you to observe, control, and automate them as a whole. This week,
- 0:32you'll meet Paulus Shouston, who created Home Assistant. This is Talk by Thinomy, episode 122,
- 0:38recorded July 25th, 2017.
- 0:50Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the
- 1:12ecosystem, and the personalities. This is your host, Michael Kennedy. Follow me on Twitter,
- 1:16where I'm @mkennedy. Keep up with the show and listen to past episodes at talkpython.fm,
- 1:21and follow the show on Twitter via at Talk Python. This episode is brought to you by Rollbar and us
- 1:27at Talk Python Training. Be sure to check out what we're offering during our segments. It really helps
- 1:31support the show. Hey, everyone. Before we get to the interview with Paulus, let me just share a quick
- 1:36news item with you. So last week, I was interviewed on one of the other major Python podcasts, Podcast
- 1:43Init, and the topic was the migration to MongoDB. So I met with Tobias Macey, and we had an hour-long
- 1:51conversation about why and how and so on. I migrated all the podcasts and training sites and things like
- 1:58that from SQLAlchemy and a relational database over to MongoDB. What went well, what didn't, lessons I
- 2:05learned, things like that. If this is interesting to you, just check it out at podcastinit.com, or if you
- 2:10subscribe to the podcast, you can find it there. Now, let's talk with Paulus about home automation.
- 2:15Paulus, welcome to Talk Python.
- 2:17Yeah, welcome. Hey.
- 2:19Hey, great to meet you and talk with you. I'm really excited about this project that you've created.
- 2:24One of the biggest, booming, growing, exciting areas is not really smartphones and devices anymore. It's
- 2:32internet of things and smart homes and little things that used to just be dumb widgets that we can now
- 2:38bring together. And really, what you built is not about the widgets, but about the bringing together,
- 2:43right?
- 2:43Yes. Yeah. The main goal of Home Assistant is to, you know, we have like, well, we call it the three
- 2:50pillars. We have observe, control, and automate. And the observe part is first bringing together,
- 2:56just knowing what's going on in the house. Control is being able to control the devices that are in
- 3:02your house. And then automate is based on observations, issue control commands.
- 3:08Yeah, that's awesome. And I'm so looking forward to chatting about it. But before we get into all
- 3:12the details there, tell us about your story. How do you get into programming in Python?
- 3:15During college, I studied, I initially studied computer science, but I actually dropped out.
- 3:21I was more interested in data. And so I started doing a business intelligence major. And there,
- 3:27I mean, you're always doing stuff with data. And I was always like using, like you're doing small
- 3:32projects in college all the time. And that's where I kind of like Python started to like sneak in.
- 3:37In the beginning, just based on what I know, how I used to learn programming, there's still a lot of PHP,
- 3:42but I slowly switched over to Python. And actually, when I was doing my master thesis is where I
- 3:49started doing a lot more Python. And that's also when home assistance started.
- 3:54That's cool. What was your thesis on?
- 3:56My thesis was on Medicaid fraud detection for the federal government here in the United States.
- 4:01Wow, that's really cool. That's I think there's really an untapped area in all of this
- 4:06medical information. It's pretty locked up, but it's starting to open up for machine learning and
- 4:12things like that.
- 4:12Yeah, I think there will be a huge potential just like even anonymized data can give us so much insight in
- 4:17all these things that are going on.
- 4:19Yeah, it's going to be cool as we get enough of this data out to actually do analysis.
- 4:24Okay, fraud is also good. Make sure that people who paid for the care or are paying for the care get it.
- 4:31That's great.
- 4:32Just for having this obviously unrelated to the topic of the podcast, but the fraud was actually
- 4:37not the people paying for the insurance. It were the doctors and the hospitals.
- 4:41Wow, that's kind of creepy.
- 4:43Medicaid is a free insurance. So those people actually didn't care how much got billed for
- 4:48them a lot of times.
- 4:49Right. They maybe didn't even know. Okay, I can see that. That's that's a little more disturbing. But yeah,
- 4:54good that someone's on keeping them on us. That's cool. So what do you do day to day these days?
- 4:58I'm a senior software engineer for Appfolio, which is a software as a service company. We provide a product
- 5:05for property managers to run their business in the cloud and a product for lawyers to run practice
- 5:11management in the cloud. And I work on the lawyer side of things. It's called my case.
- 5:14Okay, that's really cool. I feel like there's an untapped market. Well, not entirely untapped because
- 5:19you guys are doing it. But there's a big market for these super niche tool sets for just you pick
- 5:25your vertical and there's there's probably a not great solution for most most people, right?
- 5:31Yeah, definitely. And I think every so many verticals are still in like, you know,
- 5:37doing things with pen and paper or Excel spreadsheets for everything and being as a software as a service
- 5:42being able to build like an integrated solution that you know integrates everything from like,
- 5:46intake of clients to like billing clients to keeping track of your work sharing things with
- 5:52clients. There's a big opportunity.
- 5:54Yeah, that sounds really cool. We could definitely talk more about that. But let's let's talk about home
- 5:59automation. So you've been working on home assistant for about four years. And before we get into home
- 6:05assistant, I'd kind of like to get your your vision of the perfect home automation because you've written
- 6:10kind of a blog post manifesto type thing of like, here's where we should aim for this. What's your
- 6:15vision?
- 6:16Yeah, so my my vision for home automation is that a lot of people that kind of like, it's kind of like
- 6:21the early adopter phase where we're in right now where all these devices are entering the houses and
- 6:28people are realizing that with their smartphone, they can control their lights, they can control like
- 6:33the thermostat. But they tend to forget that it's usually not faster to, you know, actually use your
- 6:41smartphone like they tend to, you know, put in all these smart lights and all of a sudden your switches
- 6:45don't work anymore because your smart lights always need energy to be communicating with the network and to be part of the end of things.
- 6:52And so all of a sudden people like end up not having any light switches, which means that all of a sudden when they enter a room,
- 6:59they have to get their phone out of their phone, make sure it's connected to the network.
- 7:02And actually, they actually are instead of improving their life, they are decreasing their life experience kind of.
- 7:10Yeah, I totally think you're right with that. I mean, these things need to be kind of seamless like they are but better.
- 7:17They need to get better, not not just different, which makes it really it's a big, a big challenge, but a big opportunity.
- 7:24You know, like a quick, quick story. I was out biking the other day and I got this smart bike lock, this super tough smart bike lock, Bluetooth, you can control it, do all sorts of stuff.
- 7:33It works kind of okay. But you unlock it with your phone. And the phone wouldn't connect to it. And it was locked up. I'm like, what do I do? There's no key.
- 7:43I might be just stuck here. Because that stupid Bluetooth won't pair. What am I going to do? And this is like, this is the problem, right? Like, it's fine until it doesn't work sometimes, right?
- 7:55Yeah. And I think that's also another important part of like, you know, your Internet of Things devices is when you want to like, when your phone doesn't work, or you can't connect to it, you should still be able to like, be able to use your device.
- 8:08So in case of your lock, that's a very bad, like, you know, experience where like, oh, the Bluetooth doesn't work. Well, you're screwed.
- 8:16Yeah, yeah. There is a little panel, but it wasn't working as well. So like, it was, it was bad.
- 8:22Yeah. For example, the Philips light bulbs, when you turn them off with the electricity, like just the electricity off, and then you turn them back on, they will reset and turn on and like a white light you would expect from a normal light bulb.
- 8:33And so that's a nice experience. And even if you have a light switch, you can at least turn your light switch off and on to get the light to turn on.
- 8:41Right. So the failure mode is kind of like the dumb home, or whatever, the dumb device, in a sense.
- 8:47Yeah, exactly.
- 8:47Yeah, and these are the lights that you can dim, you can like change the color.
- 8:52And so they just go back to full power light, or something like this, huh?
- 8:55Okay, that makes sense.
- 8:56Yeah.
- 8:56Other parts of the home automation part is that like, a lot of people will build automations that are optimized for their own life, like as a one person in the household, but most of the times you're not one person in the household.
- 9:11So it's very annoying if an automation triggers, and it's not like somebody is like annoyed by it.
- 9:18So for example, if you're, you know, if you have this automation to turn off the lights or dim the lights when you are going to watch a TV series, if somebody is like reading a book on the side, then their light is gone.
- 9:29That's right.
- 9:30And so it's very difficult.
- 9:32You want to write automations that have like very, very high success rate.
- 9:37And the problem to writing automations with a very high success rate is that you either need to have a very scheduled life, you know, you need to be constantly like every day has to be almost be the same.
- 9:47And like have patterns for everything.
- 9:49But I mean, for a lot of us, that's just not the case.
- 9:52So we need to make like small automations that improve our life, but do not like work against you in the case of like you're going off the pattern.
- 10:03Yeah, exactly.
- 10:04Like, for example, you come home and normally you unlock the door with your phone, but your phone is dead.
- 10:08Now what?
- 10:09Yeah, exactly.
- 10:10So one of the automations I have, which has been very stable, is that like when we open the door, my phone is connected to the Wi-Fi.
- 10:20So home assistant knows I'm home and it will turn on the light, but only when the sun is down.
- 10:24And so the worst case is that the light is not being turned on for me and I have to hit the switch.
- 10:29Right.
- 10:29So the failure case is like what you had before.
- 10:32Yeah, exactly.
- 10:33Okay.
- 10:34Yeah, that's really cool.
- 10:35So another thing that you said in your vision was the perfect app is no app.
- 10:40What do you mean by that?
- 10:42It's kind of what I was talking before about like how the switch is faster than like opening your phone.
- 10:46And for most of these applications that you're having in your house, it is just as convenient or sometimes even more convenient to just go to the device and control it.
- 10:56The only thing that actually is coming up now that's going to be faster and more convenient is the voice assistants.
- 11:02So there's like the Google Home, the Amazon Ego, because those devices, even if your hands are dirty, for example, you're cooking or something, you can still control it.
- 11:12And it's very convenient.
- 11:13Yeah, I think this is that example really highlights some of the huge possibility and benefits, but also some of the challenges, maybe even apprehension for some people that we have this possibility of having this thing listening all the time.
- 11:28You can just speak to it like on Star Trek, like computer, dim the lights, please.
- 11:32It's amazing, right?
- 11:33It's just so incredible.
- 11:34But, you know, a lot of people are concerned about having a thing that is like constantly listening to them in their house all the time.
- 11:41Right.
- 11:41Yeah, no, that's definitely a valid concern.
- 11:43So there's actually been a couple of startups that are focusing on local speech to text.
- 11:50So they are doing local listening.
- 11:52And one that's recently come up and we've integrated and they actually contributed an integration to Home Assistant to integrate a system that looks very promising.
- 12:01It's called Snips, Snips.ai.
- 12:03They are a French startup and they're going to be their system is fully they're working on making it fully open source and it's already free to use on a Raspberry Pi.
- 12:12But the idea is that they pretty much build like an Amazon Ego with like the way you configure it with like these are the sentences that I want to support.
- 12:20But then they will run it completely locally on your device.
- 12:24So there's no cloud connection.
- 12:26And it also means that it's way faster.
- 12:28Yeah, that's one of the drawbacks of a lot of these cloud things.
- 12:32I mean, it's ridiculous.
- 12:34Like I can ask my phone like, hey, Siri, what time is it?
- 12:38And it will wait like five or 10 seconds and go, it's 2.30.
- 12:43Why did it take you 10 seconds to know that it's 2.30?
- 12:46Like this is not a huge challenge, man.
- 12:50Do you think that's a transient situation that we're in or do you think this is a permanent thing?
- 12:55Like is that just because the cloud is where the power is and it's moving to the devices?
- 13:00Or is that like places like Google would rather have the data to learn from and to massively scale on rather than make it work at home?
- 13:09I think there's multiple things in place.
- 13:10One is definitely Google and Apple, et cetera.
- 13:13They want to have your voice because they can see if they're training data, right?
- 13:19And so the more voices they have, the better they can learn from.
- 13:22But I think the biggest difference is actually is the way how these voice assistants work.
- 13:27So the Amazon Ego has a very basic approach as in if you want to write a skill, a voice part for Amazon Ego to know to support like add something to my shopping list.
- 13:41You have to register with Amazon every single sentence that the user can ever say.
- 13:47So you have to say, you know, you can have like slots that will like be filled in with the actual word.
- 13:52So you can have add item to my shopping list.
- 13:55But then you have to add another sentence, add item to my shopping list instead of the shopping list.
- 14:00And so you end up with like thousands of variations of your sentences.
- 14:04But the way Amazon Ego, this allows them that once the speech to text has been done, they can very quickly map it to a sentence that you can say because there's only like, you know, 10,000 possibilities of all the different skills that are active on your device.
- 14:19Right.
- 14:19It's not wide open machine learning.
- 14:21What did that person mean?
- 14:23Sentiment analysis type of thing.
- 14:24Right.
- 14:25And so that's where Google is the Google home.
- 14:29At least the way I think it works.
- 14:32They do more speech to text and then like get the intent of the text, which is a different approach, which is way more difficult to actually push into the devices.
- 14:41They're going to try, obviously, like, I mean, not per se Google, but like Apple's talking about like adding an AI chip.
- 14:48And, you know, getting all these things to run locally just because of, you know, privacy is important.
- 14:52Yeah.
- 14:52Like you said, don't discount latency.
- 14:54That's super annoying that it takes that long to get simple responses.
- 14:58Okay.
- 14:59So, yeah, these, I think you're right.
- 15:00This is a really great way to interact with.
- 15:03If you can interact with your home, there's some challenges like discovery, like what can you say to your home?
- 15:09It's sometimes hard to know, right?
- 15:10Yeah.
- 15:11No, that's, I mean, the problem with a voice assistant is that because we're still in the beginning phase where we actually don't really understand.
- 15:18what you're saying.
- 15:18We have just hard coded every sentence that we expect.
- 15:21So, you know, a lot of people call it artificial intelligence, but it's not really artificial intelligence yet.
- 15:28And I think the whole idea of having a normal conversation is not there yet.
- 15:34Once we haven't, we can like, kind of like, you know, as if you're talking to a person like, hey, what can you do?
- 15:40And like, you know, it's easier to interrupt them, et cetera.
- 15:44Then we can probably discover commands easier.
- 15:47Right now it's, you know, we'll, Google Home has like an Alexa, both of like newsletters.
- 15:53They email you like, did you know you can ask this?
- 15:55Kind of things.
- 15:57That's how we have to learn.
- 15:59Right, right.
- 15:59It's just a home, a smart speaker lesson every week.
- 16:03Interesting.
- 16:04Okay.
- 16:05So let's get specific about home assistance.
- 16:07So there's a number of, what would you think of this, like as a hub for a smart home?
- 16:13Or how would you describe it?
- 16:14Yeah, I would say it's a hub because the way I see a hub is that a hub is a device or a piece of software that speaks multiple languages and combines all these devices together and provides the user an interface or ways to control them.
- 16:32Yeah, well, you spoke about the challenge of having to open your phone and open an app to do a thing rather than just hit the switch.
- 16:37Well, there's an app for your plug.
- 16:40There's an app for your lights.
- 16:41There's an app for your garage door.
- 16:43Like if you have got to like go to the 10 different apps because you want to do a thing, like then it gets super crazy.
- 16:48So a home assistant will like speak the language of all these devices and give you one place to go, right?
- 16:54Yeah.
- 16:54And besides giving the user one place to go, it also means that it is one place for automations to run.
- 17:01Because if you have two different vendors, two different products of vendors that don't speak together, that don't work together, they have their own apps, their own clouds,
- 17:09then you will not be able to automate them without having like an intermediary that knows about both of them.
- 17:15Right, for sure.
- 17:16And so the motion sensor in a nest cannot be used to trigger a light being turned on or something like this.
- 17:23Well, a home assistant knows about your light, knows about the nest and can combine these things.
- 17:28Okay.
- 17:28So it basically, it can receive, it does a couple of things.
- 17:32It observes and monitors the state of many things.
- 17:35And it also receives events or at least state changes, right?
- 17:39Yeah.
- 17:40So the way it works is that we have a state machine.
- 17:42So home assistant, the architecture is that the core of home assistant is a event bus in which events related to your house are being fired.
- 17:51And these are, for example, a button is pressed or motion is detected.
- 17:57However, actually motion detect is a bad example because we represent that as a binary sensor because we can say motion is being detected.
- 18:08Yeah.
- 18:08And so the difference about something that happens right now and something that is happening is we want to, we have to capture it differently.
- 18:14We cannot just have an event.
- 18:15And so on top of the event bus, we have like a state machine and the state machine captures representations of devices in your house or other things.
- 18:25So for example, in the state machine, you have a light and the light is the main state is on or off for a light.
- 18:32And they have attributes that describe the state.
- 18:35So for example, for light, this could be the color, the brightness, maybe the color temperature.
- 18:41But for a media player, the state is, for example, passed or playing.
- 18:46And the attributes could be what type of media is the TV show?
- 18:50Is it a music album?
- 18:52If it's a music album, what's the artist?
- 18:55What's the song title?
- 18:56What's the track number?
- 18:57Et cetera.
- 18:57Yeah.
- 18:58And then whenever we change the state in the state machine, we will fire an event saying, hey, a state changed.
- 19:04And so it actually changed from this to this.
- 19:07And this allows other automations, for example, that can listen to either events or to state changes through the state changed event to kind of respond to whenever device representation changes in home assistance.
- 19:22And we can start like automating things.
- 19:24Yeah.
- 19:24That sounds really, really, really useful.
- 19:26So you start out with observing them and then you layer on state tracking.
- 19:30And then at the home assistant level, you fire the event that, hey, the state has changed.
- 19:35Anybody care about this thing?
- 19:36Maybe they do.
- 19:37Maybe they don't.
- 19:38Things like that.
- 19:41This portion of Talk Python To Me has been brought to you by Rollbar.
- 19:44One of the frustrating things about being a developer is dealing with errors.
- 19:47Relying on users to report errors, digging through log files, trying to debug issues, or getting millions of alerts just flooding your inbox and ruining your day.
- 19:56With Rollbar's full stack error monitoring, you get the context, insight, and control you need to find and fix bugs faster.
- 20:03Adding Rollbar to your Python app is as easy as pip install Rollbar.
- 20:07You can start tracking production errors and deployments in eight minutes or less.
- 20:11Are you considering self-hosting tools for security or compliance reasons?
- 20:16Then you should really check out Rollbar's compliant SaaS option.
- 20:19Get advanced security features and meet compliance without the hassle of self-hosting, including HIPAA, ISO 27001, Privacy Shield, and more.
- 20:28They'd love to give you a demo.
- 20:30Give Rollbar a try today.
- 20:32Go to talkpython.fm/Rollbar and check them out.
- 20:36So let's talk a little bit about how you built it, what technology is behind it.
- 20:40It's Python-based, right?
- 20:41Yes.
- 20:42So it's Python-based.
- 20:43It's Python 3.
- 20:44It actually started out with Python 2.
- 20:47I was still learning Python back then, and I just kept reading up on it.
- 20:51And I was like, wait, there's also a Python 3.
- 20:53And then I was looking more into it, and I was like, wait, Python 3 is the successor.
- 20:57And, you know, everybody is moving to Python 3.
- 21:00Even though four years ago, there was a lot more Python 3.
- 21:03It was still up for debate at that point, yeah.
- 21:05Yeah.
- 21:06But, yeah, it's starting to look out like a good choice for you at this point, right?
- 21:09Yeah.
- 21:09But I was looking at, like, different things, and I was reading about, like, well, there's
- 21:14no new features going to be added to Python 2, and Python 3 is being actively developed.
- 21:18And I was like, I got to make the switch.
- 21:20So I used, like, 2 to 3 tool, and I wrote it to Python 3.
- 21:24I didn't really have any users anyway back then.
- 21:27So I could do whatever I wanted.
- 21:29Yeah, breaking changes were allowed.
- 21:30It's fine, right?
- 21:31Yeah.
- 21:31And initially, it was actually all using threads.
- 21:34So I used the thread pool, and we had, like, whenever you would register for listening to an event,
- 21:41you would just register a function, and we would just pass that function and the event object to a thread pool.
- 21:46It would execute in a thread and be done.
- 21:49And this was actually caused sometimes, like, crazy deadlocks because, you know, there would
- 21:55not be enough threads.
- 21:56Some threads would be waiting for some work to be done, but that work would not be done because
- 22:00there were too many threads waiting for work to be done.
- 22:02It's a classic example.
- 22:04Those are hard.
- 22:05Yeah, those problems are hard to solve.
- 22:06Yeah.
- 22:07You know kind of what the problem is, but, like, tracing down the details can be painful.
- 22:12Yeah.
- 22:12Well, actually, the solution came by switching to AsyncIO.
- 22:17So nowadays, and I think, yeah, last year, we spent, like, over a year converting to AsyncIO.
- 22:24So I didn't know any AsyncIO, but there was this engineer from Mozilla, Ben Bangert, who was using AsyncIO at work.
- 22:32And he stopped by, and he was using Home Assistant, and he was like, our minimum requirement at that point in time was already Python 3.4.
- 22:38And he was like, if you're using Python 3.4, then AsyncIO is available.
- 22:43And with AsyncIO, it will be faster.
- 22:46There will be – we can avoid deadlocks, and it will be predictable.
- 22:51Because of all the logs and the threads, it was actually at a very unpredictable execution order.
- 22:55Sure.
- 22:56And at this point, it's waiting right at the network level, right when it's talking to the device or waiting for a response or something like this, right?
- 23:02Yeah.
- 23:03Yeah.
- 23:04With AsyncIO, you can just – you know, you pause within the work until you get, like, the next piece of information, and it can immediately execute.
- 23:11Yeah, it's really a nice way to add concurrency, the concurrency you were looking for in the Python 3 world or just the Python world, because you kind of don't have to deal with the GIL very much at that point.
- 23:23You don't have this thread overhead.
- 23:24You don't have the deadlocks that come with it for the most part.
- 23:27It's really nice.
- 23:27Yeah, I think that once – when AsyncIO was introduced to me, you know, initially when Ben stopped by and he said, you should use AsyncIO, I was like, yeah, okay, great, but I don't know how.
- 23:40And so, you know, you either come up with a PR or it's done, right?
- 23:44Yeah.
- 23:45And he actually delivered.
- 23:46He came up with a pull request.
- 23:48It was not fully done yet, but it was very exciting because I was actually learning something new in the Python world instead of, like, you know, every time I do a pull request against Home Assistant or code reviewing this, it was always, like, kind of the same kind of technologies.
- 24:00And so this was something new.
- 24:01And so we jumped on it and we managed to get the core converted to AsyncIO.
- 24:07And then over, like, the course of, like, eight months, we've been converting more and more core pieces of Home Assistant to AsyncIO, to which point now we're fully AsyncIO.
- 24:17Yeah, that's truly great.
- 24:19Did that lower, like, the types of devices that could run on?
- 24:25So before maybe it required, like, a PC, now it could run on, like, a small device or smaller devices than before?
- 24:32So we always ran well on a Raspberry Pi.
- 24:35So even though we had, like, tons of threads that did not, and the Raspberry Pi 3, at least, it was, like, running okay.
- 24:43But right now with AsyncIO, we run, like, blazing fast.
- 24:48So I think it allows us to even, like, allow for lower power devices to use those for Home Assistant.
- 24:56Yeah, I'm sure it really does make that more accessible.
- 24:58That's awesome.
- 24:59So that's the AsyncIO stuff is obviously, like, how you talk to all the devices instead of threads.
- 25:06What web framework are you using?
- 25:07Let me just say what we used before, and then I'll, like...
- 25:11So initially we started out with something I built myself on top of the standard library HTTP server, which is not a good idea, by the way.
- 25:19But for me it was kind of, you know, I never built a web framework, and I was like, we actually only have one route, which is the serving up the single-page application.
- 25:27So, you know, I'll just write something quickly myself, and then, of course, we needed more than one route, and then we needed SSL, and it became very messy.
- 25:37You're like, oh, what have I done?
- 25:37Yeah.
- 25:39Well, for a long time, Home Assistant was my place where I was practicing, like, you know, writing sort of new technologies and et cetera.
- 25:45And so this was kind of like, yeah, why not?
- 25:48But then we actually migrated, or somebody actually submitted a PR to migrate us to WorkZook, which is a whiskey framework.
- 25:58Yeah, part of Flask and all that, yeah?
- 26:00Yeah, it powers Flask indeed.
- 26:02And that was great.
- 26:03And so we were using it on top of threads.
- 26:06So we used the CherryPie wsgi server to power all of this.
- 26:11And then we were migrating to AsyncIO, and so when we migrated to AsyncIO, I was like, well, we need a new web framework.
- 26:18Yeah, because none of those do it.
- 26:20Yeah.
- 26:20No, so whiskey is not AsyncIO compatible.
- 26:23The way it's set up is it's all threading.
- 26:26And so people have explored seeing if they can make it Async compatible, and that's not possible.
- 26:32But then I stumbled upon AOHTP, and it's very difficult not to stumble upon it because they pretty much wrote the request for AsyncIO.
- 26:42So you cannot use requests either.
- 26:44So you have to use AOHTP.
- 26:46But it's a great, great library.
- 26:48It's super fast.
- 26:50It's actually powered by CITAN under the hood.
- 26:52So a lot of them are executed in C.
- 26:54And they did a great job.
- 26:56They wrote both the client and the server, and they have a framework on top of that.
- 27:00And so we were able to port our HTTP stack over to using AOHTP.
- 27:08And because we use AsyncIO, it was actually very trivial for us to add WebSocket support, for example.
- 27:13WebSocket support is an HTTP standard that starts as a normal request to your HTTP server,
- 27:20but gets upgraded to become like a long-living connection that you can send messages back and forth.
- 27:25Right.
- 27:26Normally, it's message to the web server, response from the web server, done.
- 27:30Yeah.
- 27:30Yeah, this is very difficult in a threaded environment.
- 27:33Because in a threaded environment, if you have like a worker per request,
- 27:37then all of a sudden that one worker is going to be occupied forever.
- 27:40And with AsyncIO, there's no such thing as the concept of a worker.
- 27:45There's just like tasks that have pending work to be done.
- 27:49So you can scale up way higher.
- 27:51Yeah, absolutely.
- 27:52I mean, that's kind of how Node.js got its, how it took off, like that type of programming model.
- 27:59It's really cool to see it here in Python.
- 28:01Yeah, and it's working very, very well for us.
- 28:04I think that like because of AsyncIO and you know that there is no concurrency,
- 28:08we actually managed to get rid of a lot of locks in our code.
- 28:12And, you know, when you read from a dictionary and then like two commands later you write to a dictionary,
- 28:17you know that no one else can mess with it.
- 28:20Which is, you know, so also we're having less weird bugs because these things can just no longer happen.
- 28:28Fewer Heisen bugs.
- 28:29Yeah, so between the awaits, like you have control over it.
- 28:35Very cool.
- 28:35All right, so that sounds like such a fun project to be working on.
- 28:39Are you looking for contributors and stuff like that?
- 28:42We have a lot of contributors right now.
- 28:44I think we do a release every two weeks.
- 28:46And we have between 50 and 60 people contributing code every two weeks.
- 28:51Wow.
- 28:52That's really awesome.
- 28:53Yeah.
- 28:53So right now it's just like, you know, keeping up with the pull request is the biggest challenge.
- 28:58Well, maybe you could have some contributors who just try to review the pull requests and just try to like mediate the bugs and feedback and things like that.
- 29:06Yeah.
- 29:06We have a few of those, but they are, you know, when you look at like open source contributors,
- 29:11the people that will help and like the code review and these kind of things, they're rare compared to like the people that will just submit a pull request and get their feature in.
- 29:21Yeah, of course.
- 29:22Of course.
- 29:23There's a lot of people who ask me like, hey, I want to get started in open source.
- 29:26Like what's a project I could just do something simple in?
- 29:29And so things like that, maybe if people are listening, they could come volunteer to review some pull requests or something.
- 29:33Well, I mean, I think if you get into open source, like coming in as like doing some code review definitely helps.
- 29:39But I think the best first step into open source is usually just making some contributions to the documentation.
- 29:46Getting like, because that way you also learn the workflow of a project, seeing like who works there and like even who works on it.
- 29:54And like even like if you hang out in the chat, you can like talk to them.
- 29:58And once you know the project better, then like start submitting some features, which makes it a lot easier.
- 30:03Just because in the end, like it's very difficult to, you know, get a pull request of somebody you've never spoken to who has like clearly put a lot of effort into a feature.
- 30:14And then having to tell that person like this feature is, we're not going to merge this because it's not going to work for like these use cases that you did not think of.
- 30:23Which if we would have spoken before for just like a minute or two, you know, I could have told you about this.
- 30:29Yeah, that's a really interesting point.
- 30:31It would be great if the whole GitFlow PR forking story had like a preliminary step before the work was done, before the PR was submitted.
- 30:42Like, I'm thinking of this.
- 30:44Prove my general idea, huh?
- 30:46Well, yes and no.
- 30:48Oh, because like sometimes you just, you're also doing it not per se for the project, but just for yourself to learn.
- 30:53And then at the end, you're like, oh, maybe, maybe this is valuable for someone else.
- 30:59Sure.
- 30:59But as a, you know, for me as a maintainer, it's, it's important that like, you know, when I accept a pull request, I also accept responsibility.
- 31:08Right?
- 31:09Because like when home assistant breaks, they don't come knocking on the door of that one person who submitted a pull request that contained a bug.
- 31:16No, they complain like in our chat room and in our forums on Twitter.
- 31:20So, and then we have to put out a hot fix.
- 31:23Which is, I'm sure, not fun.
- 31:25No, it's not.
- 31:26It's like, it's always hectic because you're like, okay, there's a lot of people angry.
- 31:30Well, we have a fix.
- 31:31Okay, good enough.
- 31:32And then we have to like have all the tests run and then push it to PyPy, update the forums, update the release notes.
- 31:39And it takes more work than, we've automated a lot, but still, it takes a lot of work.
- 31:45Yeah, even if maybe like rolling back documentation or something, right?
- 31:48Yeah, even reverse, it's like, becomes like a mess because you have like all these like, people that later want to like, revert the revert.
- 31:56It's a mess.
- 31:57I hear you.
- 31:58Okay, so let's talk about some of the devices you support.
- 32:00Let's go from the beginning.
- 32:02In the beginning, you kind of created this for yourself and you supported the devices you had, right?
- 32:07So where did it start?
- 32:08So it started with the Philips Hue light bulbs.
- 32:10So when they got released in the United States in, I guess, 2013.
- 32:15And that's when I, maybe, no, I think somewhere in 2012, end of 2012, they got introduced and I bought them.
- 32:24And I've been, since then I was playing with it.
- 32:26But I was just writing simple scripts to like turn them on, turn them off.
- 32:29Later, and it's slowly, that script, just for turning on and off, later, slowly has grown into Home Assistant.
- 32:38Because then I wanted them to turn on when I came home, but then I didn't want them to turn on when I came home and the sun was up.
- 32:45And so I have to keep track of more and more pieces of information.
- 32:48But yeah, the second thing I integrated was the Chromecast.
- 32:52So that's actually one of the best things I could have ever done because the Chromecast is really taken off.
- 32:58And it's actually the Google Home.
- 33:01It's also a Chromecast audio.
- 33:04So when you start Home Assistant, it automatically detects your TV if you have a Chromecast there.
- 33:09It will detect your Google Home, any other cast audio devices you have.
- 33:13And then when you start playing music on your Google Home, it will actually immediately show like the album art inside Home Assistant.
- 33:20You can pause and play it.
- 33:22And they have a great protocol where they push every state update to us.
- 33:26So the moment something happens on the Chromecast, we know about it in Home Assistant.
- 33:30Right.
- 33:30So there's not a latency of you pulling the thing or whatever.
- 33:33Yeah.
- 33:34Okay.
- 33:34So that's really cool.
- 33:35Those are some of the first two.
- 33:37Now you have more than a handful, right?
- 33:39Yeah.
- 33:39So right now we have over like 740 or something devices.
- 33:44And it just keeps growing.
- 33:45There's a lot of devices.
- 33:46Either very old ones like X10 support.
- 33:49But there are also things of like there was a South African contributor who had some South African startup IoT device in his house.
- 33:57And he wanted to integrate it.
- 33:59And so, you know, he submitted a pull request.
- 34:02And these are the kind of cases.
- 34:04And this has been like since the beginning.
- 34:06And this has been like since the beginning.
- 34:06Getting pull requests for devices that I cannot verify.
- 34:10It's always kind of like in the beginning I was like super scared.
- 34:13It's like, what am I doing?
- 34:14Like, how can I release to people code that like I haven't tested?
- 34:19Like I have to trust this random person on the internet.
- 34:22Not only have you not tested, you might be having to even really run it.
- 34:25Yeah.
- 34:25I mean, it's crazy, right?
- 34:27Yeah.
- 34:27Well, the way home assistant works, you know, I can verify in the code the way things get called to make sure that they don't do anything that goes against the design of the system.
- 34:37We've actually also put a lot of like warnings in place.
- 34:40And if certain fetching of certain things take too long, we'll print a warning.
- 34:44But the reasoning why I decided to actually accept these kind of pull requests is that for a lot of people, it's way easier to fix a bug than to add support for something new.
- 34:55So this one person might stop by and contribute support for like one version of a router, for example.
- 35:03And then, you know, we have support for this one version and someone else stops by and actually sees a bug.
- 35:09And that other person is super easy to just come in and fix one bug.
- 35:13And then someone else stops by and is like, oh, if you support this version of the router, well, with very little work, we can add this version of the router.
- 35:19And then, you know, it starts growing and growing.
- 35:22And we've seen this with like various of our supported protocols and devices where it just keeps growing.
- 35:29You almost get like many communities inside home assistant of like a few people who are rallying about the Sonos component or the Z-Wave component.
- 35:39Right.
- 35:39If their main passion is around the thing that they're integrating to home assistant, like they can form little sub communities around it, right?
- 35:47Yeah.
- 35:47Okay.
- 35:47Yeah.
- 35:48And I think this is the nice thing about home assistant is that there's a lot of open source software out there that you can't really use at home.
- 35:56Right.
- 35:56Because like there's some cool things like Kubernetes or like, I don't know, certain like web frameworks.
- 36:02But who writes a website for their house?
- 36:05Not too many people.
- 36:06Right.
- 36:06But if you want to at home and you want to play with things, the nice thing with home assistant is that it controls your house.
- 36:11So there's immediate results.
- 36:13And so there's immediate like, you know, satisfaction of your work.
- 36:17This portion of Talk Python To Me is brought to you by us.
- 36:21As many of you know, I have a growing set of courses to help you go from Python beginner to novice to Python expert.
- 36:27And there are many more courses in the works.
- 36:29So please consider Talk Python training for you and your team's training needs.
- 36:33If you're just getting started, I've built a course to teach you Python the way professional developers learn by building applications.
- 36:40Check out my Python jumpstart by building 10 apps at talkpython.fm/course.
- 36:45Are you looking to start adding services to your app?
- 36:48Try my brand new consuming HTTP services in Python.
- 36:51You'll learn to work with RESTful HTTP services as well as SOAP, JSON, and XML data formats.
- 36:56Do you want to launch an online business?
- 36:58Well, Matt Makai and I built an entrepreneur's playbook with Python for Entrepreneurs.
- 37:02This 16-hour course will teach you everything you need to launch your web-based business with Python.
- 37:08And finally, there's a couple of new course announcements coming really soon.
- 37:11So if you don't already have an account, be sure to create one at training.talkpython.fm to get notified.
- 37:17And for all of you who have bought my courses, thank you so much.
- 37:21It really, really helps support the show.
- 37:23Yeah, and it's pretty low risk, right?
- 37:27Because you can keep it behind your firewall on your router if you want.
- 37:30And it's really sort of just for you.
- 37:33Unlike a lot of the Internet of Things, they maybe have their own security issues.
- 37:39I mean, yeah, there's a lot of Internet of Things companies starting up all the time.
- 37:44And they put products out there.
- 37:46And they have a limited amount of time, a limited amount of money.
- 37:49So they will try to get to market super fast.
- 37:52And security is sometimes like an afterthought.
- 37:54Or after a couple of years, the company goes bankrupt.
- 37:58And either the cloud shuts down, your device doesn't work anymore.
- 38:02Or if the device works locally, it doesn't receive any security updates anymore.
- 38:07Right, which is just a ticking time bomb.
- 38:09But it's hard to know.
- 38:10Like my router at home, it has its little light.
- 38:15And it's green usually.
- 38:16But if there's an update for it, it'll start blinking yellow.
- 38:19Like, oh, maybe I should go look.
- 38:21But I don't know that it's not receiving updates if it weren't anymore.
- 38:25I just know when there is an update.
- 38:28I don't know that it didn't check anymore.
- 38:30You know what I mean?
- 38:31And so it's really hard to kind of understand that.
- 38:35But Home Assistant itself can run internally in your house.
- 38:40In one of these Raspberry Pis, if you want, right?
- 38:42Are there devices that you can get that's like a Home Assistant device?
- 38:47Or do I have to get a Raspberry Pi and set it up?
- 38:50Do I have to 3D print a thing?
- 38:51Or what's the story about that?
- 38:53Right now, we're just an open source project.
- 38:56And so we don't have any devices.
- 38:59We kind of focus on the Raspberry Pi.
- 39:02From the statistics that we get, we see actually 70% of our users on Raspberry Pi.
- 39:07But to make it easy, we're trying to slowly get to where we can either have Home Assistant devices or have a better experience.
- 39:16So we're working on, we just released today actually, has.io, which is our new operating system for Raspberry Pis.
- 39:24Yeah, that's a huge announcement.
- 39:25This is like a brand new thing.
- 39:27It's not just like, oh, here's some feature.
- 39:28There's a whole new operating system for it.
- 39:30Yeah, yeah.
- 39:30So it's not a 100% operating system.
- 39:34Like we built from the ground up.
- 39:35We based it on a Raisin OS, which is an open source operating system to run Docker containers on embedded devices.
- 39:43And so we use Docker and Raisin OS with SIO to allow a user to flash this to their Raspberry Pi and no longer have to worry about system updates or updating Home Assistant.
- 39:55All these kind of things can be done from the user interface.
- 39:58Yeah, that's awesome.
- 39:59Yeah.
- 39:59And so this is going to be our approach to kind of get the next so many users because right now our user base is very much, you know, do it with yourself, people, people that know programming, people that were comfortable enough to get a Raspberry Pi, open a terminal SSH into the Raspberry Pi, these kind of things.
- 40:18Previously, like the setup story was SSH in there, create a virtual environment, pip install some requirements.
- 40:25Like it was like that level, right?
- 40:28And now with this announcement, Haas.io, like it's like a web interface that controls and configures and extends Home Assistant, right?
- 40:35Yeah.
- 40:36So right now you, once you download Haas.io, you flash it to an SD image and you write, you'll have to edit one text file on the SD image to have it connect to your Wi-Fi if you want.
- 40:46But you can, of course, also plug in an Ethernet cable into your Raspberry Pi.
- 40:50But the moment you start up your Raspberry Pi, it will download the latest version of Home Assistant.
- 40:54It will update the operating system to the latest version.
- 40:57And you're good to go.
- 40:59Like after 20 minutes, more or less, it will start up Home Assistant.
- 41:04Home Assistant will start automatically discovering which devices on your network that it knows how to set up automatically for you.
- 41:11And you can start automating things.
- 41:13Yeah, that's, that sounds really cool.
- 41:15So that's, I'm sure that's going to increase adoption.
- 41:18And you had said in the early days you wanted to kind of keep it to this techie crowd.
- 41:22And it feels like this is a major step to like make it general consumer type stuff.
- 41:26Yeah, it was.
- 41:27So we used to like very much keep it focused on just the techie crowd because, you know, when something breaks, they can also contribute back.
- 41:35But we were, we've grown so big now.
- 41:37We have so much momentum that like, you know, it's a pity if we keep this away from other people as well.
- 41:43So we want to have more people like exposed to it and more people using it.
- 41:47And I think, you know, if you look at like the amount of integrations, we support so many things that, you know, we want to get more people on board and like even get more integrations and, you know, become like the ultimate home automation hub that you can run locally.
- 42:02Yeah, that's awesome.
- 42:03You have a lot more integrations than many of the, even the commercial ones, right?
- 42:08Yes.
- 42:08Yeah.
- 42:09But that's actually, it kind of makes sense.
- 42:11As in from the commercial ones, they probably have partnerships with those other companies.
- 42:17They have, you know, they will test it every time there's one of those companies will update a new product.
- 42:22They'll have to make sure it's integrated and those APIs have to stay stable.
- 42:25And we have just like an unlimited size army because we're open source.
- 42:30And so people will consume any API that's out there and integrate it into a home assistant.
- 42:36And people are, you know, it's running in their house and they depend on it.
- 42:39And so they see it's breaking or an update coming up, they will submit a patch to home assistant so that we are also, you know, we're always on the latest.
- 42:46Always on the latest APIs and always getting better.
- 42:50Yeah.
- 42:50It's really a testament to the power of open source.
- 42:53Like all these people, they have one device.
- 42:55They have some technical skills.
- 42:57They really want that one device to go in with the rest of their devices.
- 43:00And so you can't do that at a commercial one.
- 43:03You can just send them like a support request.
- 43:04Please support this device sometime soon.
- 43:07Yeah.
- 43:08I like it to, you know.
- 43:09Yeah, exactly.
- 43:09And, you know, one other strategy that we've had since the beginning is that we've always made sure that whenever anyone contributed support for a device, that the support itself was actually contained in a standalone Python library that was published to PyPy.
- 43:24That way, if you don't want to use home assistant but you still want to use that one device, you could still use that library and even end up maybe making improvements to that library or fixing bugs that we then also can consume inside home assistant.
- 43:37Right.
- 43:38And that's the way it's still set up now?
- 43:39Like all these integrations are separate?
- 43:40Yes.
- 43:40Every, yeah.
- 43:41Because if you look at other home automation, even open source ones, they have all this protocol logic inside their own code base.
- 43:49And it's all coupled with their own way how they are doing things.
- 43:52And so it makes it difficult to use that code for our project, for example.
- 43:58Sure.
- 43:58So what's the story of if I want to, suppose I get a device that's not supported, I want to add support through it.
- 44:05Take me through the steps of like how do I add a new device to this?
- 44:08Well, first you start reading the documentation.
- 44:10For home assistant, right?
- 44:12For home assistant, yeah.
- 44:13No, I think the first step is to see if this device has an API.
- 44:18Okay.
- 44:18And this might either be a public API or if they have a mobile phone app, some people will use something like Wireshark or something to check out the protocol.
- 44:28For most things out there, there will be someone who has already done this.
- 44:31You can find like maybe there's a package for Node, maybe there's a package for Python already.
- 44:36So actually for most things that you want to integrate, you'll find a library ready to go.
- 44:40If you have to write one yourself, you'll have to like use those API dumps or their public API to talk to the device.
- 44:47So once you have a library that can talk to the device, it will be very easy to integrate into home assistant.
- 44:54So anything that you want to integrate into home assistant is actually based on classes.
- 44:58So we have, for example, a switch class.
- 45:01And so you would just extend the switch class.
- 45:03And then we use the Python properties, class properties.
- 45:07So you have a property name where you return the name of your device.
- 45:11You have a property is on that will return a Boolean if the switch is on or off.
- 45:15And then you have two functions, turn on and turn off.
- 45:18And if you implement those to fire the correct commands to your device, they're already in.
- 45:24That's it.
- 45:24Yeah.
- 45:25Yeah.
- 45:25That's awesome.
- 45:26And all the, to integrate a device, you only have to integrate this class and all the things under the hood,
- 45:32how like the state machine has the representation and the event bus, all those things you don't have to worry about.
- 45:38Those things are abstracted away.
- 45:39They work with your, yeah, they work with your abstract base classes and you don't care.
- 45:43Yeah.
- 45:44Nice.
- 45:44Do you have like multiple inheritance, like something is a switch and it's color adjustable or something like this?
- 45:49No.
- 45:50So we, the abstract base class of a switch will have, well, color adjustable would mean that like it's actually a light.
- 45:58So the switch will have features that are not supported by every device that implements an abstract base class of the switch.
- 46:05And so we have this property called supported features, which is using like integer bit flags to say which features are supported or not.
- 46:13And that's actually not being used inside home assistant Python, the core, because if you call turn on and you can pass in the color, it's up to the implementation.
- 46:24You know, they can just decide not to use the color.
- 46:25Right.
- 46:26But the front end will, you know, we have a web interface to control everything.
- 46:30And the front end, for example, for light that does not support colors will not show a color picker.
- 46:35Right.
- 46:35Okay.
- 46:36Cool.
- 46:36Yeah.
- 46:37That makes a lot of sense.
- 46:38So that sounds pretty easy.
- 46:39If you can talk to the API, you can implement a couple of methods on an abstract base class.
- 46:44Like it doesn't get a whole lot easier, right?
- 46:46I think for like a sensor, if you want to add like a sensor, which is a read only piece of information that you want to pull into home assistant, you can do that in like 20 lines.
- 46:56Sure.
- 46:56Wow.
- 46:57Yeah.
- 46:58So that's hopefully that's encouraging people to go and integrate something maybe that isn't in that 740 devices.
- 47:05Yeah.
- 47:06If people are interested in like adding things to home assistant, I gave a talk at PyCon in Portland last year, 2016, about like, first it describes how home assistant works.
- 47:17And then the last 20 minutes is how I'm writing a sensor and a switch from scratch that actually interact with the file system as a demo.
- 47:25Okay.
- 47:25Yeah.
- 47:25So check that out if you want to get started.
- 47:27That's really cool.
- 47:28So I saw that you have kiosk mode.
- 47:31What is that?
- 47:32Yeah.
- 47:33So actually recently, well, it's not recently.
- 47:35It's been for a while now.
- 47:37People, because they invest so heavily in home assistant, so they have home assistant like controlling everything in their house.
- 47:43And they ended up installing home assistant on tablets and having those tablets being mounted to walls at the entrance of their house or like somewhere else in the house.
- 47:52And so people were like, you know, the normal home assistant user interface is not optimized for being on a tablet on a wall, which is where you expect like big buttons.
- 48:01We are, our user interface is optimized for mobile phones.
- 48:05And so you have, you know, it looks like material design.
- 48:07You have like the small toggles that you need like a finger and like you need to be close to like, you know, you need some form of precision.
- 48:15And so for the wall mounts, people are like, well, we need a better approach.
- 48:20And so we have support for custom panels in home assistant.
- 48:23So people were writing pages that would already show like bigger buttons or show like a whole floor plan of the house and show like where in the house, which lights are on and which doors are open.
- 48:34But the kiosk mode now will actually take it one step further.
- 48:37We'll make sure that the bar on the top is hidden and that the menu is no longer can be opened.
- 48:43And that way you really have just like a terminal that like controls parts of your house and people cannot like go to the settings and start changing things.
- 48:52Yeah, that sounds really cool, actually.
- 48:55So like that's your public one.
- 48:57And if you really want to change it, you pull it up on your laptop or something.
- 49:00Yeah.
- 49:00Yeah.
- 49:01Okay.
- 49:01Well, that makes a ton of sense.
- 49:03So I was thinking of the things that I could automate in my house when I was getting ready to talk to you.
- 49:11And to be honest, I don't really have many smart things other than like my phone and my laptop and my kids phones and whatnot.
- 49:18We do have on our doors, we have a keypad entry for all the doors.
- 49:21So we don't use keys, but they're not they don't have Bluetooth or anything.
- 49:24They're just literally like a keypad.
- 49:26But one thing that I am getting is I'm getting an electric car and it has one of those 240 volt charging units.
- 49:35And that thing has like an app and it has wireless connectivity.
- 49:41Like, do you integrate with those types of things?
- 49:44Do you know?
- 49:44Or is that a PR I should be adding?
- 49:47That's probably a PR.
- 49:49I mean, we have well, we have support for Volvo.
- 49:51So Volvo has like an app for their cars where you can see where the car is.
- 49:55And I think you can see the mileage and how much gas you have left.
- 49:58And we actually integrate home.
- 50:00The home system has support for Volvo.
- 50:02So you can like see everything in Volvo.
- 50:04So depending on the make and model of your car, there might be already.
- 50:07Yeah.
- 50:08So I'm thinking of getting a Bolt.
- 50:09I mean, I would love to get a Tesla, but you know, I'd also love a Ferrari.
- 50:13Like I can wear things.
- 50:14No, of course.
- 50:14I don't think we have support for a Volt yet.
- 50:17But if they have an API that is either accessible or even public accessible, then it should be very straightforward to add support for it.
- 50:25Awesome.
- 50:25Well, maybe I'll do some kind of PR for you.
- 50:28Because, yeah, it's supposed to have like I don't have it yet.
- 50:30So I don't know, but it's supposed to like go on the Wi-Fi and talk to your app and like warm it up before you go outside.
- 50:35Like things like that.
- 50:36Wow.
- 50:36Well, I think there's this, you know, there will be also like nice things to do.
- 50:40Like, for example, reminders to charge it, for example.
- 50:43Like, hey, you were running low when you came home, but you didn't plug it in.
- 50:47Yeah.
- 50:47Yeah, for sure.
- 50:48It's I know it's on the Wi-Fi and it's low.
- 50:50So you better go pay it at some attention or something like that.
- 50:53Right.
- 50:53Yeah.
- 50:53Awesome.
- 50:54All right.
- 50:54Well, that sounds really, really cool.
- 50:55So let's talk about just a few other things.
- 50:57We're getting short on time here.
- 51:00You have just recently started a full on home assistant podcast.
- 51:04Why don't you tell people what that is, what it's about, how they can like subscribe to you?
- 51:09Yeah.
- 51:09So this is three of our community members started this project.
- 51:13And they it's all about home assistant and things around home assistant that are happening in the IoT space.
- 51:20We are at episode four or five now.
- 51:22I think episode four was just launched.
- 51:23Yeah, I think so.
- 51:24Yeah.
- 51:24Yeah.
- 51:24And it's all about each episode.
- 51:26They try to invite other members of the community that are either doing very cool stuff with home assistant.
- 51:33So I think the last episode there was Carlo who has automated his whole house with Alexa and home assistant to control everything.
- 51:42Where even like if he lives in Florida, so if he left his door open for too long, text to speech, the house would say to everybody inside, oh, there's a door open.
- 51:51So I'm going to turn off the air conditioning now.
- 51:52Good luck.
- 51:53I was there on episode three.
- 51:56And so they keep talking to other members that are like developing the latest, greatest features for home assistant and kind of like thinks how to use it.
- 52:06And it's getting quite some popularity.
- 52:09I think the first episode had like 2,500 listeners or something.
- 52:14That's amazing for the first episode.
- 52:16Yeah, that's awesome.
- 52:16So it's really great.
- 52:18If people are interested, the URL has podcast.io.
- 52:22But every episode is also promoted on our blog and Twitter.
- 52:26Right.
- 52:26Yeah.
- 52:26And I subscribe to it.
- 52:27I just went to Overcast and I typed home assistant and boom, home assistant podcast came straight up.
- 52:33So yeah, that always works as well.
- 52:35I'm sure it's on Google Play in addition to that.
- 52:38Cool.
- 52:38All right.
- 52:39So that's really awesome.
- 52:40And you guys have t-shirts.
- 52:41Is that right?
- 52:42Yes.
- 52:42If I want to automate my home and then like get people to ask me questions about it.
- 52:46Yeah.
- 52:46So we've been selling t-shirts since I guess somewhere in the beginning of the year.
- 52:52Maybe a bit around the time, I think.
- 52:55Yeah.
- 52:56And the t-shirts we have right now, 100% of the profits are being donated to the Electronic Frontier Foundation.
- 53:02That makes it easier for us to not have any, to do anything with like income and taxes and all that stuff.
- 53:07You know, we also support the Electronic Frontier Foundation, which they're doing awesome work.
- 53:12Among others, they provide, they started the Let's Encrypt service so that everybody can have an SSL certificate, which a lot of home assistant users are using.
- 53:20Yeah.
- 53:21With your house.io, that's like a checkbox or something, right?
- 53:23Yeah.
- 53:24Yeah.
- 53:24We make it super easy to get an SSL certificate to secure your connection to your house.
- 53:29That's cool.
- 53:30Yeah.
- 53:30Yeah.
- 53:30Very, very cool.
- 53:31All right.
- 53:32Well, it's super exciting.
- 53:35I need a smart thing so I can start playing with home assistant.
- 53:40Maybe more than one.
- 53:42I would start with just a Chromecast for television.
- 53:44Okay.
- 53:45Because the nice thing about the Chromecast is that it doesn't have a dedicated app that you need to control.
- 53:52The Chromecast is built into the Netflix app, the Spotify app.
- 53:56Let's say your browser, you open YouTube and all of a sudden it has a button, play on my TV.
- 54:01Yeah.
- 54:01In your phone, it will be like, show my screen on the TV.
- 54:04Show my photos on the TV.
- 54:06It's a very powerful little device.
- 54:10And it's like very cheap.
- 54:12I think it's like 35 bucks.
- 54:13Yeah.
- 54:13It's incredibly cheap for what it is.
- 54:15Yeah.
- 54:15Sounds very cool.
- 54:16All right.
- 54:16That's a great place for people to get started.
- 54:19All right, Paulus.
- 54:20Before I let you out here, let me ask you the two questions we always ask at the end of the show.
- 54:24One, if you're going to write some Python code, what editor do you open up?
- 54:27I use Sublime Text.
- 54:28Okay.
- 54:29Sublime.
- 54:29Definitely a good choice.
- 54:30It's very fast.
- 54:32And it doesn't do too much, but it does enough.
- 54:35Sure.
- 54:35Yeah, absolutely.
- 54:37That's cool.
- 54:38And you've got quite a few lists to pick from, like maybe 741 at least.
- 54:43But how about a notable PyPI package?
- 54:46Well, actually, I mean, I was thinking about this question before the show started, like what's one that I really like?
- 54:52And actually, it's one that's now part of the – I really like AsyncIO.
- 54:56And I know it's now part of the standard library, but I think that asynchronous programming sounds so magical.
- 55:02But if you actually start looking at the source code, it's super, super straightforward.
- 55:06It's just like it has a list of tasks.
- 55:09It has every task.
- 55:09Do you have something to do?
- 55:10Okay, do it.
- 55:11And then it just keeps – it's pretty much like a while through.
- 55:15And it just keeps going through this list of work.
- 55:17And the fact that it gets to the basic – it's so basic from the core.
- 55:21And it, like, makes such a powerful paradigm possible is just amazing.
- 55:26Yeah, that's a really interesting point about how that simple paradigm really opens things up.
- 55:31And, you know, even like you said, simplifies, removes a whole class of bugs for you guys.
- 55:36Awesome.
- 55:37All right, so final call to action.
- 55:39People are interested in this.
- 55:41What do they do?
- 55:42Get a Raspberry Pi, get a hash.io, and just get up and running.
- 55:47And then there's some great documentation.
- 55:49We've got some great videos how to get started.
- 55:51And if you run into any trouble, make sure to stop by our Discord.
- 55:55It's our chat community.
- 55:57And it's where a lot of people hang out.
- 56:00They're helping out other people to get started and discuss home automation.
- 56:04All right.
- 56:04Sounds great.
- 56:05I'm looking forward to playing around with it.
- 56:07Paul, thanks for being on the show.
- 56:09It was great to chat with you and share your story.
- 56:11Yeah, it was awesome being here.
- 56:12Thank you.
- 56:14This has been another episode of Talk Python To Me.
- 56:17Today's guest was Paulus Shralson.
- 56:20And this episode has been brought to you by Rollbar and Talk Python Training.
- 56:24Rollbar takes the pain out of errors.
- 56:27They give you the context and insight you need to quickly locate and fix errors that might have
- 56:32gone unnoticed until your users complain, of course.
- 56:36As Talk Python To Me listeners, track a ridiculous number of errors for free at rollbar.com slash
- 56:41Talk Python To Me.
- 56:42Are you or a colleague trying to learn Python?
- 56:45Have you tried books and videos that just left you bored by covering topics point by point?
- 56:49Well, check out my online course, Python Jumpstart, by building 10 apps at talkpython.fm slash
- 56:55course to experience a more engaging way to learn Python.
- 56:58And if you're looking for something a little more advanced, try my Write Pythonic code course
- 57:03at talkpython.fm/pythonic.
- 57:05Be sure to subscribe to the show.
- 57:08Open your favorite podcatcher and search for Python.
- 57:10We should be right at the top.
- 57:11You can also find the iTunes feed at /itunes, Google Play feed at /play, and
- 57:17direct RSS feed at /rss on talkpython.fm.
- 57:21Our theme music is Developers, Developers, Developers by Corey Smith, who goes by Smix.
- 57:26Corey just recently started selling his tracks on iTunes, so I recommend you check it out at
- 57:30talkpython.fm/music.
- 57:32You can browse his tracks he has for sale on iTunes and listen to the full-length version
- 57:37of the theme song.
- 57:38This is your host, Michael Kennedy.
- 57:40Thanks so much for listening.
- 57:41I really appreciate it.
- 57:42Smix, let's get out of here.
- 57:45Smix, let's get out of here.
- 57:45Stay tuned.
- 57:47Stay tuned.
- 57:47Bye.
- 57:48Bye.
- 57:50Bye.
- 57:51Bye.
- 57:52Bye.
- 57:53Bye.
- 57:54Rock the best.
- 57:54First developers.
- 57:56First developers.
- 58:03Developers, developers, developers, developers.
- 58:07you
- 58:07you
- 58:07Thank you.