Non Occurrence Pattern

Non occurrence patterns identifies the absence of events when detecting a pattern.

Siddhi detects non-occurrence of events using the not keyword, and its effective non-occurrence checking period is bounded either by fulfillment of a condition associated by and or via an expiry time using <time period>.

Refer the Siddhi query guide for more information.

define stream RegulatorStateChangeStream(deviceID long,
    roomNo int, tempSet double, action string);

define stream TemperatureStream (roomNo int, temp double);

@sink(type='log')
define stream RoomTemperatureAlertStream(roomNo int);

from e1=RegulatorStateChangeStream[action == 'on']
     -> not TemperatureStream[e1.roomNo == roomNo and
        temp <= e1.tempSet] for 30 sec
select e1.roomNo as roomNo
insert into RoomTemperatureAlertStream;
define stream RegulatorStateChangeStream(deviceID long,
    roomNo int, tempSet double, action string);

Defines RegulatorStateChangeStream having information of regulator state change such as deviceID, roomNo, tempSet and action.

define stream TemperatureStream (roomNo int, temp double);

Defines TemperatureStream having information of room temperature such as roomNo and temp.

@sink(type='log')
define stream RoomTemperatureAlertStream(roomNo int);

Defines RoomTemperatureAlertStream which contains the temperature alerts.

from e1=RegulatorStateChangeStream[action == 'on']
     -> not TemperatureStream[e1.roomNo == roomNo and
        temp <= e1.tempSet] for 30 sec

Alerts if no temperature event having a temperature less than what is set in regulator arrives within 5 minutes after switching on the regulator.

select e1.roomNo as roomNo
insert into RoomTemperatureAlertStream;

This application sends a notification alert if the room temperature is not reduced to the expected level after the regulator is started.

Input

  • First, below event is sent to RegulatorStateChangeStream,

    [10, 5, 30, on]

Output

After processing the above input event, there will be an alert event arriving at RoomTemperatureAlertStream after the 30 seconds (from the first event):

[5]

Top