Scheduler

From ago control wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "= Ago Scheduler = The ago scheduler module allows triggering action on specific times of theday. You can add one or many times of day to a device, a group of devices or to a...")
 
(File format)
 
(20 intermediate revisions by one user not shown)
Line 1: Line 1:
 
= Ago Scheduler =
 
= Ago Scheduler =
The ago scheduler module allows triggering action on specific times of theday.  
+
The ago scheduler module allows triggering action on specific times of the day.
  
You can add one or many times of day to a device, a group of devices or to a scenarion. You can add on or many rules to the event. Some examples:
+
Status: Early development. Cannot be installed automatically.
* Run scenarion for closing the drapes and switch on the porch light at 19:00, but oly if the housemode = "At home".
+
 
 +
You can add one or many times of day to a device, a group of devices or to a scenario. You can add one or many rules to the event. Some examples:
 +
* Run scenarion for closing the drapes and switch on the porch light at 19:00, but only if housemode is "At home".
 
* Irrigate the lawn every Tue 9:00am and Fri 8:00pm
 
* Irrigate the lawn every Tue 9:00am and Fri 8:00pm
...
 
 
* Turn on all window lights 30 minutes before sunset.
 
* Turn on all window lights 30 minutes before sunset.
  
== Configuration ==
+
== Schedules ==
As of now, there's no UI to create the scedulesFor now, you'll need to edit a json file to suit your needs.
+
As of now, there's no UI to create the scedules. For now, you'll need to edit a json file to suit your needs.
 +
The scheduler file has to be placed in the config dir (e.g. /etc/opt/agocontrol/conf.d/). You can name the schedule file as you like and have more than one file. You use the scheduler.conf file to control which scheduler file to activate. You could e.g. have a winter.json and a summer.json schedule that are different.
  
 
=== File format ===
 
=== File format ===
Line 20: Line 22:
 
         "actions": [
 
         "actions": [
 
           {
 
           {
             "action": "on", "time": "08:00", "days": ["weekdays"], "enabled": true
+
             "action": "on", "time": "08:00", "days": ["weekdays"], "enabled": true, "fixed": true
 
           },
 
           },
 
  ... more actions for this device
 
  ... more actions for this device
Line 52: Line 54:
 
         "actions": [
 
         "actions": [
 
           {
 
           {
             "action": "on", "time": "06:00", "days": ["tu"], "enabled": true
+
             "action": "on", "time": "06:00", "days": ["tu"], "enabled": true", "random": true, "random_minutes": 15
 
           },
 
           },
 
           {
 
           {
             "action": "off", "time": "06:00", "days": ["tu"], "enabled": true
+
             "action": "off", "time": "09:00", "days": ["tu"], "enabled": true
 
           }
 
           }
 
         ]
 
         ]
Line 89: Line 91:
 
  }
 
  }
  
 +
=== Element explaination ===
 +
==== action ====
 +
on, off, setlevel, fade, run
  
=== Days ===
+
==== time ====
Days can have the following content: "all", "weekdays", "weekends" or any combination of "mo", "tu", "we", "th", "fr", "sa", "su"
+
time:   Time in hh:mm format, of sunrise, sunset with or withour offset (e.g. sunrise-22m)
  
=== Time format ===
 
 
The time field can have either fixed times, expressed in 24h format, e.g. "06:00", "17:25", "23:57"
 
The time field can have either fixed times, expressed in 24h format, e.g. "06:00", "17:25", "23:57"
 
It can also be "sunrise" or "sunset", or a time relative to those. 20 minutes before sunrise would be stated as "sunrise-20m". The time offset has to be stated in minutes; also if you want longer periods of time. 2 hours before sunset would be stated as "sunset-120m"
 
It can also be "sunrise" or "sunset", or a time relative to those. 20 minutes before sunrise would be stated as "sunrise-20m". The time offset has to be stated in minutes; also if you want longer periods of time. 2 hours before sunset would be stated as "sunset-120m"
 +
 +
