Cycle-based Automation for Home Assistant
by KimY21 in Circuits > Electronics
21 Views, 0 Favorites, 0 Comments
Cycle-based Automation for Home Assistant
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:
- Windows PC, Mac, Raspberry Pi, or any other Grablo-supported device
- A running Home Assistant server reachable from your Grablo device
- One RGB light entity in Home Assistant (any RGB-capable bulb / strip)
- Three binary_sensor entities for Smoke, Doorbell, and Email — real sensors or HA Toggle helpers both work
Software:
- 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:
- Download and install Grablo software on your device from grablo.co/download
- Get this project from the Grablo Gallery
- Open the Grablo app at app.grablo.co in your browser
- 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)
- 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
- 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
- Open the Grablo app and select your project
- Connect to your device
- Hit RUN
- Toggle the Smoke, Doorbell, and Email entities in Home Assistant to see the lamp respond
Expected Results:
- Toggle Email — the lamp blinks blue every 1.5 seconds for 10 seconds
- While Email is blinking, toggle Doorbell — the lamp immediately switches to green at 1-second intervals for 15 seconds
- While Doorbell is blinking, toggle Smoke — the lamp immediately switches to red at 0.5-second intervals and stays red until smoke clears
- When the higher-priority event ends, lower-priority blinks resume automatically if their duration hasn't elapsed
Video Tutorial
Expand Your Project
Expand Your Project
- Add a fourth priority for "motion at night" with a slow white pulse
- Replace the lamp with a smart siren entity to escalate the smoke alarm physically
- Add a Telegram or push notification action to the smoke control so the highest-priority event also alerts your phone
- Apply the same priority pattern to a speaker that announces different HA events
Troubleshooting:
- 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.
- Wrong entities are read: the project ships with example entity IDs. Open each HA action and reselect the entity for your own setup.
- Doorbell or Email blinks forever: make sure their conditions still have the Rising Edge option enabled — without it the loop restarts every cycle.
- 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).