# Time ignition perspective

**URL:** <https://forum.inductiveautomation.com/t/time-ignition-perspective/62271>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 25, 2022, 3:44pm UTC](https://forum.inductiveautomation.com/t/time-ignition-perspective/62271 "2022-07-25T15:44:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [July 25, 2022, 3:44pm UTC](https://forum.inductiveautomation.com/t/time-ignition-perspective/62271/1 "2022-07-25T15:44:16Z")

</div>

Hello, I would like to trigger an alarm if I detect engine malfunctions between 7:00 a.m. and 9:00 p.m.

For example if stpValue \>100 and the time is between 7h00 and 21h00 then I trigger an alarm.

But I don’t know how to know if the time is on the interval of 7:00 a.m. and 9:00 p.m.

---

<div class="post-metadata">

**Author:** ![swolnisty](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@swolnisty](https://forum.inductiveautomation.com/u/swolnisty)\
**Post date:** [July 25, 2022, 3:56pm UTC](https://forum.inductiveautomation.com/t/time-ignition-perspective/62271/2 "2022-07-25T15:56:49Z")

</div>

You could set up a normal alarm with an execution mode of Above Value for your setpoint, then place an expression binding on the Enabled property that looks something like:

```auto
timeBetween(now(), "7:00:00 am", "9:00:00 pm")

```

---

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [July 26, 2022, 8:01am UTC](https://forum.inductiveautomation.com/t/time-ignition-perspective/62271/4 "2022-07-26T08:01:55Z")

</div>

Thank you Sir.

That is mean  
if moteur1 = 1 and setpoint = 1 and timeBetween(now(), “7:00:00 am”, “9:00:00 pm”)  
alarm is enabled  
else:  
alarm is not enabled

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/7/f71308469fa4aa891cc3a98db0e8446da0377a22.png)

I can do that?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [July 26, 2022, 8:23am UTC](https://forum.inductiveautomation.com/t/time-ignition-perspective/62271/5 "2022-07-26T08:23:55Z")

</div>

If `moteur` and `setpoint` are boolean (True or False only) then you can use:

```auto
if moteur1 and setpoint and timeBetween(now(), “7:00:00 am”, “9:00:00 pm”):
    alarm is enabled
else:
    alarm is not enabled

```

Note the ‘:’ at the end of the line.

* * *

Please use the \</\> code formatting button when posting code. It will indent properly (important for Python) and give syntax highlighting. You can use the 🖉 edit link to fix your post.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 26, 2022, 12:07pm UTC](https://forum.inductiveautomation.com/t/time-ignition-perspective/62271/6 "2022-07-26T12:07:38Z")

</div>

Be careful. You’re starting to mix scripts and expressions.

`moteur1 && setpoint && timeBetween(now(), “7:00:00 am”, “9:00:00 pm”)`

---

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [July 26, 2022, 12:47pm UTC](https://forum.inductiveautomation.com/t/time-ignition-perspective/62271/7 "2022-07-26T12:47:00Z")

</div>

Thank you, I solved it

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [July 26, 2022, 2:30pm UTC](https://forum.inductiveautomation.com/t/time-ignition-perspective/62271/8 "2022-07-26T14:30:58Z")

</div>

Thanks, Jordan. Can you clarify what’s wrong with my approach? `timeBetween` returns a boolean so why would my script be incorrect?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 26, 2022, 2:32pm UTC](https://forum.inductiveautomation.com/t/time-ignition-perspective/62271/9 "2022-07-26T14:32:31Z")

</div>

`timeBetween` is an expression language function but you wrote Jython script syntax.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 26, 2022, 2:34pm UTC](https://forum.inductiveautomation.com/t/time-ignition-perspective/62271/10 "2022-07-26T14:34:47Z")

</div>

I was just gonna requote myself. 😉

> [@JordanCClark](#):
>
> You’re starting to mix scripts and expressions.
