HomeHome AutomationInsult-o-tron 9000 and couple of other PC tricks

Insult-o-tron 9000 and couple of other PC tricks

Insult others like it's 1699!

There is more than one way to skin the cat. There are at least five ways to use Aqara cube in your home automation. Some of them more creative than others, some of them just plain useful. In case you are not into the Insult-o-tron 9000 idea I have a couple of more uses for you.

Insult-o-tron 9000

The number of negative comments and messages I get (don’t treat this as a challenge) is probably bigger than 1 but smaller than 3 a year. Fortunately, social media take care of this for me, and for the most part, the notenoughtech across all the media channels is mostly family friendly! This makes the Insult-o-tron 9000 not that useful, but incredibly evil idea.

Wouldn’t be nice to shake your fist at someone then let the computer figure out the appropriate way to respond to the online bully while remaining classy as f*ck? (PG12 just went through the window)

Insult-o-tron 9000 is here to give you that quirky superpower! Shake your fist in anger at insults hurled at you – and respond in poetic, creative and incredibly mean style. Shakespeare all the way!

To make it happen, you have to know how to use MiHome Gateway and Aqara Cube in NodeRED. Thankfully, that’s already covered by me. I used the “air_shake” command to generate the insult and send it over to a PC or mobile (You can use it with Tasker).

FUNCTION NODE: insult
var one = ["froward","frothy","gleeking","goatish","gorbellied","impertinent","infectious","jarring","loggerheaded","lumpish","mammering","mangled","mewling","paunchy","pribbling","puking","puny","qualling","rank","reeky","roguish","ruttish","saucy","spleeny","spongy","surly","tottering","unmuzzled","vain","venomed","villainous","warped","wayward","weedy","yeasty"];
var two = ["fat-kidneyed","flirt-gill","flap-mouthed","fly-bitten","folly-fallen","fool-born","full-gorged","guts-griping","half-faced","hasty-witted","hedge-born","hell-hated","idle-headed","ill-breeding","ill-nurtured","knotty-pated","milk-livered","motley-minded","onion-eyed","plume-plucked","pottle-deep","pox-marked","reeling-ripe","rough-hewn","rude-growing","rump-fed","shard-borne","sheep-biting","spur-galled","swag-bellied","tardy-gaited","tickle-brained","toad-spotted","unchin-snouted","weather-bitten"];
var three = ["flax-wench","fen-sucked","foot-licker","fustilarian","giglet","gudgeon","haggard","harpy","hedge-pig","horn-beast","hugger-mugger","joithead","lewdster","lout","maggot-pie","malt-worm","mammet","measle","minnow","miscreant","moldwarp","mumble-news","nut-hook","pigeon-egg","pignut","puttock","pumpion","ratsbane","scut","skainsmate","strumpet","varlot","vassal","whey-face","wagtail"];

seed1 = Math.floor(Math.random() * 35);
seed2 = Math.floor(Math.random() * 35);
seed3 = Math.floor(Math.random() * 35);

insult = one[seed1] + " " + two[seed2] + " " + three[seed3];


var id = global.get('JOIN_desktop');

msg.payload = "You are a " + insult;

msg.push = {
"clipboard": msg.payload,
"deviceIds": id
}

return msg;

First, I have to generate an insult. I have 3 arrays (my Shakespearean insults have 3 words) which store 35 phrases in each. I generate three seed numbers that are used to determine the words used in the insult. The insult is then pushed as a Join Message and stored in the computer’s clipboard.

FUNCTION NODE: shake
msg.topic = "AR_desktop";
msg.payload = "shake";
return msg;

Once the message has been set, I push the command to EventGhost to trigger the Ctrl+V macro to paste the selected insult into a text box! Simple and effective!

But if you want to use it for something useful…

Jokes aside, the Aqara Cube can be used for PC controls. In my examples, I’ve set up volume & desktop controls, but you could use it to automate a music or movie playback if you use a PC play the content (shake to play a random song, or double tap to pause the movie playback).

Volume

Aqara Cube rotation is used to turn the volume up or down. I’m grabbing the rotation info from the cube and based on the rotation angle, I turn the volume up or down by 10%. The info from the cube looks like this [-10:500] and it’s available as a string. I can split it into 2 parts using “:” and use the first value (converted to int) to drive two IF conditions.

FUNCTION NODE: Rotate
var x = msg.payload.data.rotate;


