This repository contains a package-based Home Assistant automation designed to intelligently control roof de-icing heat tape in cold, snowy climates (especially mountain and north-facing roofs).
The goal is to prevent ice dams while minimizing electricity cost, by running heat tape only when it is effective and only during off-peak hours.
- Prevent ice dams without running heat tape continuously
- Avoid running heat tape when it is ineffective (too cold or already melting)
- Respect Time-of-Use (TOU) electric pricing
- Handle real-world weather data imperfections
- Allow safe manual override without fighting automation
- Allow normal UI automations to coexist safely
This project is implemented as a Home Assistant package.
- Heat-tape automations are file-managed and GitHub-tracked
- All other automations may continue to be created/edited in the Home Assistant UI
- No duplicate IDs or automation conflicts
packages/
└── heat_tape_package.yaml
All heat-tape automations live inside this single file.
Add (or merge) this into configuration.yaml:
homeassistant:
packages: !include_dir_named packagesCopy heat_tape_package.yaml into:
/config/packages/heat_tape_package.yaml
(If you prefer a different filename you may rename the file during install; the automations expect the entities and helpers described below.)
Go to: Settings → Devices & Services → Helpers → Create Helper
- Type: Toggle
- Name:
Freeze latch - Entity ID (recommended):
input_boolean.freeze_latch
Purpose: internal latch used by automations.
Normal use: do not manually control this.
- Type: Toggle
- Name:
Snow in last 12 days - Entity ID (required):
input_boolean.snow_in_last_12_days
Purpose: “permit” switch that gates heat tape operation.
- Set automatically by snow detection
- Safe for manual override from a dashboard
- Type: Timer
- Name:
Snow recent 12d timer - Entity ID (required):
timer.snow_recent_12d_timer - Duration: 288:00:00 (12 days)
Notes:
- Some UIs show only hours/min/sec. Enter 288 hours.
- Timers can show idle after Home Assistant restarts; this project restores the timer correctly (see “Reboot-safe” section below).
- Type: Date and/or Time
- Name:
Last snow detected - Entity ID (required):
input_datetime.last_snow_detected - Enable: Date and Time
Purpose: reboot-safe tracking of the last detected snow (or manual enable). This allows Home Assistant to correctly restore the “recent snow” window even after a restart.
Important: configure this input_datetime with both date and time (including seconds) to ensure correct parsing of timestamps written by the automations.
A full restart is required.
Product page:
https://www.thesmartesthouse.com/products/zooz-z-wave-long-range-high-power-relay-zen78-800lr
Why this relay works well for heat tape:
- 40A resistive load rating
- Supports 120–277V
- Z-Wave 800 Long Range
- Built-in energy monitoring
- Eliminates need for external contactor in most installs
Heat tape is a high-amperage load. Use a properly sized breaker, follow local code (often GFCI/GFPE), and consult a licensed electrician if unsure.
All weather logic uses Pirate Weather.
Enable:
weather.pirateweathersensor.pirateweather_temperaturesensor.pirateweather_precip_intensitysensor.pirateweather_current_day_snow_accumulation
update_interval: 1200 # seconds (20 minutes)Why 1200 seconds:
- Safe for shared API keys (especially if you have two HA instances)
- Prevents rate-limit errors (429)
- Snow logic uses debounce + long windows, so faster updates provide little benefit
A snow event is detected when any of the following are true for at least 10 continuous minutes:
'snow' in weather state
or precip_intensity > 0.02 in/hr
or current_day_snow_accumulation >= 0.2 inThis project uses three layers:
input_datetime.last_snow_detected(truth / durable)input_boolean.snow_in_last_12_days(permit flag)timer.snow_recent_12d_timer(UI countdown)
last_snow_detectedis stamped with the current timesnow_in_last_12_daysturns ON- the 12-day timer starts/resets
Timers often restore as idle, even if the snow flag is still ON.
To fix that, the package includes an automation that:
- recomputes how long it has been since
last_snow_detected - turns the permit ON/OFF correctly
- restarts the timer with the remaining duration
Note: the automation formats the remaining duration as an explicit HH:MM:SS string when restarting the timer for robust behaviour across HA versions.
If you manually turn OFF snow_in_last_12_days, the package:
- cancels the timer
- clears
last_snow_detected(the automation sets it to the sentinel value1970-01-01 00:00:00) - prevents a restart from immediately re-enabling the snow window
Heat tape runs only when:
- Snow occurred recently (permit is ON)
- Temperature is 25–39°F
- Time is within the off-peak daylight window (06:00 → 15:55)
Below ~25°F heat tape is often ineffective.
Above ~39°F natural melting dominates.
System runs only during:
- 06:00 → 15:55
At 15:55 daily:
- heat tape turns OFF
- freeze latch clears
Note: triggers at exact boundary times combined with after/before conditions can be sensitive to inclusivity semantics; if you observe missed events at 06:00, consider adjusting the condition bounds slightly or use a template-based time condition.
| Automation | Purpose |
|---|---|
| Heat Tape – Freeze – Latch ON | Enables system during melt band |
| Heat Tape – Freeze – Maintain ON | Enforces correct on/off behavior |
| Heat Tape – Freeze – Daily reset | Stops system before TOU peak |
| Heat Tape – Snow – Start timer | Detects snow and stamps last snow time |
| Heat Tape – Snow – Recompute after restart | Restores recent-snow window after HA restart |
| Heat Tape – Snow – Clear flag | Clears snow permit when timer ends |
| Heat Tape – Snow – Cancel timer | Respects manual OFF and clears last-snow time |
Apache License 2.0
This project controls high-amperage electrical equipment.
Always follow local electrical codes and consult a qualified electrician.