Description
It would be nice if the schedule included the ability to insert thunderstorms.
Example:
User decides that starting at 4:30pm every day, there should be a 20% chance of a thunderstorm lasting 30 minutes should occur. This is added as a special event into their schedule JSON.
The easiest way to implement this is to make a Behavior that handles the thunderstorm. It should have a higher priority than the basic ramp. It can fire at fairly short intervals to mimic lightning. It may also be worth making it possible for an active behavior to set the next run time for the behavior job to lessen some of the load on the CPU, letting it idle between lighting strikes. Since it will want to do updates to the PWM at rates on the order of a millisecond during a lightning strike, but go dormant for multiple seconds afterwards.
The trick here I think is to handle the down/up ramp of the lighting to simulate clouds when entering the thunderstorm and leaving it. Ramping down to the thunderstorm is easy, but ramping back up afterwards can be tricky. I'm thinking of situations where the ramp back up crosses an event point in the schedule. We may want to think about leveraging something like the "Behavior Plugin" during the transitions, and a Behavior for the thunderstorm itself.