Cloudflare TV

Teaching an Old House New Tricks

Presented by Tom Lianza, Larry Archer
Originally aired on 

Two Cloudflare engineers discuss smart home gadgets and home automation -- from lights that turn themselves on when you walk into a room, to a garage door that tells if you if it's left open too long (and can even close itself), and more. Bonus: how to use Cloudflare Access and ArgoTunnel to protect your home's web-based control panel.

Cloudflare Access

Transcript (Beta)

Hi, I'm Tom Lianza and I'm here with Larry Archer and we are going to talk about home automation and I'll start with just my background.

I'm an engineering director at Cloudflare.

This has been something that's interested me for quite some time, but I've never gone quite as deep down the rabbit hole as Larry has.

So it's mostly me learning from him and us all learning from him.

And also I can fill in around the edges with what mere mortals might do with home automation.

Hi, I'm Larry Archer.

I'm an engineering manager at Cloudflare. I've been an engineer gosh, probably my whole life.

So that's part of the reason I'm into this kind of thing, I think.

So, yeah, this will be fun. Where should we start?

Maybe I guess we should talk about what what we mean by home automation or smart home stuff.

I kind of think of it as anything that can make your home a little easier to use or these days, it's like anything that you can connect to the Internet, connect to the Wi Fi in the house, but Yeah, I think we both got started at this kind of stuff way before the term Internet of things came about.

Yeah, my interest has definitely been about using computers to help help me with my life more in the physical world, not just while I'm sitting on a computer.

Now, when I started tinkering I even with with computers.

Generally, I was pretty all in, you know, build your own computer.

I remember building a myth TV set up back in the day. I don't know the state of that project.

Everything I did was Gen Two because I felt the need to build everything.

And then over time, it's just like the the products I wound up with the things I ended up building that and pieces of hardware and software I use just They needed a lot of care and feeding and it was on me to care for them and feed them.

And I just started to sort of pull out. And now a lot of my what I do what I tinker with this is more off the shelf.

And then a little bit more limited. Yeah. Yeah, I remember I'd forgotten about myth TV, but I had a box like that too and Getting your own tuner card working man.

That's a whole other Right, but Then they once HDTV came out, it was a little different and everything else online.

Now it's so much easier.

But, um, yeah, I think my Thinking X 10 was probably the first time I like purchased hardware to do anything with home automation.

So you could like It was basically remote controls, which was pretty cool.

At the time, you just press a button and your living room lights.

Come on, or you walk around with something on your key chain and And turn the lights on and off going even farther back.

I remember as a kid, my dad had timers those little timers you plug in turn the lights on to make it look like you're home or something, but Yeah, when I first got the extent thing.

I came with a little serial port dongle. That you just plug in and would send the same radio signals that the that the little remote had but And it was kind of neat that somebody had written a Linux command line tool for it.

So you could I think it was called bottle rocket or maybe that was the name of the dongle, but it was just a command line tool, you could send it the same signals and And from there you could you could script things like set up a cron job to turn on your lights and stuff or to control it remotely over a web page or something like that, but Yeah, I never had a great deal of satisfaction with my X 10 experience.

contributed to turning me off of At least do it myself. Yeah, I had. Yeah, I probably Spent longer than maybe was wise with that type of hardware even like when as far as installing switches in replacing switches in the walls with One place that lived and I remember taking it apart.

One day after taking the switch apart after had stopped working one day.

I was like, oh, that's That explains a lot. Just the quality of the components in there.

Maybe it wasn't. Maybe an off brand switch even but And then after a while I got back into it and it's like, what's, what else is out there.

What's the Standards and actual More commercial grade or Or industrial strength hardware out there and Somehow I settled on Z wave switches and lights and things and installed a few switches like that and I guess to To be able to control the wave stuff.

You need a controller. So I had a Hardware little box that plugged in connected to an ethernet port and then you give you this web interface that you could You know again schedule things set up little basic rules like if this happens, then do this other thing And that was kind of neat for a while, but the web interface was a little little clunky At that point, were you using the Internet for stuff or is it all local?

