Azure stream analytics query using Tumbling window -


in our application, multiple iot devices publish data iot hub. emits reading in rooms (for ex: power usage). have requirement find out total energy consumed in area in last hour , log it.

suppose, there light bulb switched on 8:00 , take 60 watt power, , switched off @ 8:20 10 min. @ 8:30 switched on in dimmed manner power usage 40 watt. energy (watt per hour) consumed between 8 , 9 should be:

60*20/60 (for 8:00 8:20 am) + 0 (8:20 8:30) + 40*30/60 (8:30 9:00) = 40 watt per hour.

how can write stream analytic query (using tumbling window achieve this).

you can use hoppingwindow produce events every minute repeating latest signal device , use tumblingwindow hourly aggregates.

-- first query produces event every minute latest known value  1 hour minutedata ( select deviceid, topone() on (order ts desc) lastrecord  input timestamp ts group deviceid, hoppinwindow(miute, 1, 60) )  select  deviceid, sum(lastrecord.wat)/60 minutedata group deviceid, tumblingwindow(hour, 1) 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -