I have two sensors that control lights. when either one detects someone it turns on the light, when both sensors detect nobody it does not show any light. There are two special cases. If someone went to the first sensor and then left without going to the second sensor, it turns off the light. And if someone went from the first sensor to the second sensor. Not leaving
I tried to use Siddhi's Logical Pattern, but I didn't get the expected results.
@App:name("ControllerRightApp")
define stream inputStream(ternateId string,deviceId int,data string);
@sink(type='log',prefix='LOGGER')
define stream OutputStream(action string);
@info(name='CargoWeightQuery')
from inputStream[ternateId =='demo']
select ternateId,deviceId, data,json:getString(data,'$.eventName') as eventName
insert into tempStream;
from every ((e1=tempStream)->(e2=tempStream[deviceId==1 and eventName=='out'] and e3=tempStream[deviceId==2 and eventName=='out']))
select "{'deviceId':'3','action':'close'}" as action
insert into OutputStream;