Premium Only Content
![AC Diversion Load, Part 5](https://1a-1791.com/video/s8/1/6/P/l/7/6Pl7e.qR4e-small-AC-Diversion-Load-Part-5.jpg)
AC Diversion Load, Part 5
Reworked the PL code to work with the positive/negative power readings that were unlocked in the previous video.
It's amazing what knowing the actual power and direction of flow makes in the code. Before, it was a guessing game and now it's a simple computation.
This is my first time working with "conditional values" in PL along with logic expressions in actions. The Vera controllers use the Lua programming language and PL uses a Lua-like syntax as well. On thing that's "missing" is you can't have assignment expressions, like a=b+c. Instead, you need to make a condition called "a" and determine it's value as the result of (b+c). Then you can use the value in "a" as a variable in other expressions. I like to keep expressions simple and compute just one thing at a time. This helps as you can see the intermediate results.
The key to this computation was to keep everything in floating point. My original code was integer-based and had a problem when it kept ignoring small ~1 watt changes in power. Over time those small changes would build up and until there was a big change of 7 or more watts, nothing would happen. With the floating point code, you keep accumulating the changes and once that rounds up or down to a different number, a change is made.
The other key point is to have only ONE variable tracking the dimmer setting. Before I had tried to use a counter to handle incrementing/decrementing the dimmer setting, then writing that counter value to the dimmer. This was before I figured out the "conditional values" and was an easy way to add or subtract numbers in a variable. However, this created a problem in that the counter and the dimmer could get out of sync. Moving to just having a device property that follows the dimmer setting solved that issue. With only one copy, it can't get out of sync. It also allows manually adjusting the dimmer to see how the code reacts.
Also tried to incorporate features into the code to reduce Z-Wave network traffic as well as spread that and the CPU load out in time. This should help reduce bottlenecks and synchronization issues. For example, the time delay between getting the power sample and then acting on any changes allows all the computations to take place before the logic that makes changes runs.
Hardware:
In-wall dimmer: https://amzn.to/3qughPz
Ceramic heat lamp https://amzn.to/3jpdcP8
HEM Gen5 https://amzn.to/3iEgf4i
More to come, seeing what other features are possible with this code...
Subscribe for more content like this
Comment, rate, share & click the bell icon
And as always, thanks for watching
Intro/Outro:
Louisiana Fairytale by Austin Rogers
https://web.archive.org/web/20170402222425/http://drfiddle.com/show_tune.php?id=94
-
1:19:23
Josh Pate's College Football Show
4 hours ago $0.33 earnedBig Ten Program Rankings | What Is College Football? | Clemson Rage| Stadiums I Haven’t Experienced
30.1K -
LIVE
Vigilant News Network
10 hours agoBombshell Study Reveals Where the COVID Vaccine Deaths Are Hiding | Media Blackout
2,144 watching -
1:17:59
Sarah Westall
6 hours agoDOGE: Crime & Hysteria bringing the Critics & the Fearful - Plus new CDC/Ukraine Crime w/ Dr Fleming
21.2K3 -
45:39
Survive History
11 hours ago $2.17 earnedCould You Survive in the Shield Wall at the Battle of Hastings?
20.9K5 -
1:50:28
TheDozenPodcast
10 hours agoViolence, Abuse, Jail, Reform: Michael Maisey
54.3K2 -
23:01
Mrgunsngear
1 day ago $0.68 earnedWolfpack Armory AW15 MK5 AR-15 Review 🇺🇸
54.5K12 -
25:59
TampaAerialMedia
1 day ago $1.31 earnedUpdate ANNA MARIA ISLAND 2025
30.8K3 -
59:31
Squaring The Circle, A Randall Carlson Podcast
12 hours ago#039: How Politics & War, Art & Science Shape Our World; A Cultural Commentary From Randall Carlson
23.9K2 -
13:21
Misha Petrov
12 hours agoThe CRINGIEST Thing I Have Ever Seen…
19.3K45 -
11:45
BIG NEM
8 hours agoWe Blind Taste Tested the Best Jollof in Toronto 🇳🇬🇬ðŸ‡
12.7K