# How to check if a device is enable?

**URL:** <https://forum.inductiveautomation.com/t/how-to-check-if-a-device-is-enable/7982>\
**Category:** Module Development\
**Created:** [February 10, 2014, 1:52pm UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-device-is-enable/7982 "2014-02-10T13:52:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [February 10, 2014, 1:52pm UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-device-is-enable/7982/1 "2014-02-10T13:52:02Z")

</div>

I use the AbstractTagDriver to create a driver.  
I’d like to check and be notified when a device is enable/disable ?  
 ![:scratch:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/76d1620bec252bfac07050c889ff5a91dc8a9c25.gif ":scratch:")

---

<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:** [February 10, 2014, 4:15pm UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-device-is-enable/7982/2 "2014-02-10T16:15:54Z")

</div>

Your driver never gets instantiated if it’s disabled, so… if you’ve “alive” and running code you’re enabled.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [February 10, 2014, 6:03pm UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-device-is-enable/7982/3 "2014-02-10T18:03:52Z")

</div>

In fact, when my device is enable, few thread are launched to manage some communications,  
I wan’t to stop these thread if the device is later disable. (“Edit device checkbox enable” unchechecked by user).

---

<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:** [February 10, 2014, 6:08pm UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-device-is-enable/7982/4 "2014-02-10T18:08:19Z")

</div>

You’ll have to manage some kind of global counter then.

Increment it each time an instance of your driver is instantiated, decrement it each time an instance has shutdown() called on it.

EDIT: Or maybe I’ve misunderstood you and these threads are started by each driver instance (and not globally, by the hook for example), in which case you just need to stop them in shutdown().

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [February 11, 2014, 12:54pm UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-device-is-enable/7982/5 "2014-02-11T12:54:26Z")

</div>

Thanks Kevin ![:thumb_left:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e26afb081ddde6df016df6ee49159cf56aaca688.gif ":thumb\_left:")  
I will stop thread for the device management in the shutdow method.
