Public Access
Rules can be limited to schedule blocks
Each rule has the blocks it acts in (none: always; without a running schedule always). Stored as a block mask (schedule format 2, version 1 records are converted), in JSON as the blocks' start times. Version 2.7.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
87e242bf89
commit
53e9057d02
11 files changed
+166
-19
No files matched your search
@@ -1708,6 +1708,38 @@ void test_selector_take_over_rules()
|
||||
TEST_ASSERT_TRUE(c.instant); // a rule's page leaves at once
|
||||
}
|
||||
|
||||
void test_selector_rules_only_in_their_blocks()
|
||||
{
|
||||
PageSchedule s = twoBlocks(); // 07:00 Weer + Datum, 17:00 Energie
|
||||
s.rule_count = 2;
|
||||
s.rules[0] = rule("3D printer", TriggerMode::WhileTrue);
|
||||
s.rules[0].blocks = 1 << 1; // only from 17:00
|
||||
s.rules[1] = rule("Deurbel", TriggerMode::AddToRotation, 10);
|
||||
s.rules[1].blocks = 1 << 0; // only in the morning block
|
||||
TEST_ASSERT_NULL(validateSchedule(s));
|
||||
PageSelector sel;
|
||||
sel.setSchedule(&s);
|
||||
sel.update(8 * 60, 0);
|
||||
sel.setRuleState(0, true, 0);
|
||||
TEST_ASSERT_EQUAL_STRING("Weer", sel.update(8 * 60, 1000).page); // not in this block
|
||||
TEST_ASSERT_EQUAL_STRING("3D printer", sel.update(17 * 60, 2000).page);
|
||||
sel.setRuleState(0, false, 3000);
|
||||
sel.setRuleState(1, true, 3000);
|
||||
sel.update(17 * 60, 3000);
|
||||
TEST_ASSERT_EQUAL_STRING("Energie", sel.update(17 * 60, 40000).page); // not added here
|
||||
|
||||
// Without a running schedule the blocks don't matter
|
||||
s.enabled = false;
|
||||
sel.setRuleState(0, true, 50000);
|
||||
TEST_ASSERT_EQUAL_STRING("3D printer", sel.update(8 * 60, 50000).page);
|
||||
|
||||
s.enabled = true;
|
||||
s.rules[0].blocks = 1 << 2; // a third block doesn't exist
|
||||
TEST_ASSERT_NOT_NULL(validateSchedule(s));
|
||||
TEST_ASSERT_TRUE(ruleInBlock(s.rules[1], -1));
|
||||
TEST_ASSERT_FALSE(ruleInBlock(s.rules[1], 1));
|
||||
}
|
||||
|
||||
void test_selector_add_to_rotation()
|
||||
{
|
||||
PageSchedule s = twoBlocks();
|
||||
@@ -1984,6 +2016,7 @@ int main()
|
||||
RUN_TEST(test_selector_manual_pick_until_the_next_block);
|
||||
RUN_TEST(test_selector_one_block_starts_again_each_day);
|
||||
RUN_TEST(test_selector_take_over_rules);
|
||||
RUN_TEST(test_selector_rules_only_in_their_blocks);
|
||||
RUN_TEST(test_selector_add_to_rotation);
|
||||
RUN_TEST(test_ha_auto_unit_and_absolute);
|
||||
RUN_TEST(test_ha_duration);
|
||||
|
||||
Reference in new issue
Block a user