« Back to Product

Documentation

IPS_CreateEvent

 int IPS_CreateEvent (int $EventType) 

Parameters

EventType
Value Constant Description
0 EVENTTYPE_TRIGGER creates a "triggered" event
1 EVENTTYPE_CYCLIC creates a "cyclical" event
2 EVENTTYPE_SCHEDULE creates a "schedule" event

Returns

ID of the newly created event

Description

The function creates an event object of the type EventType.

The function returns an ID that can be used to uniquely identify the created event object. After creation, the object is still unconfigured and must be configured with the functions IPS_SetEventActive, IPS_SetEventAction and the corresponding IPS_SetEventCyclic / IPS_SetEventTrigger.

Example

$eid = IPS_CreateEvent(EVENTTYPE_TRIGGER);                  //Triggered event
IPS_SetEventTrigger($eid, EVENTTRIGGERTYPE_ONCHANGE, 15754); //On change of variable with ID 15754
IPS_SetParent($eid, $_IPS['SELF']);         //Assign the event
IPS_SetEventActive($eid, true);             //Activate the event

$eid = IPS_CreateEvent(EVENTTYPE_CYCLIC);                  //Cyclic event
IPS_SetEventCyclic($eid, EVENTCYCLICDATETYPE_DAY, 1, 0, 0, EVENTCYCLICTIMETYPE_HOUR, 6); //Every day, every 6 hours
IPS_SetEventCyclicDateFrom($eid, 1, 12, date("Y")); //From December 1st of this year
IPS_SetEventCyclicDateTo($eid, 31, 12, date("Y"));  //Until December 31st of this year

IPS_SetEventCyclicTimeFrom($eid, 15, 0, 0); //From 15:00
IPS_SetEventCyclicTimeTo($eid, 23, 30, 0);  //Until 23:30

IPS_SetParent($eid, $_IPS['SELF']);         //Assign the event
IPS_SetEventActive($eid, true);             //Activate the event

// Required since IP-Symcon 6.0, if the event shall execute an automation (e.g. a PHP script)
IPS_SetEventAction($eid, '{7938A5A2-0981-5FE0-BE6C-8AA610D654EB}', []);
Any questions?