DEV Community

Xingliao Smart Home
Xingliao Smart Home

Posted on

A Smart Switch Schedule That Fires Late Is Usually a Clock Problem

Schedules are the most-used feature on a smart switch and the least understood. They are also the only feature that depends on something completely outside the device: an accurate clock. A switch has no real-time clock crystal backed by a battery. It knows the time because somebody told it, and it forgets the moment power is removed.

There is no clock inside the switch

A mains-powered switch can keep rough time by counting mains cycles, and some do. What it cannot do is keep calendar time across a power cut, and it usually cannot tell you the date at all until it has synchronised. So the sequence after power is restored is: boot, join the network, reach a time server, then execute schedules. Everything before that third step either waits or uses a default state.

This explains the pattern people report after a short outage: the lights come back in a state nobody asked for, and the schedules are unreliable for a while afterwards. It is not the schedule engine failing. It is a device that has not been told what time it is.

Three minutes late is normal for a cloud schedule

Where the schedule is executed matters as much as the clock:

  • Cloud-executed schedules run on a server. The server evaluates the rule and sends a command to the device. That path includes network latency, device wake-up, and any retry. A few seconds of delay is expected; a few minutes usually means the device was slow to respond or briefly offline, and the command was queued.
  • Device-executed schedules run locally, so they do not depend on the network at the moment they fire — but they depend entirely on the device having the right time, which it got from the network earlier.

If you need two lights to come on within a second of each other, do not use two independent schedules. Use one automation that controls both, executed in one place. Two schedules are two clocks, and two clocks will disagree.

The failure modes worth knowing

Drift after a long uptime. A device that synchronises once at boot and never again will drift by whatever its oscillator is worth. Over months that can become minutes. Devices that re-synchronise periodically do not have this problem, which is why the symptom is inconsistent between models rather than between brands.

Blocked time synchronisation. Time synchronisation needs outbound access to a time server, which needs DNS. A guest network, a VLAN with no internet route, or a firewall rule that permits web traffic but blocks the time port will leave a device permanently unable to set its clock. The symptom is a switch that works perfectly by app but never runs a schedule.

Timezone and daylight saving. The device, the account and the phone each have a timezone. If they disagree, the schedule runs at the wrong local time — usually by a whole hour, which is the signature of a timezone mismatch rather than a clock fault. Daylight saving is handled in firmware on some devices and ignored on others; a schedule that was correct in October and wrong by an hour in November is almost always this.

Sunrise and sunset schedules add two more inputs: a location and a date. Set the wrong city and the offset is wrong every day of the year, consistently. Set no location at all and the device falls back to a fixed time or refuses the rule.

Stale rules after a network change. Change the router, move to a new access point, or reconfigure the subnet, and a switch that used to synchronise can silently stop. The app still works because the app talks through the cloud and does not prove the device can reach a time server.

Diagnosing it in order

  1. Check whether the device shows a time anywhere in its app. Many expose it on a device info page. If it is blank or obviously wrong, everything else follows from that.
  2. Confirm the timezone in the account and on the phone. One hour of error is a timezone problem, not a clock problem.
  3. Test a schedule five minutes out and time it. Under ten seconds late is normal. Minutes late means the command path is being retried.
  4. Reboot the device and re-test. If it is accurate immediately after a reboot and drifts afterwards, the device is not re-synchronising.
  5. Verify the network permits outbound time synchronisation. Guest networks and isolated IoT VLANs are the usual cause of a device that never learns the time.

What to do if timing actually matters

For anything with a consequence — a hallway light for a child, a heater on a pre-set window, pumping equipment — do not rely on a single device's schedule. Put the automation on a hub or controller that has a battery-backed clock and a reliable time source, and let it command the switch. The switch then becomes an actuator, which is what it is good at, and the clock lives somewhere that was designed to keep one.

For everything else, accept a few seconds of slack. A schedule that turns a porch light on at dusk does not need millisecond accuracy, and it is worth understanding that the device is doing something genuinely difficult: keeping calendar time with no battery, no clock chip and no display, then acting on it months later without supervision.

Wall switch options with local and cloud scheduling are covered in the WiFi smart wall switch OEM and wholesale range, and the wider selection is in the smart switch category. Hub-side automation and timing behaviour are described under the smart home automation system programme, with the full range at XingLiao.

Top comments (0)