var angle = x.split(':');
y = angle[0];
var rotation = parseInt(y, 10);

if(rotation >= 0){
    
    msg.payload = "volup";
}
if(rotation < 0){
    msg.payload = "voldown";
}
msg.topic = "AR_desktop";
return msg;

An AutoRemote message is sent to EventGhost which will increase/decrease the volume accordingly. If you want to know more about AutoRemote in NodeRED – check this tutorial out.

Desktop switch

When I push the Aqara Cube, my PC changes the active desktop (Win+Ctrl+Left/Right). First, I have to keep track of which desktop is currently enabled. I used HTTP requests to update the NodeRED each time I change the desktop. I’m doing this so the NodeRED would know what is the active desktop (stored as flow variable) and send the correct instructions when the Cube is pushed.

FUNCTION NODE: push
var x = flow.get('DesktopActive');

msg.topic = "AR_desktop";
msg.payload = "DesktopActive:" + x

return msg;

Most of the “magic” happens on the EventGhost’s side. The AutoRemote message triggers the opposite key macro and feeds back the changes to NodeRED via HTTP posts. You can read more about the HTTP requests in NodeRED here.

import requests

username = getattr(eg.globals, "HTTP_user")
password = getattr(eg.globals, "HTTP_pass")
path = "/desktop/"
url = getattr(eg.globals, "HTTP_request") + path
data = {"desktop":"L"}

resp = requests.post(url, data, auth=(username, password),verify=False)

For some reason, the Win+Ctrl+Left/Right macro is being blocked by EventGhost if monitored, so I set up an additional macro to play this combination so I could also change the desktops using the keyboard.

Desktop extend

I use the double tap action to extend the screens. This is just to show you basic mouse controls in EventGhost. The NodeRED side just uses a function node to send a specific command to EventGhost.

FUNCTION NODE: tap_twice
msg.topic = "AR_desktop";
msg.payload = "tap_twice";
return msg;

To extend the desktop I have to execute Win+P and select the Extend option. I could not scroll down with macro keys for some strange reasons so I settled for the absolute mouse position and a click. Worked just fine in my tests.

Buy Aqara Cube

Buy it using these links to support NotEnoughTech.

Conclusion

The massive advantage of NodeRED in oppose to the native MiHome application is the ability to switch the cube control schemes on the fly. You could can have the cube controlling the movie when the playback is detected and switch to other schemes by enabling and disabling the flows. One cube, plenty of applications. I will keep the Insult-o-tron 9000 just in case 🙂

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

Smart Ideas with

Automate your space in with these ecosystems and integrate it with other automation services

client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image

Learn NodeRED

NodeRED for beginners: 1. Why do you need a NodeRED server?

0
To server or not to server? That's a very silly question!

Best Automation Projects

Tuya SDK for beginners: Intro to Tuya Cloud API

0
Working with Tuya Cloud API. A guide to Cloud automation for beginners, get started with REST!

NEST your old thermostat under $5

0
Nest-ing up your older thermostat under $5

Nora – Google Assistant in NodeRED

0
Integrate Google Assistant with NodeRED thanks to Nora - NodeRED home automation

DIY Smart Washing Machine – for about 15 bucks!

0
Learn how to add washing machine notifications to your Google Home on the cheap

Sonoff Zigbee Bridge – review

0
Sonoff line up will soon include Sonoff Zigbee Bridge and more Zigbee sensors - here is the first look

Smart Home

We’ve seen this before: SwitchBot K10+ PRO

0
This is an odd one. Building on the success of SwitchBot K10+ they released SwitchBot K10+ PRO - but is the experience actually better?

Is this the smart panel we have waited for?

0
ITEAD has released a new smart panel: Sonoff NSPanel Pro 120 - have they learned the lesson from the terrible launch of the original Pro? Let's see what's new.

Aqara FP1E detects motionless humans

0
This isn't exactly a new device, it's an interaction of the original Aqara presence sensor. Aqara FP1E brings Matter, ZigBee and new triggers to your smart home

SwitchBot S10: cleaning re-imagined!

0
SwitchBot S10 promises unattended vacuuming and mopping so you can focus on things you love and care for. Does it deliver?

Sonoff for households and gardens

0
ITEAD released two ZigBee devices to manage water in your household and gardens. Now you can monitor the flow and dispense water with Sonoff SWV and prevent water damage using the Sonoff Water Leak sensor with a twist.