Cycle-based Automation for Home Assistant

by KimY21 in Circuits > Electronics

21 Views, 0 Favorites, 0 Comments

Cycle-based Automation for Home Assistant

Hacster Cover Image.png

Make a single lamp signal three different Home Assistant events — by priority. When an email arrives, the lamp blinks blue. When the doorbell rings, it switches to green. The moment smoke is detected, it goes red and overrides everything else. Cancel-and-resume logic that is hard to express in event-driven HA automations falls out naturally from Grablo's PLC-style scan cycles and native priority support — no MQTT broker, no YAML, no code.

Supplies

Hardware:

  1. Windows PC, Mac, Raspberry Pi, or any other Grablo-supported device
  2. A running Home Assistant server reachable from your Grablo device
  3. One RGB light entity in Home Assistant (any RGB-capable bulb / strip)
  4. Three binary_sensor entities for Smoke, Doorbell, and Email — real sensors or HA Toggle helpers both work

Software:

  1. Grablo — No-Code IoT Platform (grablo.co)

Quick Start

Want to skip the build and just run it? Copy the project from the Grablo Gallery:

  1. Download and install Grablo software on your device from grablo.co/download
  2. Get this project from the Grablo Gallery
  3. Open the Grablo app at app.grablo.co in your browser
  4. Fill in your Home Assistant connection in Settings → Home Assistant → Edit (the HA block is already in the project — just enter the server address and paste a Long-Lived Access Token from HA → Profile → Security → Long-lived access tokens)
  5. Open each HA action and reselect the entity for your own setup — three Read actions (Smoke, Doorbell, Email) and the Turn On / Turn Off actions on your light entity
  6. Connect to your device and hit RUN

If you'd rather build it from scratch, follow the steps below.

Create the Project and Connect Home Assistant

Create a new project at app.grablo.co, name it "Cycle-based Automation for Home Assistant," and select All Devices as the target. Then go to Settings → Home Assistant → Edit and enter your HA server address (default port 8123). In Home Assistant, go to your user profile → Security → Long-lived access tokens, generate a new token, copy it, and paste it into the Token field. No dashboard widgets are needed for this project — the lamp itself is the UI.

Build the Logic

Create the first logic and name it "Read Values." Add an Always condition so it runs every cycle, then add a Home Assistant Integration action with the Command set to Read. Click Select, pick the Smoke Alarm entity, and bind its state attribute to a new variable called Smoke. Duplicate the action twice and change the entities to your Doorbell and Email sensors, binding each to a Doorbell and Email variable. Because Grablo re-evaluates every scan cycle, these three variables always reflect the latest Home Assistant state.


Create a second logic called "Priority Control." Inside it, add three controls — one for each event — and wrap them in a Control Group with the mode set to Priority.

The Smoke control uses a Compare condition (Smoke EQ True) with no edge option, so it keeps firing for as long as smoke is detected. Its actions are simple: an HA Write action that turns the lamp on red at 100% brightness, a Delay of 0.5 seconds, another HA Write that turns it off, and another 0.5-second Delay.

The Doorbell control uses a Compare condition (Doorbell EQ True) with the Rising Edge option, so a single ring is enough to start it. Wrap its on/delay/off/delay chain inside an Action Group with Repeat for Duration set to 15 seconds and a 1-second delay per cycle, with the lamp turning green. The Email control is the same pattern: Rising Edge on Email EQ True, Repeat for Duration of 10 seconds, blue color, 1.5-second delays.

Finally, set each control's priority — 1 for Smoke, 2 for Doorbell, 3 for Email. Lower numbers mean higher priority, so Smoke wins over everything else.

Launch Your Project

Launch Your Project

  1. Open the Grablo app and select your project
  2. Connect to your device
  3. Hit RUN
  4. Toggle the Smoke, Doorbell, and Email entities in Home Assistant to see the lamp respond


Expected Results:

  1. Toggle Email — the lamp blinks blue every 1.5 seconds for 10 seconds
  2. While Email is blinking, toggle Doorbell — the lamp immediately switches to green at 1-second intervals for 15 seconds
  3. While Doorbell is blinking, toggle Smoke — the lamp immediately switches to red at 0.5-second intervals and stays red until smoke clears
  4. When the higher-priority event ends, lower-priority blinks resume automatically if their duration hasn't elapsed


Video Tutorial

Cycle based Automation for Home Assistant

Expand Your Project

Expand Your Project

  1. Add a fourth priority for "motion at night" with a slow white pulse
  2. Replace the lamp with a smart siren entity to escalate the smoke alarm physically
  3. Add a Telegram or push notification action to the smoke control so the highest-priority event also alerts your phone
  4. Apply the same priority pattern to a speaker that announces different HA events


Troubleshooting:

  1. Lamp doesn't react: open one of the Read actions and click the entity picker — if the dropdown is empty, the HA connection is wrong. Re-check the address and Long-Lived Access Token.
  2. Wrong entities are read: the project ships with example entity IDs. Open each HA action and reselect the entity for your own setup.
  3. Doorbell or Email blinks forever: make sure their conditions still have the Rising Edge option enabled — without it the loop restarts every cycle.
  4. Higher priority doesn't override: confirm the Control Group's mode is set to Priority and that Smoke is assigned priority 1 (lower number = higher priority).