[HELP] Build controller home and boiler heating

You have gaps in your times, but that shouldn’t matter much. The current state will continue through the gap. But you don’t really need the and part of the condition if you restructure your if statements.

Instead if if/else if you can just use if statements and see if now is after the start of one of your times of day.

Or you can create a simple rule for each time of day.

configuration: {}
triggers:
  - id: "1"
    configuration:
      time: 06:00
    type: timer.TimeOfDayTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      state: MORNING
      itemName: TimeOfDay
    type: core.ItemStateUpdateAction

Repeat for each time of day.

If you want to get fancy, you can put the start times for each time of day into an Item that can be adjusted from the UI. The advantage of doing that is that then your times of day can be based on times that come from Astro, a weather binding, iCal binding, alarm clock event, etc.

configuration: {}
triggers:
  - id: "3"
    configuration:
      timeOnly: "true"
      itemName: AlarmClock
    type: timer.DateTimeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      state: MORNING
      itemName: TimeOfDay
    type: core.ItemStateUpdateAction

Again, repeat for each time of day.

Finally, if you want different start times or different time periods for different types of days (e.g. on weekends MORNING starts later, on holidays MORNING is skipped) then Time Based State Machine is what you’d want to use.

To set up the above in Time Based State Machine you’d do the following:

  1. Create a Group Item, I’ll call it “TimesOfDay”
  2. Create a DateTime Item for each time of day and make each a member of “TimesOfDay”
  3. Populate each Item with a valid state. Only the time portion is used. See DateTime List Item and DateTime Standalone Widget to do so from MainUI easily. For example, you’d set the Item “Night” to 22:00.
  4. Set the metadata for each Item to tell the rule what state the Item represents and what type of day the Item applies to. You’d use “tsm” for the namespace (unless you change it in the next step). For something like this, you’d only have one set for “default”. The “Night” Item’s metadata would look like this:
value: NIGHT
config:
  type: default
  1. Create the rule from the template, choosing the Group created in 1 and the Status_Time_Of_Day_By_Rule Item as the Item. Leave the namespace blank for the default “tsm”.

Thanks a lot! This is really great info!