[SOLVED] Trigger based on calendar entries/school vacation

Hi

is there maybe a way to trigger events based on calendar entries (iCal, exchange …) or school vacation?

cheers
Wolfgang

Hi @jipp,

there is no official iCal parser yet (eventually there will be one). Currently you could do this in Node-BLUE with PHP by using one of the iCal libraries.

Cheers,

Sathya

1 Like

E. g.: https://github.com/fangel/SG-iCalendar

Place the library in /var/lib/homegear/phpinclude then you can use it within the function node.

1 Like

Hi

I did a quick workaround by adding a function node which only forwards the input signal in case a certain date is not in the list - in this case an array with bankholidays:

$now = new DateTime();

$array = array(
    "2018 01 01", 
    "2018 03 30",
    "2018 04 02",
    "2018 05 01",
    "2018 05 10",
    "2018 05 21",
    "2018 05 31",
    "2018 10 03",
    "2018 11 01",
    "2018 12 25",
    "2018 12 26");

foreach($array as $value) {
    print $now->format('Y m d');
    if ($value != $now->format('Y m d')) {
        return $message;
    }
}

will try to add the ical approach later.

Hi

finally wrote my own ical class - not a brilliant coder, but tried to wrote my 1st php class.

I downloaded the ics file and placed it into “/data/homegear/”.

the class Ical.zip (699 Bytes) is extracted placed it into the folder:
/var/lib/homegear/phpinclude
ls -l
total 8
-rw-r–r-- 1 root root 1522 Feb 8 16:11 Ical.php

I added the following to a function node with two outputs (one for the signal forwarding - 0 and one for logging - 1):
require(‘Ical.php’);

$ical = new Ical("/data/homegear/feiertage_nordrhein-westfalen_2018.ics");
$found = $ical->match();

if (isset($found)) {
    $message["payload"] = $found;
    output(1, $message);
} else {
    output(0, $message);
}

it will forward the input signal after checking either to output 0 or in case its a vacation day the name of the entry to output 1.

cheers
Wolfgang

2 Likes