# Events trigger order

**URL:** <https://forum.genieacs.com/t/events-trigger-order/4786>\
**Category:** Uncategorized\
**Created:** [December 1, 2023, 7:09pm UTC](https://forum.genieacs.com/t/events-trigger-order/4786 "2023-12-01T19:09:22Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![dchard](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/dchard/32/1612_2.png) [@dchard](https://forum.genieacs.com/u/dchard)\
**Post date:** [December 1, 2023, 7:09pm UTC](https://forum.genieacs.com/t/events-trigger-order/4786/1 "2023-12-01T19:09:22Z")

</div>

Hi,

I am having some problems triggering events in the correct order.

I have a factory reset preset which I want to run on `Inform; informEvent="0 BOOTSTRAP,1 BOOT"`

This works fine, the CPE does the factory reset and reboots itself, and a “FRS” tag is added to the device. After this the first inform is: `Inform; informEvent="1 BOOT,0 BOOTSTRAP"`

I am triggering on this to start the provisioning of the device but only after the factory reset is done.

The factory reset preset is triggered for even “0 BOOTSTRAP, 1 BOOT” plus check for the “FRS” tag is missing.  
The provisioning preset is triggered for event “1 BOOT,0 BOOTSTRAP” plus check for the “FRS” tag to be true.

Yet, 2-3 seconds after the factory reset preset is started, the provisioning preset is also started.

Question one:  
Apparently there is no different between events “0 BOOTSTRAP, 1 BOOT” and “1 BOOT,0 BOOTSTRAP” for GenieACS ?

Question two:  
How else can I trigger the provision script to only run after the factory reset is done? Apparently events and tags are not enough, maybe there is another way?

Much appreciate any and all help.

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [December 1, 2023, 7:57pm UTC](https://forum.genieacs.com/t/events-trigger-order/4786/2 "2023-12-01T19:57:12Z")

</div>

> [@dchard](#):
>
> after the factory reset is done

The factory reset is “done” when the CPE informs `0 BOOTSTRAP`. What is the issue you are trying to actually solve?

> [@dchard](#):
>
> Apparently there is no different between events

This is accurate.

---

<div class="post-metadata">

**Author:** ![dchard](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/dchard/32/1612_2.png) [@dchard](https://forum.genieacs.com/u/dchard)\
**Post date:** [December 1, 2023, 8:55pm UTC](https://forum.genieacs.com/t/events-trigger-order/4786/3 "2023-12-01T20:55:39Z")

</div>

> The factory reset is “done” when the CPE informs `0 BOOTSTRAP`.

The problem is apparently that is the response when the CPE first connects to the ACS, and also the response after a factory reset.

> What is the issue you are trying to actually solve?

I try to resolve the issue to do a factory reset when the device first connects to the ACS. This part actually works triggering on the “0 BOOTSTRAP” event.

And after the factory reset is done, I want to trigger the provisioning of the CPE. The problem is: currently the factory reset and the provisioning is triggered at the same time, and not atfer one another. And becuase the prov is started while the devices is doing the factory reset, the device provisioning fails.

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [December 1, 2023, 10:07pm UTC](https://forum.genieacs.com/t/events-trigger-order/4786/4 "2023-12-01T22:07:50Z")

</div>

> [@dchard](#):
>
> And becuase the prov is started while the devices is doing the factory reset, the device provisioning fails.

Are there any errors that happen when the CPE sends a `0 BOOTSTRAP`? Per the spec, the CPE is _required_ to resend events if a fault is encountered during the process.

---

<div class="post-metadata">

**Author:** ![dchard](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/dchard/32/1612_2.png) [@dchard](https://forum.genieacs.com/u/dchard)\
**Post date:** [December 1, 2023, 10:20pm UTC](https://forum.genieacs.com/t/events-trigger-order/4786/5 "2023-12-01T22:20:15Z")

</div>

I dont think the issue is on the CPE side.

The ACS sends the factory reset on “0 BOOTSTRAP,1 BOOT”:

```auto
Inform; cpeRequestId="37" informEvent="0 BOOTSTRAP,1 BOOT"
Script: factory reset command sent to ONT!

```

2-4 seconds later the ACS tries to provision the CPE while it is already factory resetting:

`Script: ONT provision for SN: 485754430AD6C29B`

This fails obviously, as the CPE is already doing the reboot after the factory reset:

`Channel has faulted; channel="provision" retries=0 faultCode="session_terminated" faultMessage="The TR-069 session was unsuccessfully terminated"`

So the question is: should the ACS retry the failed “provision” preset after the CPE finished the factory reset and reachable again?

And more importantly: how to trigger the provision preset preferably not in the middle of the factory reset already ongoing? As this is the root cause of the issue: the ACS tries to provision during a factory reset ongoing.

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [December 1, 2023, 10:35pm UTC](https://forum.genieacs.com/t/events-trigger-order/4786/6 "2023-12-01T22:35:12Z")

</div>

> [@dchard](#):
>
> I dont think the issue is on the CPE side.

If your router is sending a `0 BOOTSTRAP` while it still in the process of doing a factory reset, then it is the issue. Every CPE I’ve encountered sends `0 BOOTSTRAP ` **after** its done doing a factory reset.

As for why the event is ocuring multiple times, its because of this error message:

> [@dchard](#):
>
> The TR-069 session was unsuccessfully terminated

> [@akcoder](#):
>
> Per the spec, the CPE is _required_ to resend events if a fault is encountered during the process.

---

<div class="post-metadata">

**Author:** ![dchard](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/dchard/32/1612_2.png) [@dchard](https://forum.genieacs.com/u/dchard)\
**Post date:** [December 1, 2023, 10:46pm UTC](https://forum.genieacs.com/t/events-trigger-order/4786/7 "2023-12-01T22:46:26Z")

</div>

There is a misunderstanding here:

The first “0 BOOTSTRAP” event is happening because the ONT received the TR-069 server parameters from the OLT. As much as I know, when the TR-069 URL changes on the ONT, it is normal to report a “0 BOOTSTRAP” event although this is not an actual factory reset as only the TR-069 parameters of the ONT are changing here.

So for the above “0 BOOTSTRAP” event I trigger the “actual” factory reset, and of course as you said it, this results in a second “0 BOOTSTRAP” report once the ONT finished the factory reset.

The problem is that during the “actual” factory reset is ongoing, the provision script is also triggered, which fails as the ONT is already undergoing the reboot part for the factory reset → no ACS connection → the prov preset fails.

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [December 1, 2023, 11:15pm UTC](https://forum.genieacs.com/t/events-trigger-order/4786/8 "2023-12-01T23:15:42Z")

</div>

Okay, so now I understand better what the actual issue is. Here is a provision flow that will work:

Create a preset tied to `0 BOOTSTRAP` which kicks off the `Bootstrap` provision script. If you installed GenieACS at v1.2 or later this is already done for you. Modify the Bootstrap script to add this line:

```auto
declare('Tags.Provisioned', null, {value: false});

```

Create a second preset with an event of `-0 BOOSTRAP` with a precondition of `Tags.Provisioned IS NULL` and this will kick off your provision script.

This is the exact process we use. Most of the info in the wiki article came directly or indirectly from me 🙂.

> **[Example of a Provisioning Flow](https://github.com/genieacs/genieacs/wiki/Example-of-a-Provisioning-Flow)**
>
> A fast and lightweight TR-069 Auto Configuration Server (ACS) - genieacs/genieacs

---

<div class="post-metadata">

**Author:** ![dchard](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/dchard/32/1612_2.png) [@dchard](https://forum.genieacs.com/u/dchard)\
**Post date:** [December 1, 2023, 11:23pm UTC](https://forum.genieacs.com/t/events-trigger-order/4786/9 "2023-12-01T23:23:15Z")

</div>

Much appreciate your help! Most of the things I figured out was mostly based on your responses on this forum. 🙂

One question: how will the second preset trigger if I set the precondition to " `-0 BOOSTRAP`" and the ONT comes back with “1 BOOT,0 BOOTSTRAP” after the “actual” factory reset? Just trying to better understand this, but if you say it will trigger, I believe you 🙂

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [December 1, 2023, 11:32pm UTC](https://forum.genieacs.com/t/events-trigger-order/4786/10 "2023-12-01T23:32:47Z")

</div>

Ahh, so I forgot to mention that. I configure all of our CPEs with the lowest possible `PeriodicInformInterval` possible. For some of my CPEs its set to 5 seconds. Others 30 seconds. So when the CPE does another `2 PERIODIC` the provisioning process continues. At the end of the provisioning process I set the inform interval to 3600 seconds (1 hr).

---

<div class="post-metadata">

**Author:** ![dchard](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/dchard/32/1612_2.png) [@dchard](https://forum.genieacs.com/u/dchard)\
**Post date:** [December 1, 2023, 11:43pm UTC](https://forum.genieacs.com/t/events-trigger-order/4786/11 "2023-12-01T23:43:58Z")

</div>

In my case the `PeriodicInformInterval` is 60 seconds (there is a good reason behind this frequent polling rate), and I think your “-0 BOOTSTRAP” event worked correctly: it eliminated the prov to be triggered during the factory reset, and after the factory reset it got triggered and the device is provisioned successfully.

Will play with this in various scenarios, but I think it works as intended. Thanks again!  
PS: I have a problematic Sagemcom ONT so I might pop up in another thread 🙂
