HomeHome AutomationA "goodnight" button - MiHome switch it all and more

A “goodnight” button – MiHome switch it all and more

Sorry, IKEA you are still the potato of automation

I’m not going to lie, there are many times I ended up in bed “accidentally” then absolutely hated getting back up and turning everything off. Voice commands are great until you realise that speaking to other women online (even if they are names Alexa or Assistant) is a “no no“. I decided to hack the heck out of the MiHome Button. And it does so much more.

A “goodnight” button

In order for this to work, my wife has to be on board. If you convinced your better half to a new automation, you are basically half way there. So tempt her into this automation I’m going to use the MiHome switch to perform the following functions:

  • toggle bed lamp
  • toggle main lamp
  • toggle between light sources automatically
  • turn everything else off when ready

Yes you could do this with Tasker if you don’t want to get your hands dirty, but a physical switch 3M taped to the side of your bed is the most accessible way of doing it. Trust me, I’m an automation… um… who am I anyway! You are reading this because the idea is awesome.

I spoke about the MiHome and NodeRED integration before. You should read the article about Gateway and NodeRED and MiHome button in NodeRED to get up to speed. From these articles you will know that MiHome button has 3 functions. I used NodeRED to map the following functions:

  • click (toggle bedside lamp – it is used more often)
  • double click (toggle top light)
  • hold (turn off everything)
Button presses will turn off other lights as I hardly have scenarios where both light sources are needed. This is programmable, and if you want to have independent control of both lights, you can change this.

In my setup I used:

Buy Aqara Switch

Buy it using these links to support NotEnoughTech.

NodeRED Flow – “goodnight” button

I’m recycling a lot of code that I already covered in the previous write ups. If you want to learn more, just click on the links (here, here, here).

Single click

When the button is pressed, I send the toggle command to the lightbulb. The status of the bulb (including the colour info) is held in a global variable and I simply change the state of the bulb to the opposite one. At the same time, I’m sending a command to turn the other bulb off (this is the optional behaviour).

Double click

This is a copy of the single click action. I just simply send the information to another bulb. Pretty much a copy and paste job with some small changes to the global variables which store the information for the correct ligthbulb.

Long click

I picked about 6 seconds to avoid the accidental shutdowns. NodeRED is able to tell the time based on the button press and button released actions. You could map multiple commands if you want (press for 5 seconds to turn lights off, press for 10 sec to turn all of and arm an alarm etc.).

When the button is clicked, a message to turn off the lights is issued. There is no uniformed way right now to do so, as I use a combination of smart sockets (MQTT) and other lights.

My computers go to sleep thanks to AutoRemote notification which is sent to EventGhost. Then the program puts the PCs to sleep. I wrote more about this in this write up. Because I’m using a subflow to send the AutoRemote message, all I need is a topic and the payload. The rest of my data for that API call is stored in global variables. Take a look at serving credentials to make your life easier and not to waste the time with hardcoding all the information every time.

Conclusion

I got a fair share of comments after I moaned about lack of the granular control in IKEA smart home. This is the reason why I’m conscious of it. Automating things at this level would cost you more money if you would like to use IKEA Tradfri in their default form. Me? I will just play about with devices like this – creating small solutions to problems that probably affect just me. After all, home automation should be personal and suited to my needs, not to the needs of the masses.
Feel free to join the discussion in this Reddit post.

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

Sonoff Zigbee Bridge – review

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

DIY Smart Washing Machine – for about 15 bucks!

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

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.