It was mostly local like I've never been a huge fan of connecting something up to the Wi-Fi and then letting it connect to the cloud and then trusting some other company to or some external entity to have control over that even if It's like oh you need to log into it to get to this or or they say it's locked down or something But I don't know.

Maybe I'm paranoid Maybe in a good way.

So yeah the stuff I've had It's been locals like you plug this in you get to it from your Wi-Fi They tell you how to expose it to the Internet or something.

I was like, yeah, I'll just do it locally that's fine, or maybe set up a VPN to my home network or something, but There are better ways than that now So that's after that one.

This was a thing called Vera. I Went looking like what other software is out there and I found this thing called home assistant Which is a open source project.

It's written in Python and it's I Actually, I should have checked.

I don't know how long it's been around but it's been around a while.

It's got lots of contributors I think there's even a commercial product or two based around it, but it's very broad it You can connect z -wave stuff to you can connect x10 stuff to it.

You can Connect other more Easier to use can consumer facing things like the Wi-Fi light bulbs like Phillips So, but it sounds like what you're with the open source community and the project you're you're talking about Yeah, and if you've got the time and the The expertise you could you could even write up your own Component for this so it can talk to some other some other thing and obviously lots of people have I guess the other Backing up a bit back to the hardware some of the other stuff.

I've done besides just like lights Motion sensors and door sensors.

So like things that send a signal when the door opens or closes and then a thermostat a While ago the the city of Austin started giving rebates for smart thermostats and whether or not they're connected to the Internet and I Got one not a nest but another brand and I'm not even sure they're around anymore But it's a it's it's got its own rest API that you can hit over the local network again Keeping the all the control local and there's even a home assistant plugins for that So it's all you can you can tie it all together From a hardware perspective one of the things so much of its wireless except of course power and so there's there's always to me a Or unless you want my I feel like if I put a battery in something and mount it to the wall It's just inevitably a chore Done by me.

So when it comes to Windows switches and stuff like that, do you adore?

Do you end up having to wire them in or how do you the ones I have are all battery powered and things have gotten a lot better like the old x10 ones were like Okay, put two double-a batteries in this and then you end up changing it.

Yeah, like every month or two Depending on conditions and things but the door sensors I have now are z-wave and they they're powered by a small lithium battery which I think they claim lasts about a year.

That's sounds about right to me. I haven't I don't remember the last time I changed any of those so maybe I haven't had them that long.

So maybe a year or two We also have a Deadbolt on our door that's z-wave but that takes four double-a batteries, which that's probably the most annoying one.

You have to change it every Every few months or so But it's nice You might go into this but that's the deadbolt is one of my worst fears, too I assume when the battery dies, there is still a way to open your door.

Yeah, so the one I have it's The key is still there the the lock is still there So it's got a keypad on the outside you punch in the number and it unlocks it for you or you can send a signal Over z-wave and have it have it unlock But it's still got a key in there so as long as you you're not completely relying on it bring bring keys with you you can you can get back in and it it's a I think it's conservative in how much battery it thinks it has left So it will beep and not let you lock it again if the batteries are too low.

So So you it tries to not let you lock yourself out but Yeah, that might be a good time to talk about some of the other things that are going on the other stuff I've done with it and then Do some show-and-tell stuff.

But uh, so one thing I did with the that z-wave deadbolt, which I don't have turned on right now is So you've got motion sensors.

You've got other things you can tell this system lets you tell if a certain person is in the house or not based on something like oh your phone is on the Wi-Fi or your You sent a Bluetooth signal from some Keychain dongle or something.

It says okay your home So for a while, I had it set up. So when my phone got on the Wi-Fi and then the motion sensor at the front door Triggered within a minute or two.

It would say oh Larry's home and it would unlock the front door for me as I was walking up the sidewalk, which Really amazing and neat but also a little bit scary because like if that Doesn't work perfectly and it opens the door in the middle of the night for somebody else and that's that's not great.