==== days ====
 +
Days can have the following content: "all", "weekdays", "weekends" or any combination of "mo", "tu", "we", "th", "fr", "sa", "su"
 +
 +
==== enabled ====
 +
true -  This row is active <br>
 +
false - Ignore it
 +
 +
==== fixed ====
 +
true -  Do not apply random delta to this  <br>
 +
false - Apply random delta to this  <br>
 +
missing row = false
 +
 +
==== random ====
 +
true -  Override random setting  <br>
 +
false - Apply default randomsetting  <br>
 +
missing row = false
 +
 +
==== random_minutes ====
 +
Number of minutes to use when doing random calculation
 +
 +
== Configuration ==
 +
The scheduler execution is controlled with scheduler.conf, placed  in the config dir (e.g. /etc/opt/agocontrol/conf.d/). Example:
 +
[scheduler]
 +
schedule=winter.json          <-- Which schedule file do you want to use?
 +
log_level=info
 +
print_daily_schedule=No        <-- Should you print the schedule to the log when you shift day?
 +
random=5                      <-- If you want to use a random time delta, state the number of minutes.
 +
 +
 +
=== Print daily schedule to log ===
 +
With the 'print_daily_schedule' parameter you can select to print the daily schedule. Example:
 +
 +
INFO: 05:52  Scenario - Plant lights on          - run
 +
INFO: 08:00 ----> now <----
 +
INFO: 08:05  Device  - Lampa 1111-1111          - on
 +
INFO: 08:19  Device  - 2222-2222                - dim
 +
INFO: 08:54  Device  - Lampa 1111-1111          - off
 +
INFO: 17:02* Group    - Living room              - on
 +
INFO: 20:38  Device  - 2222-2222                - fadedown
 +
INFO: 21:37  Device  - 2222-2222                - fadedown
 +
INFO: 21:52  Group    - Living room              - off
 +
INFO: 23:02  Device  - 2222-2222                - off
 +
 +
The 17:02* means it's a time based on sunrise or sunset.
 +
All times in the above example are random times with a 5 minutes plus/minus the base time.
 +
 +
== Known problems ==
 +
Not much error handling in place when it goes to content parsing. Most errors in the scheduler json file will be ignored. If you're not getting the scheduler to work, test the validity of your json file by loading it to [http://www.jsoneditoronline.org/] and you'll see any format errors.
 +
 +
Scheduler json files need to be UTF-8 and strangely, local characters (e.g. åäö) mess up the parser, so skip those for now.

Latest revision as of 22:42, 16 February 2017

Contents

[edit] Ago Scheduler

The ago scheduler module allows triggering action on specific times of the day.

Status: Early development. Cannot be installed automatically.

You can add one or many times of day to a device, a group of devices or to a scenario. You can add one or many rules to the event. Some examples:

  • Run scenarion for closing the drapes and switch on the porch light at 19:00, but only if housemode is "At home".
  • Irrigate the lawn every Tue 9:00am and Fri 8:00pm
  • Turn on all window lights 30 minutes before sunset.

[edit] Schedules

As of now, there's no UI to create the scedules. For now, you'll need to edit a json file to suit your needs. The scheduler file has to be placed in the config dir (e.g. /etc/opt/agocontrol/conf.d/). You can name the schedule file as you like and have more than one file. You use the scheduler.conf file to control which scheduler file to activate. You could e.g. have a winter.json and a summer.json schedule that are different.

[edit] File format

