Upgrading the button by which your parents call you to come and eat

Table of Contents
Upgrading the button by which your parents call you to come and eat

Introduction

Do you already have a basic version of the button that enables your mom to call you for dinner? Congratulations. 👍 With this enhancement, you can move the project even further forward - the message changes according to the time of day. You can even respond to it.

Under this project, you will learn how to set up a different message for different times of day, send a special notification by holding the button and program a simple response option. 👌

The basic version of this project can be found here: Create an IoT button that enables your mom to call you for dinner.

You will need the box with button and a USB Dongle. The basic HARDWARIO Starter Kit is sufficient for this.

Prepare Node-RED

  1. Put the Starter Kit together and pair it. On the Core Module you will need the familiar bcf-radio-push-button firmware again.

sestavení-starter-kitu

Set up notification

  1. Set up the flow of the notification in the same way as the basic version of this project. Place the MQTT node, which has click counting in Topic, from the Input section onto the desktop. Next to it, place mobile notification connected to Blynk.

Skip the change node for now, you'll soon find out why.

So far it looks like this:

MQTT node

  1. This time, paste a different node, to which you copy javascript, between the two nodes. You will find it as the Function node under the section of the same name.

Function node

  1. To this node add a code with which to control the time. ⏳ You set up from what time until what time you want to receive breakfast 🍳, lunch 🍗 and dinner 🍕 messages. Smart javascript, hey?

Copy the following code into the Function line in the node setting. If you look at the code, you will see that some parts are highlighted in color. In them, you set the meal time and your own message. Customize the colored parts of the code, bearing in mind that accent marks (čárky) and hooks (háčky) won't work.

var date = new Date(); var hour = date.getHours();
if(hour >= 8 && hour < 11) { msg.payload = "Pojd na snidani, ospalce"; return msg; } else if(hour >= 11 && hour < 17) { msg.payload = "Obidek na tebe uz ceka"; return msg; } else if(hour >= 17 && hour < 21) { msg.payload = "Podava se vrchol dne, vecere"; return msg; }

Setting the message itself

  1. Name this node in the same window in the Name line. For example Time & Message Setting.  Setting time and message Confirm with the Done button.

Set up press and hold button.

  1. Let's quickly move on. Now it´s time to set up what the button does when your parents hold it for a long time. That can be controlled too. 👌 Place another MQTT node from the Input section onto the desktop. MQTT

  2. Set there a different Topic that causes the reaction of the button when you press it for a long time.

    node/push-button:0/push-button/-/hold-count

    Topic

  3. Behind this, place the Change node that you already used in the basic version. In it, set your own message, which is sent when your parents hold the button for a long time. It can be used for different messages other than for eating 🙂. For example: Come downstairs, you lazy so and so!

Change node

  1. Behind this node, place another one to unclick the message. In addition, you can make the message not only pop up on your mobile, but also on your computer.

You can do this through the Notification node under the Dashboard section.

Notification node

  1. In the node, select OK/Cancel Dialog on the Layout line and confirm with the Done button.

Layout

  1. Connect everything as shown in the screenshot and press Deploy.

Deploy

Ready, steady... go!

  1. Like before, put the improved box ** in the hands of your mom and dad**.

  2. Instruct them to short press the button to call you to come and eat…

vylepšená krabička
  1. ... and to press and hold 👇 the button if they want to call you for anything else.
zmáčknutí tlačítka

At least you won't be disappointed when, instead of eating, there is a family discussion on the plate. Ugh, another menu, please!