Created question in FIWARE Q/A platform on 20-06-2018 at 13:06
Please, ANSWER this question AT https://stackoverflow.com/questions/50947432/perseo-rules-how-to-get-average-of-specific-time-window
Question:
perseo rules, how to get average of specific time window?
Description:
How can I use patterns in perseo rules with time windows? I have tried many different combinations, following the directions of EsperTech Tutorials, though, none of them was successful each time I post it to perseo. Any example for time window and how to get the average of any value (e.g. temperature) during that time will be highly appreciated. Trust me, before asking I have made a ton of efforts ![](/images/icons/emoticons/wink.gif)
One working query for me is the following:
select *,\"temperature_range_XX-YY\" as ruleName, *, ev.temperature? as Temperature, ev.id? as Id, ev.datetime? as DateTime, ev.cid? as CID, current_timestamp as TS from pattern [every ev=iotEvent(cast(cast(temperature?,String),float)>XX or cast(cast(temperature?,String),float)<YY and type=\"sensors\")]
Of course, this query returns only any temperature outside XX and YY range. What I need is to get an alert if temperature is outside the range for specific time and what is the average of all values during that time.