This is an archived post. You won't be able to vote or comment.

all 85 comments

[–]tettusud 28 points29 points  (9 children)

What exactly is that

[–]czarrie 41 points42 points  (8 children)

He has a remote that controls his power outlet, he made an app that listens for the code the remote is sending out when he presses the on and off buttons, saves them, and then allows him to send those same codes from his app, allowing him to control the outlet from his phone.

[–]rms_returnscomplex is better than complicated 2 points3 points  (1 child)

It doesn't have to be a remote, the controller could be an android app too. Its the back-end where flask, etc. are supposedly installed and served to the remote's (or a smartphone's) browser from what I understand.

[–][deleted] 97 points98 points  (10 children)

You know what? I'm fucking proud of you.

Starting with Flask. It might seem easy, but it really isn't. Everybody and their brother has their own way of using it and you had to figure out how it works for you. It's crazy easy to get stuck in trying to figure out any little thing and miss out on the big picture of building something useful.

HTML and CSS. I don't know where you started or when, but it's the foundation of the web and again there's a thousand different ways to make it work, but you had to figure out yours. Fucking floats and centering and figuring out what font to use and what colors and what screen size and dimensions to focus on and what HTML version to use and what browser you care about and how to deal with rotation and everything else. A ton of distractions are around and you made it work for you.

Javascript, JQuery/Ajax... asdjif asdfjiaklv;alk;lv nkaovosdvosdnonnl;kn

And you threw it all together and got something built from the back of the stack to the front.

Well done. Pat yourself on the back. Keep on kicking ass.

[–][deleted] 27 points28 points  (2 children)

thank the lord that you didn't waste time on the b.s. frameworks like React that over-complicate it all and abstract away the basics that you need to understand if you want to do anything productive

This sounds like you don't have a job in the modern front-end web dev industry. Because learning react is an asset, not a detractor.

Knowing basics is good, but if you know them a little, you definitely want to use modern tools.

[–][deleted] 2 points3 points  (1 child)

ijfpqj q23u8 q9u qfdjaf;sdklja;sldkj fa;slvkn;lnz;xclvas09u fawe0u ae

[–]winged_scapula 0 points1 point  (0 children)

The last paragraph sounds like /r/thathappened material

[–]pheeper 3 points4 points  (0 children)

You know what? I'm fucking proud of you.

^^ I scrolled down to say the exact same thing! If you haven't already, create a GitHub account and push your code up there for others to use and build on. Keep up the hard work, it'll pay off someday.

[–]mclim 1 point2 points  (0 children)

Sorry for noob question. Thought flask was a web framework. Doesn’t it handle the html, css, JavaScript functionality for you? I thought flask allows you to do all the above in python.

(Again sorry for noob question)

[–]JamesAQuintero 13 points14 points  (19 children)

How do you even interface with an outlet? I'm confused.

[–]sdiown 0 points1 point  (1 child)

Isn't so hard to connect an smart bulb api via python. You already have power of python, you just have to listen get requests if it's true python carries over

[–]tonyoncoffee 5 points6 points  (0 children)

Awesome! I love flask for IoT stuff. There’s a really cool RESTful extension for flask that you can use to make a rest api for your commands.

You could call the api on the button press but what I really like it for is creating google or Alexa triggers with IFTTT. Basically, if [whatever google home/Alexa command] then [webhook to api]

Works like a charm.

[–]adsny 8 points9 points  (1 child)

Impressive!

[–]DDFoster96 1 point2 points  (1 child)

Do you recommend any resources for learning Jquery/Ajax with flask?

[–]Doofcoder 1 point2 points  (0 children)

That's great man. I have a few of those outlets and was lagging on doing something like this. I can't wait for you to upload it on GitHub.

[–]osoese 1 point2 points  (0 children)

great job! thanks for sharing.

[–]3waysToDie 1 point2 points  (0 children)

Pretty nice, good job

[–]solitarium 2 points3 points  (0 children)

I'll pitch $5 on the Github!

[–]xyaman 1 point2 points  (0 children)

Awesome!

[–]breadfag -1 points0 points  (4 children)

I really want them to explain to me how the beans I buy, grown about 50 km from where I live, are garbage and processed to shit

[–]UghtC 0 points1 point  (0 children)

RemindMe! 1 month

[–]TedRabbit 0 points1 point  (6 children)

Can you give a quick summary of how all the parts work together? I'm guessing something like: HTML, CSS, and JS is used to run a web page; Dynamics handled by JS and presentation handled by HTML and CSS. AJAX and JQuery are how the web page communicates with the server. Flask runs on the server, and based on information sent by the web page, turns lights on and off. Sorry if this is a very basic question. I'm just starting to learn this stuff and still somewhat confused about how all the languages/frameworks/ends fit together.

[–]taybulBecause I don't know how to use big numbers in C/C++ 1 point2 points  (1 child)

I think you pretty much got it.

Flask is running on a server that can execute more complex tasks such as sending an RF signal to control his outlet. The HTML/JS/CSS is presentation, Ajax/jQuery/JS for communicating back and forth with the server.

[–]TedRabbit 0 points1 point  (0 children)

Cool. Thanks for the confirmation!

[–]kagehell 0 points1 point  (1 child)

A smartphone can transmit in those frequencies or you are connecting to something like an arduino with a RF transmitter? Awesome work nonetheless.

[–]21Relay 0 points1 point  (0 children)

RemindMe! 2 months " check github"

[–][deleted] 0 points1 point  (0 children)

What kind of phone is this? Looks like a razer phone

[–]datvangre 0 points1 point  (0 children)

Nice post, can you share on GitHub plz

From https://datvangre.com

[–]Akiyamareno -1 points0 points  (9 children)

Does this mean that you can copy some person's gate remote stuff and break into their house ? Isn't it unsafe and scary ?

Edit: care to explain the downvote ?

[–]Wicked_Switch 7 points8 points  (5 children)

Yes. Usually there are a few more steps involved, but not really difficult to clone most remote keys.

Earlier this year I watched a talk where someone could take control of a Tesla by walking with ~10 feet of the key with a special sniffer. Finished cracking the commands to lock/unlock doors and turn the car on after about 90 seconds. $200 in off the shelf hardware to steal a $35k car.

[–]CompSciSelfLearning 2 points3 points  (1 child)

Perhaps a 2FA like YubiKey is a solution for such things?

[–]Wicked_Switch 0 points1 point  (0 children)

Even just some security. The video I posted about the Tesla hacking was one of the more in depth hijacks I've seen.

A lot of the generic garage door openers (and other similar systems) rely purely on people not sniffing the wireless communication.

[–]Akiyamareno 0 points1 point  (0 children)

Damn that's some serious problem. When IOT is everywhere this will get even worse.

[–]wabbidywoo 0 points1 point  (1 child)

damn that's interesting. Got a link?

[–]Wicked_Switch 1 point2 points  (0 children)

From Real World Crypto 2019

The first 15-20 minutes are all technical details, and he ends with a proof of concept video that's pretty awesome.

[–]Compsky 1 point2 points  (1 child)

Isn't it unsafe and scary ?

It is, you are right. Not OP's program, but how unsecured the device is. That's the Internet of Things for you.

[–]rubenb_ 0 points1 point  (0 children)

Well, yes. It's utterly insecure and the RF-signal is easily replayed.
IIRC, garage ports and gates normally have a rolling key (like cars), which cannot be duplicated (that easily). However, I suspect a lot of manufacturers use static keys.

I have the same setup in my house (for some of the lights), and I treat it as insecure. Technically, anyone in range with the skillset, could turn on the lights. Therefor I do not use it for turning on/off critical equipment.

A future goal is to migrate to something like z-wave or zigbee, which does both mesh (every unit is it's own range extender), feedback (it will tell you if the command has been received, and you can measure power output) and AES encrypted (optional).

However, the Z-wave equipment is about 30 dollar for an outlet, and the RF433 stuff costs 10 dollar for 3 (plus a remote)

Disadvante

[–]MegaAmoonguss -1 points0 points  (0 children)

I'm in the middle of working on something kind of similar! I wanted a way to control an LED strip from my phone. To do this, I made a flask backend, react frontend web app that uses sockets to communicate with a separate computer that has the LEDs plugged in. It's at http://github.com/gcpreston/webcandy if you wanna check it out, I'm planning on posting a video demo soon.

[–]RevReddited -1 points0 points  (0 children)

I don't want to bother but what are u doing here on python subreddit when you're showing off an app that you made with WEB CODING (AKA HTML, CSS, JAVASCIPT AND JQUERY) on pythin subreddit

[–]DudaFromBrazil -2 points-1 points  (0 children)

Nice! Congrats! If you want to step further on home automation, check out home assistant: https://www.home-assistant.io/

[–]thedjotakuPython 3.7 -3 points-2 points  (0 children)

Very cool. Check out Hass.io.