Dan in CA
Creating a program for each zone using the existing UI and then modifying the durations for each program on a daily basis would be a good approach
The program data is held in memory as the list of lists gv.pd (program data) and as the file programs.json in the data directory.
The format was ported from Ray’s micro controller code where every bit had to count because of limited memory.
Here is a breakdown of program data that I took straight from Ray’s C code with added notes:
v = 1, //Program enable flag (byte/boolean)
v = 1, //days byte (includes a flag for odd – even restriction) Mon. = 1, high bit: 0 = no restriction and no interval, 1 = odd/even parity or interval enabled.
//When used for interval: high bit = interval on, rest of byte used for days countdown set as “starting in” = days remaining in cycle.
v = 0, //Interval days: if 2 -> 255 = interval enabled (most sig bit set), — if value is 1 (least sig bit set) = odd restriction, if value is 0 = even restriction. This field shows 3 by default in the UI when no interval is selected.
v = 360, //Start time in minutes (from 0 at midnight)
v = 1080, //End time in minutes (from 0 at midnight)
v = 240, //Repeat (cycle) interval in minutes
v = 900, //Duration in seconds for each active zone in this program
v = 1]; //Zones bytes – indicates which zones are active (selected) in this program).
As you can see the duration (in seconds) for a program is stored in element 6 of the program data list. You should be able to modify the duration of any existing program from your plugin.
Here is an example of a program from Python’s gv.pd list:
1, 21, 0, 360, 1080, 240, 900, 21
And the corrisponding program creation page:
EDIT: Here is a web site I found extremely useful for visualizing bit patterns and figuring out what the values in the program data represent
Their Timestamp page is also very helpful
This whole project has been a huge learning experience for me. I think you will gain some valuable knowledge from developing your plugin