# Using the presence feature via LANmanager

**URL:** <https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467>\
**Category:** Scènes\
**Created:** [November 7, 2023, 7:26pm UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467 "2023-11-07T19:26:42Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaelbillon](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/gaelbillon/32/12185_2.png) [@gaelbillon](https://community.gladysassistant.com/u/gaelbillon)\
**Post date:** [November 7, 2023, 7:26pm UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/1 "2023-11-07T19:26:42Z")

</div>

Hello,

After searching and doing several tests I couldn’t find it; I would like to know whether, with the LAN Manager integration, what value is returned by the presence feature, and whether it is possible to use it with «&nbsp;continue only if&nbsp;» in scenes.

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/b/b30ac34ec227195fffc6fbcaa83f4c63b2274f92.png)

Thank you in advance

---

<div class="post-metadata">

**Author:** ![Will\_71](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/will_71/32/9582_2.png) [@Will\_71](https://community.gladysassistant.com/u/Will_71)\
**Post date:** [November 7, 2023, 7:43pm UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/2 "2023-11-07T19:43:44Z")

</div>

Hi,

In the scenes you have this trigger

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/5/5ccda49a3b462bde37a85ced457d7a068adc47cb.png)

Yes it’s possible but I’ve never tested it.

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/c/c5c7eb0cbb9fe810dbd81bc6bd4c9ffd5b24ce2c.png)

And if you want to know the value a variable returns you can send the variable as a message

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/5/5d82b11cf950b8d44d7936b884437f3affc8e422.png)

---

<div class="post-metadata">

**Author:** ![gaelbillon](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/gaelbillon/32/12185_2.png) [@gaelbillon](https://community.gladysassistant.com/u/gaelbillon)\
**Post date:** [November 7, 2023, 8:10pm UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/3 "2023-11-07T20:10:42Z")

</div>

Thanks @_Will_71 for your reply, well spotted I forgot to send the message for the variable.  
For the trigger — OK, that’s what I had done to indicate if seen at home.  
However, for using the variable in the scenes that’s what I also tested, but unfortunately not functional because the value of the presence function of LANmanager is always 1 even if the phone is not connected to the LAN.

@AlexTrovato I couldn’t find it in the various threads, but is this the expected behavior?

Thanks

---

<div class="post-metadata">

**Author:** ![cce66](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/8797f3/32.png) [@cce66](https://community.gladysassistant.com/u/cce66)\
**Post date:** [November 7, 2023, 8:37pm UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/4 "2023-11-07T20:37:57Z")

</div>

I can see my devices on the LAN

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/3/341cc6e26660901fe5dc2bd5d30af14a4efdd038.png)

I have this printer

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/c/c1933e8e869c0815b4fa59593b207f2e14f14cc7.png)

I create a scene «&nbsp;If MF8040CN absent LAN turn off the light&nbsp;»

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/2/2afd3d6b358c89bc1eca10484f108d70ed5baa47.png)

I create a scene «&nbsp;If MF8040CN present LAN turn on the light&nbsp;»

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/7/72549100d6a826849f667ada46f706b579ceb1a1.png)

Using «&nbsp;present&nbsp;» as in the screenshot

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/2/239986785f0ae6fb1a3f2de0df7aec38c1c432d6.png)

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/1/12303fd144ae82f9539f29f9ebf4cd5fd2249d11.png)

This should work but the problem is knowing how or with which value the device is marked as present

