Skip to content

Instantly share code, notes, and snippets.

@DavidDeSloovere
Last active December 23, 2025 09:12
Show Gist options
  • Select an option

  • Save DavidDeSloovere/44e5e56cb13f4662f18021b32587f374 to your computer and use it in GitHub Desktop.

Select an option

Save DavidDeSloovere/44e5e56cb13f4662f18021b32587f374 to your computer and use it in GitHub Desktop.
Self executing Snowflakes as a JS module

Home Assistant

  • Create snowflakes.js under config\www folder.
  • Add content from the gist
    • Choose to run always (remove all below line 4),
    • Or by date (remove line 4, optionally editing the dates you want the snowflakes to trigger)
    • and save.
  • In HA, go to Configuration > Lovelace Dashboards > Resources.
  • Click 'Add Resources' and enter local/snowflakes.js (it's a JavaScript module)
  • Save it
  • Enjoy the holidays

Using https://github.com/hcodes/snowflakes

import Snowflakes from 'https://cdn.skypack.dev/magic-snowflakes';
// always run
new Snowflakes();
// OR use date
// month in JS dates are zero-based
const currentMonth = new Date().getMonth() + 1;
const currentDay = new Date().getDate();
// run from december 6th to january 15th
const isOkForDecember = currentMonth === 12 && currentDay >= 6;
const isOkForJanuary = currentMonth === 1 && currentDay <= 15;
if (isOkForDecember || isOkForJanuary ) {
new Snowflakes();
}
@dnestico
Copy link

dnestico commented Mar 8, 2024

Perfect! Will update the code now forsure.

@dnestico
Copy link

dnestico commented Dec 23, 2025

This has stopped working in 2025 unfortunately, weird. Maybe cuz not using the shell command / automation anymore on my new HA instance? I'm using the 3rd option so thought that should already do the same thing without any automation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment