Automating Night Silence with Apple Shortcuts and HashiCorp Consul
I have a nightly cron that can post things from OpenClaw to a Discord channel.
This is useful.
This is also dangerous at night.
If I forget to close the tab, or some device keeps the sound enabled, the cron can happily post to Discord while everybody sleeps. Then Discord makes a sound. Then my family wakes up because my automation decided to be productive at 3 AM.
Classic DevOps problem, just at home.
I needed a boring guardrail.
At night all devices should shut up.
In the morning they should return to the previous volume.
That’s it.
Focus modes help with notifications, but I wanted a more mechanical guarantee. Save current volume, mute the device, restore the same value later.
So I made a small stateful automation with Apple Shortcuts and Consul KV.
Overkill? Of course.
Still better than being woken up by my own cron job.
The naive version
The naive Shortcut is trivial:
Set Volume to 0%
Run it before sleep. Done.
Except now the morning part is broken.
What should restore do?
Set volume to 50%? Why 50? Maybe the phone was at 20%. Maybe the iPad was at 80%. Maybe the device was already muted. Maybe I changed the volume in the evening for some reason.
Hardcoded restore is not restore. It is just a cron job with confidence.
The actual requirement is this:
observe -> persist -> mutate
First read the current value.
Then save it somewhere.
Only then change it.
Sounds obvious. Still exactly the kind of thing that gets wrong in small home automations, because each individual step looks harmless.
Why Consul
I already run infrastructure where Consul makes sense.
For this task Consul KV is almost comically suitable. I need one key per device:
personal/night-silence/maksym-iphone/volume
With a tiny value:
{"volume": 0.42}
No database. No schema. No migration. No Home Assistant entity gymnastics. Just a key-value store.
Could it be a JSON file somewhere? Sure.
Could it be Redis? Also yes.
Could it be Home Assistant? Probably.
I used Consul because it is already infrastructure-shaped. Devices can write state. Other automations can read it. Keys have namespaces. I can inspect everything later.
The whole architecture is boring:
iPhone / iPad / Mac
|
| Apple Shortcut
v
private HTTP endpoint
|
| writes device state
v
Consul KV
|
| later restore Shortcut reads state
v
device volume restored
Consul is just the place where I keep the previous value. The useful idea is treating device volume as state.
Bedtime shortcut
The bedtime Shortcut does this:
Get Current Volume
Get Device Name
Make Dictionary
Get Contents of URL
Set Volume to 0%
The dictionary is roughly:
{
"device": "maksym-iphone",
"volume": 0.42,
"source": "shortcuts",
"reason": "night-silence"
}
The backend stores it under a device-specific key.
The order is important.
If you mute first and save later, congratulations, you saved 0%. This is the automation equivalent of taking a backup after deleting the database.
So the rule is simple:
observe -> persist -> mutate
Same as production systems. Smaller blast radius, same idea.
Restore shortcut
The morning Shortcut is the inverse:
Get Device Hostname
Build Consul KV URL
Get Contents of URL
Get Value from Consul response
Decode Value with base64
Get volume from decoded dictionary
Set Media volume to saved volume

Consul HTTP API returns KV entries as JSON. The payload is in the Value field, and Consul base64-encodes it.
So the Shortcut has to do this little dance:
response[0].Value -> base64 decode -> dictionary.volume
Not beautiful, but explicit.
Each device uses its own hostname in the key, so the phone restores phone volume, iPad restores iPad volume, etc. No shared global “morning volume” nonsense.
Missing value should not be dramatic.
If there is no saved value, do nothing.
if saved volume exists:
restore it
else:
leave the device alone
This is another small but important detail. If the save step failed last night, the restore step should not invent facts in the morning.
Why Focus mode was not enough
Focus is good. I use it.
But my problem started from a very specific failure mode: OpenClaw posts to Discord from a nightly cron, and some device can still make noise because I forgot to close the tab or mute it properly.
I wanted the boring infrastructure answer: store previous state, apply safe state for the maintenance window, restore previous state later.
The parts stay small:
- Focus handles notifications
- this shortcut handles media volume
- sleep automation handles health data
- OpenClaw can observe and tell me when something drifts
One tool does not need to own the whole workflow.
I dislike giant home automation scenes for the same reason I dislike giant shell scripts. At first they look convenient. Then one day the lights, music, vacuum cleaner, and some random API call are all coupled together and nobody knows why.
Small automations with explicit state are much easier to debug.
Consul as personal automation glue
It is funny to use Consul to remember that my phone was at 42% volume before bedtime.
Consul is usually service discovery, health checks, production infrastructure, all that serious stuff.
Here it stores phone volume.
But the class of problem is familiar:
- What device am I changing?
- What was the previous state?
- Can I restore it?
- What happens if one step fails?
- Where can I inspect the state tomorrow?
Most personal automations are written like one-off scripts. They mutate something directly and forget why.
Add durable state and the automation becomes less clever and more reliable.
I can check the value directly:
consul kv get personal/night-silence/maksym-iphone/volume

In the UI it is just a key per device with a tiny JSON payload like {"volume":0.59}.
This is enough.
If something goes wrong, I do not need to guess what the Shortcut did last night. I look at the state.
That is worth more than fancy automation logic.
Credentials
The phone does not talk to Consul directly.
Shortcuts call a private endpoint. The backend talks to Consul.
The Shortcut gets a tiny interface:
save this device volume
read this device volume
A broad Consul token should stay out of Shortcuts.
Putting infrastructure credentials into Shortcuts would be convenient for about five minutes and then annoying forever. Shortcuts are great glue, but not where I want to spray tokens.
So the split is:
- Shortcuts know a narrow endpoint
- backend knows Consul
- Consul stores the state
Small interface. Small permission. Easy to replace later.
What I like about it
The result is almost invisible.
At night devices go quiet.
In the morning they return to the previous volume.
The automation is reversible, which is the whole point.
If an automation changes something, ask where the previous value goes.
If the answer is “nowhere”, the automation is probably too dumb.
Saving state before mutation is normal in Terraform, databases, and Kubernetes controllers. Turns out it is also useful when the state is “how loud was my iPhone before I went to sleep?”
DevOps at home sometimes looks ridiculous.
But the test is simple: did the system become calmer?
This one did.