Looking in the GitHub code [Gladys/server/services/lan-manager/lib/lan-manager.constants.js at master · GladysAssistant/Gladys · GitHub](https://github.com/GladysAssistant/Gladys/blob/master/server/services/lan-manager/lib/lan-manager.constants.js)  
I found  
const PRESENCE\_STATUS = {  
ENABLED: ‹&nbsp;enabled&nbsp;›,  
DISABLED: ‹&nbsp;disabled&nbsp;›,  
};

I tried with ‹&nbsp;enabled&nbsp;› ‹&nbsp;disabled&nbsp;› but it doesn’t work…

However, when launching the scenes the plug turns on or off depending on the scene called… 🤔

If you can help I think you’re the one who developed this integration @AlexTrovato

---

<div class="post-metadata">

**Author:** ![guim31](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/guim31/32/4840_2.png) [@guim31](https://community.gladysassistant.com/u/guim31)\
**Post date:** [November 7, 2023, 8:45pm UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/5 "2023-11-07T20:45:17Z")

</div>

I notice 2 things :

- you don’t have a Trigger in your scene (maybe it’s planned, I’m mentioning it just in case)
- I think you should set either the value 1 for «&nbsp;present&nbsp;» or 0 for «&nbsp;absent&nbsp;»

---

<div class="post-metadata">

**Author:** ![cce66](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/8797f3/32.png) [@cce66](https://community.gladysassistant.com/u/cce66)\
**Post date:** [November 7, 2023, 9:00pm UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/6 "2023-11-07T21:00:47Z")

</div>

> [@guim31](#):
>
> you don’t have a Trigger in your scene (maybe it’s planned, I’m saying it just in case)

yes I haven’t put one for now I trigger the scene by hand it goes faster to «&nbsp;debug&nbsp;» the part below :wink

---

<div class="post-metadata">

**Author:** ![gaelbillon](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/gaelbillon/32/12185_2.png) [@gaelbillon](https://community.gladysassistant.com/u/gaelbillon)\
**Post date:** [November 7, 2023, 9:19pm UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/7 "2023-11-07T21:19:48Z")

</div>

> [@guim31](#):
>
> I think you have to set either the value 1 for «&nbsp;present&nbsp;» or 0 for «&nbsp;absent&nbsp;»

Like @cce66 I also tried but it doesn’t work, and when sending me the variable I always get «&nbsp;1&nbsp;» in return even when not logged in.

---

<div class="post-metadata">

**Author:** ![guim31](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/guim31/32/4840_2.png) [@guim31](https://community.gladysassistant.com/u/guim31)\
**Post date:** [November 8, 2023, 7:59am UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/8 "2023-11-08T07:59:50Z")

</div>

I just tested and I confirm that the value is still == 1

---

<div class="post-metadata">

**Author:** ![cce66](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/8797f3/32.png) [@cce66](https://community.gladysassistant.com/u/cce66)\
**Post date:** [November 8, 2023, 10:35am UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/9 "2023-11-08T10:35:10Z")

</div>

@AlexTrovato looking at the code

> <https://github.com/GladysAssistant/Gladys/blob/master/server/services/lan-manager/lib/lan-manager.scanPresence.js>

I think the state value isn’t being set to 0 if the device is not found

```auto
37 if (discoveredDevicesByMAC[deviceMAC]) {
38 this.gladys.event.emit(EVENTS.DEVICE.NEW_STATE, {
39 device_feature_external_id: externalId,
40 state: 1,
 41 });

```

If I’m not mistaken it should be this

```auto
if (discoveredDevicesByMAC[deviceMAC]) {
    this.gladys.event.emit(EVENTS.DEVICE.NEW_STATE, {
        device_feature_external_id: externalId,
        state: 1,
    });
} else {
    this.gladys.event.emit(EVENTS.DEVICE.NEW_STATE, {
        device_feature_external_id: externalId,
        state: 0,
    });
}

```

I’m not sure about my suggestion 🤔 so don’t make fun of me 😊

---

<div class="post-metadata">

**Author:** ![francois](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/francois/32/14531_2.png) [@francois](https://community.gladysassistant.com/u/francois)\
**Post date:** [November 12, 2023, 12:02am UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/10 "2023-11-12T00:02:47Z")

</div>

Hi,

I notice the same thing. My phone disappears from the Wi‑Fi and despite minutes passing (with a default scan of 2 min), the presence of my phone stays at 1 Ad Vitam…

However, I may be doing

---

<div class="post-metadata">

**Author:** ![guim31](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/guim31/32/4840_2.png) [@guim31](https://community.gladysassistant.com/u/guim31)\
**Post date:** [November 12, 2023, 8:27am UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/11 "2023-11-12T08:27:56Z")

</div>

I don’t think you’re doing it wrong. In my opinion, there’s a bug to fix! 👍

---

<div class="post-metadata">

**Author:** ![GBoulvin](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/gboulvin/32/10006_2.png) [@GBoulvin](https://community.gladysassistant.com/u/GBoulvin)\
**Post date:** [November 12, 2023, 8:58am UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/12 "2023-11-12T08:58:27Z")

</div>

At my place, it’s worked from the start!  
The two scenes:

- Interval 8 minutes (trigger)
- Check user presence (device seen within the last 3 minutes)
- Get the last state (of the phone)
- Continue only if phone = 1
- User LEFT the house

Second scene:

- Device state change (phone-presence)  
 ![Screenshot_20231112_095426](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/c/cec51e9ad3b2008fc69d5540f2a4ebe992a224e9.jpeg)
- User seen at home

In LANmanager, the scan is set to 2 minutes  
I have very few false departures, except at night when phones go into power-saving mode and are therefore disconnected from the Wi-Fi, obviously.  
The scan intervals and triggers certainly need to be reviewed, but since it was working like that…

 ![Screenshot_20231112_100029](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/7/7c536ca895a13ca980edeb11002a11d99ca924b0.jpeg)  
 ![Screenshot_20231112_100050](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/2/2508ab4f220b7b5374f7df052d782d6d5342db71.jpeg)  
(Yes, they’re still asleep 😇, those ones)

---

<div class="post-metadata">

**Author:** ![cicoub13](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/cicoub13/32/4482_2.png) [@cicoub13](https://community.gladysassistant.com/u/cicoub13)\
**Post date:** [November 12, 2023, 12:26pm UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/13 "2023-11-12T12:26:04Z")

</div>

So the trigger for «&nbsp;Phone device change&nbsp;» only fires when the phone becomes present, and not when it becomes absent. This should be improved to make scenes easier (for example, like a contact sensor).

---

<div class="post-metadata">

**Author:** ![francois](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/francois/32/14531_2.png) [@francois](https://community.gladysassistant.com/u/francois)\
**Post date:** [November 12, 2023, 7:11pm UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/15 "2023-11-12T19:11:38Z")

</div>

Hi,  
If presence = 1, that means the phone is seen, so we should be seen in the house and not have left the house, right?

---

<div class="post-metadata">

**Author:** ![GBoulvin](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/gboulvin/32/10006_2.png) [@GBoulvin](https://community.gladysassistant.com/u/GBoulvin)\
**Post date:** [November 12, 2023, 9:49pm UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/16 "2023-11-12T21:49:21Z")

</div>

I know very well that it’s not logical, but it works. If I put 0, I’m marked as present all the time.

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [November 13, 2023, 9:02am UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/17 "2023-11-13T09:02:50Z")

</div>

Hi @francois 🙂

I recommend you read the Bluetooth integration tutorial for presence management ( [Gérer la présence avec la détection Bluetooth | Gladys Assistant](https://gladysassistant.com/fr/docs/integrations/bluetooth/) )

It works the same way with LAN Manager.

Basically, what you need to remember is that you need 2 scenes:

- A scene «&nbsp;device state change&nbsp;» → «&nbsp;If the device is detected&nbsp;» that marks your user as «&nbsp;seen at home&nbsp;». It looks like you already have this scene.

- A scene «&nbsp;Scheduled trigger&nbsp;», every 5 minutes for example, that uses the scene action «&nbsp;Check presence&nbsp;».

The idea behind the «&nbsp;Check presence&nbsp;» action is to fetch the last time your device(s) were seen at home. If it was more than XX minutes ago, then Gladys will mark you as away.

---

<div class="post-metadata">

**Author:** ![cce66](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/8797f3/32.png) [@cce66](https://community.gladysassistant.com/u/cce66)\
**Post date:** [November 13, 2023, 10:04am UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/18 "2023-11-13T10:04:16Z")

</div>

Hello @pierre-gilles

So in short, to detect presence or non-presence it’s:

We test presence by checking if it’s equal = 1

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/f/f3cf54f5914d4ad92a5159cbb84a0877e4f36783.png)

We test absence by checking if it’s **different \<\>** 1 (and not if = 0)

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/8/894167f6ce316a2a70558e655e4d8cc5f2f7a7ff.png)

This should be specified on that page because it leads one to think that

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [November 13, 2023, 10:06am UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/19 "2023-11-13T10:06:30Z")

</div>

> [@cce66](#):
>
> We test for absence by checking if it’s **different \<\> 1** (and not if it equals 0)

Actually, no

We test for absence if the last time the device was seen was more than X minutes ago.

---

<div class="post-metadata">

**Author:** ![cce66](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/8797f3/32.png) [@cce66](https://community.gladysassistant.com/u/cce66)\
**Post date:** [November 13, 2023, 10:57am UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/20 "2023-11-13T10:57:31Z")

</div>

Sorry to be a pain but I don’t see how to use this feature in scene creation and I think there’s confusion not just for me!  
I understand that X minutes is determined by the scan we configured in the lan-manager module but I don’t understand what is needed to test presence or to test absence (which is a non-presence for X minutes to detect in this case)

Could you attach a screenshot of what should be set to test the presence  
of a device because I’m totally confused about this if what I put above is not correct!

Could you attach a screenshot of what should be set to test non-presence for X minutes (i.e., absence at the time of testing)

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/1/16aa3493536007fc6e28f105f32298efb3d7d0c9.png)

Because the problem is that you may want a scene to test the presence of a device on the network

- user returned home so alarm disarmed, lights turned on, etc.
- camera functional so send an image
- box that responds — everything’s fine

Or you may want a scene to test the absence of a device on the network

- user absent so alarm activated if house empty, lights turned off, etc.
- camera malfunctioning send a message, etc.
- box no longer responding so if plugged into a switched outlet reboot the outlet, etc.

I think you think we’re talking about that which links user and device (with ‹&nbsp;seen X minutes&nbsp;›)

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/e/e8f9b5c8ac757dbc52f9f9734b57032ace3cb23a.png)

Whereas here we’re just talking about device presence not linked to any user

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/5/50a95958828cf628774153947d37ae8002e31d91.png)

And for this we don’t really know how to use this feature and especially which values to use. Also, to inject a variable you have to search the forum to know that you need to put a space after the two braces to get the list of variables whereas it’s shown as ‹&nbsp;{{&nbsp;› without a space:  
 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/c/c6d7398347e65e3b2984b2df553886cdedbefd52.png)  
So either it’s not the intended effect or there’s a bug, but putting myself in the shoes of a new user who wants to try Gladys before adopting it, they try things and it doesn’t work: two possibilities — they search the forum to find out why it doesn’t work as shown, or they consider the product unstable or non-functional and switch to another home automation solution, which is a shame when it’s over details like this!  
I’d like to understand so that afterwards it’s possible to make mini-tutorials with concrete usage examples of features that can help people adopt Gladys. 🙂 because I think a mini-tutorial with a concrete example is illustrative and sometimes better than documentation!

---

<div class="post-metadata">

**Author:** ![francois](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/francois/32/14531_2.png) [@francois](https://community.gladysassistant.com/u/francois)\
**Post date:** [November 14, 2023, 3:22pm UTC](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467/21 "2023-11-14T15:22:28Z")

</div>

Hi @pierre-gilles,

I must admit that detecting presence via the LAN, rather than using Bluetooth or OwnsTracks, seems simpler in my situation.

The goal is to avoid having to touch my daughters’ phones, which spend their time turning off all the «&nbsp;unnecessary&nbsp;» services in their eyes. Geolocation is among those unnecessary services.  
And the likelihood of seeing a NUT key fob end up at the bottom of a cupboard seems extremely high…

Since the phone and Wi-Fi are the base of their Maslow’s pyramid, I know I’ll get the right info by relying on Wi‑Fi…

You choose your friends but rarely your family 🙂

PS : but I just realized that I misread your reply and that the link you suggested does indeed talk about both scenarios. thanks 🙂

[Next page](https://community.gladysassistant.com/t/utilisation-fonctionnalite-presence-via-lanmanager/8467.md?page=2)
