Energy Card

Just to elaborate, a rule created from a template is a rule like any other. It can be viewed and changed like any other UI created rule.

I don’t have the Items to generate @hmerk’s rules yet but I do have a bunch of others. Here’s what a rule created from my Delay Start [4.0.0.0;4.9.9.9] template looks like once I’ve created the rule:

Note I use pure JS Scripting. You’ll see Blockly if you click on the script action to edit it.

The whole rule in the code tab:

configuration:
  pause: ""
  rules:
    - humidity_low_detect
    - thing_status
triggers:
  - id: "1"
    configuration:
      startlevel: 40
    type: core.SystemStartlevelTrigger
  - id: "2"
    configuration:
      startlevel: 70
    type: core.SystemStartlevelTrigger
conditions: []
actions:
  - inputs: {}
    id: "3"
    configuration:
      type: application/javascript
      script: >-
        var {helpers} = require('openhab_rules_tools');

        console.loggerName = 'org.openhab.automation.rules_tools.Delayed Start';

        //osgi.getService('org.apache.karaf.log.core.LogService').setLevel(console.loggerName, 'DEBUG');

        helpers.validateLibraries('4.1.0', '2.0.1');


        // Properties

        var disabledRules = '[hum-low-detect, sensor-status-detection, service-status-detectio, thing_status]'.replace('[','').replace(']', '').split(', ');

        var delay = 'PT1M30S';


        // First time the rule is called at runlevel 40 the flag will be initialized to false

        var alreadyCalled = cache.private.get('flag', () => false);

        var timerTime = (alreadyCalled) ? delay : 0; // run immediately the first run of the rule

        var activity = (alreadyCalled) ? 'enabling' : 'disabling';

        var when = (alreadyCalled) ? 'after ' + delay : 'immediately';


        console.info('Delayed Start triggered, ' + activity + ' rules ' + when);


        helpers.createTimer(timerTime, () => disabledRules.forEach(rule => {
          console.info(activity, rule);
          try {
            rules.setEnabled(rule, alreadyCalled);
          }
          catch(e) {
            console.error('Failed to enable/disable rule ' + rule + ': ' + e);
          }
        }), 'delayedStart');

        cache.private.put('flag', true);
    type: script.ScriptAction

Except for the configuration block at the top, this rule is indistinguishable from a rule created by hand in every meaningful way. The template gives you a complete rule and what you do with the rule once it’s created is up to you.