{
"items":
[
   {
     "device": "1111-1111", "name": "Lamp in window",
     "enabled": true,
       "actions": [
         {
           "action": "on", "time": "08:00", "days": ["weekdays"], "enabled": true, "fixed": true
         },
... more actions for this device
       ]
   },
   {
     "device": "2222-2222",
     "enabled": true,
       "actions": [
         {
           "action": "dim", "level": 100, "time": "08:10", "days": ["all"], "enabled": true, "comment": "xyz"
         },
... more actions for this device
       ]
   },
   {
     "scenario": "4321-4321", "name": "Plant lights on",
     "enabled": true,
       "actions": [
         {
           "action": "run", "time": "06:00", "days": ["mo", "we", "sa"], "enabled": true, "rule": "1234-1234"
         },
         {
           "action": "run", "time": "15:00", "days": ["tu", "th", "su"], "enabled": true, "rule": "1234-1234"
         }
       ]
   },
   {
     "group": "5555-5555",
     "enabled": true,
       "actions": [
         {
           "action": "on", "time": "06:00", "days": ["tu"], "enabled": true", "random": true, "random_minutes": 15
         },
         {
           "action": "off", "time": "09:00", "days": ["tu"], "enabled": true
         }
       ]
   }
 ],
"rules":
 [
   {
     "name": "Alarm - at home",
     "uuid": "1234-1234",
     "rules": [
       {
         "type": "variable check",
         "variable": "HouseMode",
         "operator": "eq",
         "value": "At home"
       }
     ]
   },
   {
     "name": "Alarm - empty house",
     "uuid": "1235-1235",
     "rules": [
       {
         "type": "variable check",
         "variable": "HouseMode",
         "operator": "eq",
         "value": "Empty"
       }
     ]
   }
 ]
}

[edit] Element explaination

[edit] action

on, off, setlevel, fade, run

[edit] time

time: Time in hh:mm format, of sunrise, sunset with or withour offset (e.g. sunrise-22m)

The time field can have either fixed times, expressed in 24h format, e.g. "06:00", "17:25", "23:57" It can also be "sunrise" or "sunset", or a time relative to those. 20 minutes before sunrise would be stated as "sunrise-20m". The time offset has to be stated in minutes; also if you want longer periods of time. 2 hours before sunset would be stated as "sunset-120m"

[edit] days

Days can have the following content: "all", "weekdays", "weekends" or any combination of "mo", "tu", "we", "th", "fr", "sa", "su"

[edit] enabled

true - This row is active
false - Ignore it

[edit] fixed

true - Do not apply random delta to this
false - Apply random delta to this
missing row = false

[edit] random

true - Override random setting
false - Apply default randomsetting
missing row = false

[edit] random_minutes

Number of minutes to use when doing random calculation

[edit] Configuration

The scheduler execution is controlled with scheduler.conf, placed in the config dir (e.g. /etc/opt/agocontrol/conf.d/). Example:

[scheduler]
schedule=winter.json           <-- Which schedule file do you want to use?
log_level=info
print_daily_schedule=No        <-- Should you print the schedule to the log when you shift day?
random=5                       <-- If you want to use a random time delta, state the number of minutes.


[edit] Print daily schedule to log

With the 'print_daily_schedule' parameter you can select to print the daily schedule. Example:

INFO: 05:52  Scenario - Plant lights on           - run
INFO: 08:00 ----> now <----
INFO: 08:05  Device   - Lampa 1111-1111           - on
INFO: 08:19  Device   - 2222-2222                 - dim
INFO: 08:54  Device   - Lampa 1111-1111           - off
INFO: 17:02* Group    - Living room               - on
INFO: 20:38  Device   - 2222-2222                 - fadedown
INFO: 21:37  Device   - 2222-2222                 - fadedown
INFO: 21:52  Group    - Living room               - off
INFO: 23:02  Device   - 2222-2222                 - off

The 17:02* means it's a time based on sunrise or sunset. All times in the above example are random times with a 5 minutes plus/minus the base time.

[edit] Known problems

Not much error handling in place when it goes to content parsing. Most errors in the scheduler json file will be ignored. If you're not getting the scheduler to work, test the validity of your json file by loading it to [1] and you'll see any format errors.

Scheduler json files need to be UTF-8 and strangely, local characters (e.g. åäö) mess up the parser, so skip those for now.

Personal tools