espressif / esp-rainmaker

ESP RainMaker Agent for firmware development
Apache License 2.0
431 stars 145 forks source link

Automations - infinity loop issue (MEGH-4304) #236

Open jacek12345 opened 1 year ago

jacek12345 commented 1 year ago

It is simple to make infinity loop with Automation feature.

https://user-images.githubusercontent.com/34368502/217755451-d7d65bcd-406d-4e34-844b-877b2da14925.mp4

It can take place because of logic mistake or deliberate action. The result will be generating a lot of traffic on AWS. It is more probable with complex Automation scenarios and can be unintended and accidentally made by end customer. I think that there should be some kind of prevention. I suggest to add some configuration parameters for Automation module: CONFIG_AUTOMATION_CNT_MAX_VAL - maximum ammount of the_same_Automation_event triggers allowed CONFIG_AUTOMATION_CNT_TIME_WINDOW - time window for counting Automation triggers CONFIG_AUTOMATION_INACTIVE_TIME - Automation inactive time after to much Automation events detection if too much automation events is detected, it is disabled for a certain amount of time, which will break the infinite loop. Also notification in app appreciated. E.g.: CONFIG_AUTOMATION_CNT_MAX_VAL=20 CONFIG_AUTOMATION_CNT_TIME_WINDOW=60 CONFIG_AUTOMATION_INACTIVE_TIME=10 if Automation X occured 20 times per 60 sec., disable Automation X for 10 sec.

shahpiyushv commented 1 year ago

@jacek12345 , we will definitely take this up on priority in the cloud backend.