A helper script for ioBroker
A helper script written in javascript language to set a state or trigger a scene in ioBroker based on events imported to ioBroker with iCal adapter. The script is configurable by JSON properties of the configuration Object. While ioBroker.ical adapter supports Events, those are limited. This helper script can trigger the start before the Calendar event starts (configurable pre-start offset); the end can trigger after the Calendar event ends (configurable post-end offset).
See ioBroker.ical adapter. You will need at least one working iCal instance (referenced as ical.1
further on).
Several iCal instances are possible, create one helper script for each such instance.
See ioBroker.javascript adapter. The helper script is not an adapter itself, therefore you need the ioBroker.javascript adapter (aka Script Engine).
Create a new Script in the Scripts
menu. Select JavaScript
as the the programming language.
Copy the source code of automation4ical.js and paste it into the source code editor.
Check line 11 - your iCal instance must be specified there (e.g. ical.1
).
Save the script. The Script Engine will start it immediately.
Once the helper script is run at least once, it will create the Configuration object.
Open menu Objects
and navigate to 0_userdata
| 0
| automation4ical
| 1cfg
(the number in 1cfg
will change based on your iCal instance).
Edit values in that Configuration Object. An example of the JSON settings is:
{
"minutesPre": 180,
"minutesPost": 60,
"onStartState": "scene.0.room_baseline.mainhall_used",
"onStartVal": true,
"onEndState": "scene.0.room_baseline.mainhall_empty",
"onEndVal": true
}
Pre-start offset in minutes. In example above, the starting scene is triggered 3 hours before the Calendar event starts.
Post-end offset in minutes. In example above, the ending scene is triggered 1 hour after the Calendar event finishes.
The State specified in onStartState
will be set to onStartVal
by the helper script at the calculated start time.
The State specified in onEndState
will be set to onEndVal
by the helper script at the calculated end time.
Heating of several different areas (rooms) in a community center can be automated with ioBroker.
There is a main (public) Google calendar with all events in the center.
For each area a Google account was created with a (non-public) Calendar. Automatic acceptance of new invitations was enabled for such a Calendar.
When we create an Event in the public Calendar, we also invite the Google account(s) of areas, that should be heated before the event starts.
There are several iCal instances in our ioBroker (ical.1
to ical.N
) - one for each (non-public) Calendar of the respective areas.
For each iCal instance there is a helper script and a Configuration Object. Some rooms start heating 1 hour in advance of an event, some start 2 hours in advance and the big ones 3 hours in advance.
We use Scenes for the setup of each of the Rooms 'modes of operation' because this helper script can only assign a Value to a single State at the start or at the finish.
Nothing really planned, but some ideas include:
- The offsets are fixed numbers now, but could be probably calculated dynamically.
- Whole-day events in the Calendar are skipped by the helper script. That is our decision. Could be probably a configurable option.
- Configuration Object is created once (with current set of options), but never updated in case we add new options.
- Vales are written to States with ACK=false. Could be probably a configurable option.
The MIT License (MIT)