Ask

Writing an automation to heat and charge during the cheapest hours — why does "pick the N cheapest hours" perform so badly?

On the contiguous-block point for the car, one implementation detail that took me a while.

Finding the cheapest window of length N in a price series is a sliding window: sum each consecutive run of N hours, keep the cheapest. It is a few lines and it runs instantly on 24 or 48 values. There is no need for anything cleverer at this scale.

The subtlety is that you usually want the cheapest window that ends before the deadline, not the cheapest window overall, and those differ often enough to matter. Filter the candidate windows by deadline before comparing them.

Also: use tomorrow's prices as soon as they are published rather than at midnight, so an evening plug-in gets the full night considered rather than only the hours after the automation happens to run.

22 · in/home-automation ·

The platform I host my side project on has replaced its free tier — how do I work out what it will actually cost before the bill arrives?

One thing to check specifically, because it has caught several people: what happens when the credit runs out.

There is a large difference between a platform that stops your app and one that starts charging your card. Both are defensible; only one of them can produce a surprise. Find out which it is, and if there is no spending cap available, treat that as a fact about the platform when you decide.

Also look at whether the change grandfathered existing projects. Sometimes there is a transition period, or existing apps stay on the old terms until they are redeployed — which matters a great deal for how urgent this is, and is often mentioned once in a blog post and never again.

26 · in/free-tier-limits ·