npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

homebridge-hydroquebec-peak-virtual-switch

v0.0.19

Published

Virtual Switch that turns ON and OFF based on Hydro-Quebec Peak Hours

Readme

homebridge-hydroquebec-peak-virtual-switch

Hombridge Hydro-Quebec plug-in (integration) that relies on Hydro-Quebec's Open Data APIs to determine wether a peak period is currently ongoing and based on that, turns ON or OFF a HomeKit virtual switch.

There are actually three (3) virtual switches to represent each of the following relevant periods:

  • PEAK -> An Hydro-Quebec peak period is actually ongoing
  • PRE_PEAK -> Period before Hydro-Quebec peak period (typically 0am-3am and 10am-2pm)
  • PRE_PRE_PEAK -> Period before pre-peak period (typically 9pm-0am and 7am-11am)

Switch states:

  • ON -> The given period is currently ongoing
  • OFF -> The given period is NOT currently ongoing

At any given time, only one of the virtual switches will report ON, all others will be reporting OFF.

In case of overlap, the PEAK switch wins over the other switches, and the PRE_PEAK switch wins over the PRE_PRE_PEAK switch.

With these virtual switches, you can then use HomeKit automations to turn other devices ON/OFF when any of these virtual switches change state (ON/OFF), to have even more electicity savings during these different pre/peak periods.

API Reference:

  • https://donnees.hydroquebec.com/explore/dataset/evenements-pointe/information/

  • https://donnees.hydroquebec.com/explore/dataset/evenements-pointe/api/?sort=offre

Update schedule

All 3 virtual switches will update themselves using the following schedule:

  • On Homebridge plug-in startup

  • Every day at 06:00 EST (peak AM begin)

  • Every day at 10:00 EST (peak AM end)

  • Every day at 00:00 EST (pre-peak AM begin)

  • Every day at 05:59 EST (pre-peak AM end)

  • Every day at 21:00 EST (pre-pre-peak AM begin)

  • Every day at 23:59 EST (pre-pre-peak AM end)

  • Every day at 16:00 EST (peak PM begin)

  • Every day at 20:00 EST (peak PM end)

  • Every day at 10:00 EST (pre-peak PM begin)

  • Every day at 15:59 EST (pre-peak PM end)

  • Every day at 07:00 EST (pre-pre-peak PM begin)

  • Every day at 09:59 EST (pre-pre-peak PM end)

Actual Hydro-Quebec API being called by the plug-in

GET https://donnees.hydroquebec.com/api/explore/v2.1/catalog/datasets/evenements-pointe/records

Query parameters added to the URL above:

  • where=offre = "CPC-D
  • order_by=datedebut desc
  • limit=5

Sample API response:

{
  "total_count":8,
  "results":[
    {
      "offre":"CPC-D",
      "datedebut":"2025-01-20T21:00:00+00:00",
      "datefin":"2025-01-21T01:00:00+00:00",
      "plagehoraire":"PM",
      "duree":"PT04H00MS",
      "secteurclient":"Residentiel"
    },
    {
      "offre":"CPC-D",
      "datedebut":"2025-01-16T11:00:00+00:00",
      "datefin":"2025-01-16T14:00:00+00:00",
      "plagehoraire":"AM",
      "duree":"PT03H00MS",
      "secteurclient":"Residentiel"
    },
    {
      "offre":"CPC-D",
      "datedebut":"2025-01-08T21:00:00+00:00",
      "datefin":"2025-01-09T01:00:00+00:00",
      "plagehoraire":"PM",
      "duree":"PT04H00MS",
      "secteurclient":"Residentiel"
    },
    {
      "offre":"CPC-D",
      "datedebut":"2025-01-08T11:00:00+00:00",
      "datefin":"2025-01-08T14:00:00+00:00",
      "plagehoraire":"AM",
      "duree":"PT03H00MS",
      "secteurclient":"Residentiel"
    },
    {
      "offre":"CPC-D",
      "datedebut":"2025-01-06T21:00:00+00:00",
      "datefin":"2025-01-07T01:00:00+00:00",
      "plagehoraire":"PM",
      "duree":"PT04H00MS",
      "secteurclient":"Residentiel"
    }
  ]
}