So that one's not turned on anymore, but it's like one of the Examples of like you can chain all these little conditions together and stuff like that.

So Yeah, make sense the First scenario, I've never owned a home until just recently and the first scenario I was kind of excited about was just was that sort of proximity unlock but then a million scary situations, right?

Yeah, especially a Lot of the stuff I do is voice is voice enabled with the Alexa speaker or the or the Google now I shouldn't have said that word probably other people's devices just And You know telling a speaker to unlock your door sounds like a recipe for Someone to walk by your window and and ask just ask to come in doors You know, it seems like you got to be with great power comes great responsibility, yeah Yeah, again, I don't want Didn't attend for this to be like a home assistant commercial, but it's got plugins for for that, too For different smart speakers and stuff so you can I'm not sure like the actual state of it now, but at first it was pretending to be another bridge like So you could tell like hey It would pretend to be like light switches and you could give it different names and say hey smart speaker do this turn on this light Set the thermostat to whatever So, yes, let me share my screen here and we'll Take a look at what my dashboard that's another Kind of wild but a neat thing about a tool like this is a It gives you a dashboard of your house or of all the stuff in your house So and this one is home assistance really great.

You can go in here and configure everything through the UI When I first started using it, most of the stuff was like, okay if you want This panel on that panel and these different tabs to show up go edit this yaml file.

I mean everything is yaml, right? And and configure all this stuff through the yaml and it's it's really evolved and grown it's it's kind of amazing all the stuff you can just click and configure now, but So this is just a few of the things I've got in here so if I Yeah, if I go click this my light over there is is there should be turning on I can lock the front door from there and it hooks into like dark sky for weather And yeah, it's it's Texas here so it's it's hot outside What else Another really neat thing about it is it it records all this data.

So Right here. This is the thermostat you can see when it's green The air conditioning was on and you can see what the temperature was what it was set to All kind of stuff like that So to what extent for these things I see freezer air conditioning to what extent are you Choosing sort of products that's that integrate with this versus bolting the this Onto products that may or may not have any awareness that they're smart.

It's In our house. It's definitely a mixture of the two.

So thermostat is a I think the company's called radio thermostat and there's a home assistant plug-in for that and that's Uh, it works great.

You just tell it here's the The IP address of your thermostat it talks to it and collects the data The freezer and the refrigerator temperatures.

Um, that's something I cooked up on my own.

So that's the other reason I I'm into this stuff. It's like a good Uh way to focus projects and we'll do little programming and hardware projects so I'd For that I took a raspberry pi and some usb temperature sensors Uh, so it's sitting on top of the fridge and the the wires go into the fridge in the freezer and then there's a a little python script that pulls the temperature sensors and then Publishes those those sensor values onto mqtt Bus so I think it used to be built in but now now it's not but I have there's a mqtt thing.

Uh, Trying to remember what mqtt stands for I see a message queue. It's yeah, it's a it's a thing.

That's uh used a lot in Internet of things applications, it's just a It's got topics and values and you publish a value onto a certain topic And that's it and other things can subscribe to that and there's just You just get the latest the last one published on there.

So it says uh, we can even look at the uh Thank you.

Telemetry transport telemetry. Yeah, so If you go in here and edit you can see what this one is Okay, so it's a little bit deeper than that, but so there's a sensor object in the In home assistant, which is wired into a mqtt topic, which is like house kitchen freezer or something like that uh I forget what I made but so it just publishes that and then uh home assistant listens to the mqtt bus and And records the temperature.

Um Yeah, so that is there Have you experienced value from having a Recorded history of your refrigerator's temperatures over time When I did this I was like, oh, this will be cool.

I'll get these neat graphs and like but what's the point really?

but then Uh, I think it was last year sometime our freezer stopped Like would was starting to do weird things.

It was like this is not freezing all the time. Uh I was like what's what's going on with this?

So, um, I think and that's when I I had this idea like okay I could wire up a temperature sensor to the freezer, but I hadn't done it um And that's and so I set this up and finally got it working and you could actually see uh, this is a screenshot from The the logs the data from sometime last year and Most of this is like normal defrost cycle so that the freezers uh It heats up every once in a while to make sure that frost doesn't build up right like a Unless you've got a deep freeze.

That's uh, that's what freezers do but then Every once in a while I had this spike up to 40 That's 42 degrees fahrenheit or something like that.

It's like that's that's weird. Why is it doing that? So um It didn't Immediately tip me off to the problem, but it was like okay something's for some reason it's it's defrosting too hard Or too much at certain intervals.

So I was like, okay, it really is broken.

It's not just the ice cream seems a little soft it's Something's weird.

So this was It was actually really useful to have this this data and say okay Yep, something's going on and I can see the patterns.

This is a A more recent one and that's like normal It gets up to 25 or so and then then freezes back down to negative two or something like that.

So It's interesting. It also seems like um Now seeing the data You could you could know if someone left the fridge door open or something.

I'll almost alert on it even. Yeah fridge exactly and I so the fridge we got as a replacement for that one that stopped freezing, uh actually has a beeper on it if you leave the door open too long, but uh Yeah, I could do that and you can actually see uh So the um those graphs I showed you earlier come from Home assistant's own little grafana instance um, so Let me back up a little bit how much time do we have?

10 minutes 10 minutes more. Okay Home assistant is this uh, it's not just a platform to talk to us all those all these different components and stuff.

It's got um, Uh, this specifically is a thing called home assistant They changed the name recently it used to be hasio h-a-s-s-i-o um, but it's like this home assistant os I think is what it's called now and it's um like an image you can install on a raspberry pi or a virtual machine or anything and it's got a docker and Containerized everything and so as in addition to this core the dashboard and all the controls and stuff you can Install All these add-ons and one of the add-ons is and these run as like docker containers alongside the home assistant core So you've got i've got influx db and and grafana for like long-term metrics of all this stuff, uh What else in there, um I want to make sure to talk about this one too, which is kind of neat, but we'll come back to that the argo tunnel plugin, um so yeah, it's got grafana in there and you can you can uh, look around and see i'm gonna see if we could uh, See somebody leaving the door open on the on the fridge Probably something like that, but I wonder if even opening it registers or if it's so quick if it's just like open and close it's fine, but if it's like Like yesterday.

Oh the drawer came loose and I had to leave it open for a few minutes and you could see it uh I think that's probably no, that's a regular defrost and you can see how the Like it's only one cooling unit in the fridge.

It's uh So the fridge and the freezer are tied together when they move in lockstep.

It means it's probably Yeah, the device you've only got one one compressor in there or something, but um anyway So yeah, uh all kinds of neat stuff.

I get the other problem. I think I actually this is not data, but uh The thing that was actually useful uh from this was uh, and one of the reasons I started to get into it was I'd leave the garage door open like go home Park the car leave the door open and then wake up in the morning and the garage door was open all night It's like oh geez, that's not good or we'd leave the house and forget to press the button and it would stay open or At one point it would close and then open because the sensor was broken.

So I set up an alert that said If the garage door is open and you're not home, maybe send me a message and then Even had a relay hooked into it so I could close the the door remotely Which again May be questionable safety, but there's a sensor in there that stops it from closing if somebody's in the way, so It should be okay.

Yeah Seems practical to me.

That seems pretty It was really good. Um I should talk about how the alerts are are uh Are getting out of there.

I could show you like So these are like some of the different automations that have configured in here most of these I did write as yaml, but you can go edit them as as uh In here, they've got two different types of ways to edit it.

Uh but this one says Uh, if one of these sensors is open for a minute and 15 seconds then Send this message Uh to this target, which is a discord bot so it shows up as as something like this, uh Hey, you left the back door open for for too long Maybe you want to close that you're letting all the cold air out or something like that or uh And this is the the fridge alert.

It got over 50 degrees or something which Maybe needs some tuning but Yeah, stuff like that so It's kind of a handy, uh Handy way to get notifications.

