How the hell are you?
2021/03/12
Smart devices are all of the everyday objects made intelligent with advanced computers, including AI and machine learning, and networked to form the internet of things (IoT).
Not just computers and smartphones, but everything: clocks, speakers, lights, doorbells, cameras, windows, window blinds, hot water heaters, appliances, cooking utensils, you name it. And what if those devices could all communicate, send you information, and take your commands? And what if I could use Kafka to get this device’s real-time information?
Today I want to show a Raspberry PI Java Spring web app to simulate a Lamp switch using the TP-link smart bulb and smart plug. Once the device is on its start to collect the real-time energy consumption info and send to a Kafka topic.
I already did a blog about TP-link smart plush, but today I want to use a Java API that I found here and here. I kind of did a mix of both.
I’m using a smart plug HS110 and smart bulb LB110
code
1 2 3 4 5 |
1 2 3 4 5 6 7 8 | System.out.println(payload); if(payload.equals("true")){ plug.switchOn(); this.producer.sendMessage(plug.getEnergy()); }else { plug.switchOff(); } |
1 | } |
For configure kafka just need add the settings on “application.yml”. Here I did with my raspberry pi kafka cluster.
Disclaimer – I got the CSS from here
You can get the full code on my GitHub.
And you can combine this with my influxdb-and-grafana blog and add some nice visualization.
Smart Plug HS110
Smart Light lb110
I mentored a colleague in a similar project