Home Home Automation Insult-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 in style with crypto-currency

Smart Ideas with

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

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

ESP8266 WIFI lights under $5

0
Your Sonoff device can't do this!

Free wireless doorbell (Amazon Dash button hack)

0
The most terrifying situation I can imagine* is missing a parcel

New Amazon Dash Buttons

0
You can teach new buttons old tricks!

ESP8266 ceiling light – demo

0
Testing the ESP8266 as a WIFI light controller

Try Tasker and Raspberry Pi for your home automation needs!

0
Raspberry Pi can help you with your Tasker profiles

Smart Home

Awesome time with Wio Terminal

0
Wio Terminal from SeeedStudio is a great all-in-one development board that doesn't require soldering skills to get started with.

Flashing Tasmota on Sonoff ZigBee Bridge

0
How to flash Tasmota on Sonoff ZigBee Bridge to enable it for NodeRED and Home Assistant

Flashing Tasmota on Novostella smart bulb & floodlights

0
Flashing Tasmota on Tasmota on Novostella smart bulb & floodlights - it's quick simple and rewarding - here is how to use lights in NodeRED

Adding Sonoff sensors in Zigbee2MQTT and other systems

0
Can you use Sonoff sensors in Zigbee2MQTT and other ecosystems? Trying Tuya, Xiaomi, IKEA Tradfi and CC2531

Sonoff Zigbee sensors

0
I'm checking out Sonoff ZigBee sensors by ITEAD - what's the budget sensors like?