You can do sms or other kinds of push notifications, too, but Um What else oh so we talked about being able to reach it from inside the house on the wi-fi I I always thought it would be really nice to like keep an eye on the house when you're not there or know when uh, somebody rings the doorbell you can Check on the package or something like that.

And there's other there's products out there for that too, which again Who came to home assistant?

Um But to be able to to access it outside the house, uh safely so that only I can get to it is something that uh, the Cloudflare product actually helped me out with um, so And if you I don't know if you can see the the url, but so this is accessible anywhere right now except uh It's protected by Cloudflare access.

So if I go there it asks me to log in Uh with a google login and so I can get in there.

My wife can get in there if I want Other family members could could log in or something like that and and access this dashboard from from your phone Like down the street or in another city or anything like that.

It's it's pretty neat. Um and then so the access is protecting it the way I uh, Put it on the Internet is with argotunnel so I mentioned earlier.

It's got uh, all these add-ons that you can write as docker plugins and this one is I wonder if I can see this is a just a docker container running.

Um Argotunnel and oops, there's my cert don't look at that and don't copy that.

Um And it just connects to the local Home assistant and then Reaches out to Cloudflare's edge and makes it so that you can get to this anywhere without having to open any holes on your uh, Your router or anything like that.

Did you build this? uh, yeah, it's um, I I need to to clean it up and publish it somewhere, but it's uh, building add-ons for home assistant is I think not much more than a docker file and some some config files.

Um, so it it runs, uh Runs Cloudflared in docker and and takes in the the config options from this from this file and and sets it up that way and uh It'll even I guess it builds the uh, the docker container right there.

So do you um, so then in the end you have a computer running home assistant and all these things somewhere and yep, uh, I used to run it on a raspberry pi, but Lately was running into issues with the sd cards getting corrupted.

So now it's running in a vm on a on a computer uh in the house here Um Yeah, so that way it's there's one address I can use to access it in the house and uh this other one I can use uh, uh from my phone wherever um Very cool.

It's it's handy stuff. Uh, I think what else?

so who who I can definitely see myself doing this and nerding out about it and loving it.

I'm not so sure that The rest of my family members would uh, find it as interesting.

Yeah, are you Um, so one of the one of the first automation rules I set up was uh Put some motion sensors in the kitchen You walk in the kitchen the lights come on you leave the kitchen for five minutes The lights go out, um, which is great almost all the time.

Um Because you're not leaving the lights on in the kitchen or uh, you can see in the Dark, and it does things like oh dimmer lights in the evening So you don't get blinded in the middle of the night a few times when the motion sensors don't quite work And the lights turn off on you while you're sitting there And that's not not great.

Um So that's most of the interaction that the rest of the family has with it.

It's just the the automations. Um, I have Like shown my wife the dashboard and stuff and like here it is if you want to turn the lights on here let me install this app, but uh I don't know that it's if it's not user-friendly enough or if it's just just not interested, but It's there.

I try to make it easy enough.

Like here's the you can press this button. It'll turn the lights on but I guess one thing that makes it easier is we've got a touch screen In the kitchen that you can pull this up on and you don't have to have the app or remember where it is and and stuff like that, but What would you do?

What would you like to do next or what haven't you done or didn't work that you?

You could see being your next project.

Um I'd like it to be And this may be uh pretty challenging but make i'd like it to be smarter without having to come up with what the rule is like okay, if the And maybe there's some machine learning aspect of it like look for patterns that are out of the ordinary and and tell me about them like Something like automatically figure out i'm not home and this door opened and closed three times and that probably means something weird is going on so uh to do that, but that's uh Yeah, that sounds that sounds really interesting but so much of our lives are uh Patterns sense of finding anomalous things could could reveal some interesting stuff.

Yeah All right, I think we're running out of time thanks sly really really interesting stuff and I hope you open source or Reveal that plug-in.

Yeah, i'll put it out there Thanks tom.

This was fun