[RELEASE] Hydro-Quebec Dynamic Pricing

This app is for Quebec Hubitat users that have subscribed to Hydro Quebec's Dynamic Pricing. This app will help automate all aspects of maximising the use of this program for every program they offer as of Winter 2024-2025.

This will check and add events based on the program you are subscribed to automatically by using the provided JSON file by Hydro Quebec (new for 2025). Based on these events you can...

  • Automations for morning and evening events can be widely different.
  • Have automations run xx number of minutes before the event so that you can bring up the temperature of the house just before the event starts.
  • Automations when the event starts like turn off switched outlets, bring down the temperature by xx number of degrees, etc.
  • Put back the home exactly like it was before the start of the event.
  • Send notifications to your phone for start, end, new events, etc.
  • Send TTS notifications to your speakers as a reminder.
  • Turn a single light on or other indicator that you are in an event period.
  • Disable morning or evening events easily with a switch or virtual switch.
  • When new events have been detected, the app stops poling the JSON file to save on unneeded traffic/resources.
  • After a certain time, if no new events are detected by 6pm, it will stop polling and restart the next day.
  • Pause/Start button for summer time where this program is not needed.

More options coming as; control thermostat scheduler directly from the app (testing to make sure this is possible and can work as expected), decide time when you start poling the JSON file link and for how long until it stops every day. Auto recover and reschedule all current events as any event that is current if the hub is rebooted.

The easiest way to install the app is through HPM by searching for "Hydro Quebec", for those that like it the old way, the link to the raw code is: https://raw.githubusercontent.com/NelsonClark/Hubitat/refs/heads/main/Apps/Hydro-Quebec_Dynamic_Pricing/Hydro-Quebec_Dynamic_Pricing.groovy

4 Likes

V 1.0.1 pushed

  • Added a permanent Poll button, this button will poll and re-schedule all upcomming events
  • Changed time of first pole of the day to 13:13:13 because of a situation where HQ updated the events

Is it possible for your app to turn switches ON?

Seems it can only turn switches OFF.

Reason is to turn ON a switch that triggers rules, etc.

There's one place in notifications that turns on switch but for all events...

If you would need one for each type of event, I can add that tonight.

1 Like

Yes, each type of events turning ON switches would be best to trigger rules, etc.

I could trigger the rules by switches turning off but it is a bit counter intuitive especially if you want to monitor or manually set these switches.

1 Like

First, thank you Nelson your code is REALLY clean and well commented (one of the best).

I have one SMALL problem: When I run the app for the first time, the app crashes in that condition: The next event is in less time than the PRE-event time. Example: If the event is in one hour and I asked for the thermostats to change in TWO hours then the app crashes. I think it happens only when the first time the state.apiData was not filled. Let me know if I'm wrong.

More a question: it seems sendVoiceMessage variables are not used ? Is it he case ?

Could not reproduce this, but then again I was not home to test it in those conditions, will have to check this out but from what I can see, this would definitely be something that would happen on a new install and maybe if settings are changed during an event/pre-event.

I also found the other problem where it used a method that was removed and did not rename to the other one < newPoll() >, this is corrected.

I commented out that section, I was working on it, but then could not test it because I changed my router/WiFi setup for a more robust system and removed the code temporarily, as soon as I get my SONOS speaker back in the game, I will get this working.

Should push a new version tomorrow.

1 Like

Well I had time to get a new version out tonight...

1.0.2 - 2025-01-31

  • Added Triggers, aka switches that turn on during an event to fire other automations.
  • Corrected a bug when first installed and calling a polling method that is no longer available
  • Commented out voice message options as I could not test this anymore, will be back soon as soon as I reinstall my SONOS speaker.
  • Corrected the way pre-events change into events to prevent having some things not return to normal at the end of it all
1 Like

Nelson, I'm doing some tests with your app and I changed a bit the code to do so some stuff I'd like. We received another event for tomorrow evening and we already have on for tonight. In my case it doubles the event for tonight in the schedule. Is it your case also or I just bugged your app ? :wink:

Not on my side...

Can you post your upcomming events?

I was sure it was my fault. Thank's ! Did I say that your code is really nice and well commented ? It's the case. You're doing a great job.

Forget it it's my fault, I will look at it.

I think I know why. Is it possible it is because you run at 23:00 after today's events and I run at 11:30 BEFORE today's evening event ? I think it is the problem.

One weird thing is that I did get the push message to the mobile app about new events added, but never got the message that the pre-event had started, waiting to see at 4pm to see if I get a message then. Added a few trace logs to see if it actually gets inside the "if" statement or if I have a bug somewhere that I just can't see?

I poll the API at 13:13:13 every day, so it was before the event for this evening.

1 Like

Update available, this weekend was great for bug squashing with the events going on.

  • 1.0.3 - 2025-02-02
    • Tweaked the code a bit, added a 10 seconds pause between pre-event and event changes to occur
    • Fixed bug with pushing messages to notification devices
    • Fixed bug with trigger switches (switches turned on during events) that were not turning off at the send of an event
    • Added polling start time (you will need to go change in the app settings and then hit done for this to take effect)
    • Added some more trace logging for future features coming up
    • Various other bug squashing

New update with hub restart recovery and check if within a period when installed.

  • 1.0.4 - 2025-02-05
    • NEW FEATURE, option to recover after a hub reboot, this will cause all scheduled events to be removed and recheck everything, if within an event period, that event will start immediately
    • If the app is started or a manual poll of the API is done, if we are within an event period, that event period will start immediately
    • More tweaking of the code
    • Various other bug squashing

just installed. seems straight forward.
I already have 2 virtual switches (HQ-Peak-AM and PM) that are triggered (when turned on) to heat up the place, turn light off, turn furnace fan off...
easy install. just turn on those 2 switches on. nothing else. oh, and select FlexD residential.
love it.
looking forward to the next cold days.

side question, you did all that code yourself? or all AI? or a mix of both?

Thanks, new stuff coming this weekend including voice announce over speakers (SONOS is tested and working, will be looking for people that uses Echo Speak and other voice enabled devices), might install echo speaks since I do have like 7-8 echo devices around the house.

Never use AI, I want full control of what I code and understand it, what good making an app that you can't understand how it works and can't improve on. Sure I have snippets of other peoples code (why reinvent the wheel).